Skip to content

Commit 6b9742d

Browse files
authored
chore: fix pylint message consider-using-any-or-all (#881)
Signed-off-by: Jens Troeger <[email protected]>
1 parent 94504d4 commit 6b9742d

File tree

15 files changed

+16
-65
lines changed

15 files changed

+16
-65
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ ignore_missing_imports = true
212212
fail-under = 10.0
213213
suggestion-mode = true # Remove this setting when pylint v4 is released.
214214
load-plugins = [
215+
"pylint.extensions.for_any_all",
215216
]
216217
disable = [
217218
"fixme",
@@ -230,7 +231,6 @@ disable = [
230231
"too-many-public-methods",
231232
"too-many-return-statements",
232233
"too-many-statements",
233-
"too-many-try-statements",
234234
"duplicate-code",
235235
]
236236

src/macaron/slsa_analyzer/build_tool/docker.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ def is_detected(self, repo_path: str) -> bool:
4444
bool
4545
True if this build tool is detected, else False.
4646
"""
47-
for file in self.build_configs:
48-
if file_exists(repo_path, file):
49-
return True
50-
51-
return False
47+
return any(file_exists(repo_path, file) for file in self.build_configs)
5248

5349
def prepare_config_files(self, wrapper_path: str, build_dir: str) -> bool:
5450
"""Make necessary preparations for using this build tool.

src/macaron/slsa_analyzer/build_tool/go.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ def is_detected(self, repo_path: str) -> bool:
4444
True if this build tool is detected, else False.
4545
"""
4646
go_config_files = self.build_configs + self.entry_conf
47-
for file in go_config_files:
48-
if file_exists(repo_path, file):
49-
return True
50-
51-
return False
47+
return any(file_exists(repo_path, file) for file in go_config_files)
5248

5349
def prepare_config_files(self, wrapper_path: str, build_dir: str) -> bool:
5450
"""Prepare the necessary wrapper files for running the build.

src/macaron/slsa_analyzer/build_tool/gradle.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ def is_detected(self, repo_path: str) -> bool:
7373
True if this build tool is detected, else False.
7474
"""
7575
gradle_config_files = self.build_configs + self.entry_conf
76-
for file in gradle_config_files:
77-
if file_exists(repo_path, file):
78-
return True
79-
80-
return False
76+
return any(file_exists(repo_path, file) for file in gradle_config_files)
8177

8278
def prepare_config_files(self, wrapper_path: str, build_dir: str) -> bool:
8379
"""Prepare the necessary wrapper files for running the build.

src/macaron/slsa_analyzer/build_tool/maven.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ def is_detected(self, repo_path: str) -> bool:
6666
)
6767
return False
6868
maven_config_files = self.build_configs
69-
for file in maven_config_files:
70-
if file_exists(repo_path, file):
71-
return True
72-
73-
return False
69+
return any(file_exists(repo_path, file) for file in maven_config_files)
7470

7571
def prepare_config_files(self, wrapper_path: str, build_dir: str) -> bool:
7672
"""Prepare the necessary wrapper files for running the build.

src/macaron/slsa_analyzer/build_tool/npm.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ def is_detected(self, repo_path: str) -> bool:
5757
# cases like .npmrc existing but not package-lock.json and whether
5858
# they would still count as "detected"
5959
npm_config_files = self.build_configs + self.package_lock + self.entry_conf
60-
for file in npm_config_files:
61-
if file_exists(repo_path, file):
62-
return True
63-
64-
return False
60+
return any(file_exists(repo_path, file) for file in npm_config_files)
6561

6662
def prepare_config_files(self, wrapper_path: str, build_dir: str) -> bool:
6763
"""Prepare the necessary wrapper files for running the build.

src/macaron/slsa_analyzer/build_tool/pip.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ def is_detected(self, repo_path: str) -> bool:
5555
bool
5656
True if this build tool is detected, else False.
5757
"""
58-
for file in self.build_configs:
59-
if file_exists(repo_path, file):
60-
return True
61-
return False
58+
return any(file_exists(repo_path, file) for file in self.build_configs)
6259

6360
def prepare_config_files(self, wrapper_path: str, build_dir: str) -> bool:
6461
"""Prepare the necessary wrapper files for running the build.

src/macaron/slsa_analyzer/build_tool/yarn.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@ def is_detected(self, repo_path: str) -> bool:
5555
# cases like .yarnrc existing but not package-lock.json and whether
5656
# they would still count as "detected"
5757
yarn_config_files = self.build_configs + self.package_lock + self.entry_conf
58-
for file in yarn_config_files:
59-
if file_exists(repo_path, file):
60-
return True
61-
62-
return False
58+
return any(file_exists(repo_path, file) for file in yarn_config_files)
6359

6460
def prepare_config_files(self, wrapper_path: str, build_dir: str) -> bool:
6561
"""Prepare the necessary wrapper files for running the build.

src/macaron/slsa_analyzer/package_registry/jfrog_maven_registry.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,7 @@ def is_detected(self, build_tool: BaseBuildTool) -> bool:
194194
if not self.enabled:
195195
return False
196196
compatible_build_tool_classes = [Maven, Gradle]
197-
for build_tool_class in compatible_build_tool_classes:
198-
if isinstance(build_tool, build_tool_class):
199-
return True
200-
return False
197+
return any(isinstance(build_tool, build_tool_class) for build_tool_class in compatible_build_tool_classes)
201198

202199
def construct_maven_repository_path(
203200
self,

src/macaron/slsa_analyzer/package_registry/maven_central_registry.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2023 - 2023, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2023 - 2024, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
"""The module provides abstractions for the Maven Central package registry."""
@@ -100,10 +100,7 @@ def is_detected(self, build_tool: BaseBuildTool) -> bool:
100100
based on the given build tool.
101101
"""
102102
compatible_build_tool_classes = [Maven, Gradle]
103-
for build_tool_class in compatible_build_tool_classes:
104-
if isinstance(build_tool, build_tool_class):
105-
return True
106-
return False
103+
return any(isinstance(build_tool, build_tool_class) for build_tool_class in compatible_build_tool_classes)
107104

108105
def find_publish_timestamp(self, group_id: str, artifact_id: str, version: str | None = None) -> datetime:
109106
"""Make a search request to Maven Central to find the publishing timestamp of an artifact.

0 commit comments

Comments
 (0)