Skip to content

Commit 7bb23d8

Browse files
authored
chore: fix pylint message else-if-used (#888)
Signed-off-by: Jens Troeger <jens.troeger@light-speed.de>
1 parent bc89fe9 commit 7bb23d8

File tree

4 files changed

+42
-43
lines changed

4 files changed

+42
-43
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
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.check_elif",
215216
"pylint.extensions.for_any_all",
216217
"pylint.extensions.overlapping_exceptions",
217218
"pylint.extensions.set_membership",

src/macaron/repo_finder/commit_finder.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -776,12 +776,11 @@ def _compute_tag_version_similarity(
776776
# A half value is used here as otherwise it can lead to the same score as a tag_suffix that is
777777
# equal to the last part.
778778
score = score - 0.5
779+
elif tag_suffix not in release_set:
780+
# The suffix does not match, and is not similar.
781+
score = score + 1
779782
else:
780-
if tag_suffix not in release_set:
781-
# The suffix does not match, and is not similar.
782-
score = score + 1
783-
else:
784-
score = score + 0.2
783+
score = score + 0.2
785784
else:
786785
# If no suffix pattern can be created the suffix cannot be matched to the last version part.
787786
score = score + 1

src/macaron/slsa_analyzer/ci_service/github_actions/analyzer.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -311,37 +311,37 @@ def build_call_graph_from_node(node: GitHubWorkflowNode, repo_path: str) -> None
311311
)
312312
external_node.model = create_third_party_action_model(external_node)
313313
job_node.add_callee(external_node)
314-
else:
315-
# Check the shell type configuration. We currently can support `bash`` and `sh`.
316-
# By default `bash`` is used on non-Windows runners, which we support.
317-
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrunshell
318-
# TODO: support Powershell for Windows runners, which is the default shell in GitHub Actions.
319-
# Right now, the script with the default shell is passed to the parser, which will fail
320-
# if the runner is Windows and Powershell is used. But there is no easy way to avoid passing
321-
# the script because that means we need to accurately determine the runner's OS.
322-
if step.get("run") and ("shell" not in step or step["shell"] in {"bash", "sh"}):
323-
try:
324-
name = "UNKNOWN"
325-
node_id = None
326-
if "id" in step:
327-
node_id = step["id"]
328-
if "name" in step:
329-
name = step["name"]
330-
331-
callee = create_bash_node(
332-
name=name,
333-
node_id=node_id,
334-
node_type=BashScriptType.INLINE,
335-
source_path=node.source_path,
336-
ci_step_ast=step,
337-
repo_path=repo_path,
338-
caller=job_node,
339-
recursion_depth=0,
340-
)
341-
except CallGraphError as error:
342-
logger.debug(error)
343-
continue
344-
job_node.add_callee(callee)
314+
315+
# Check the shell type configuration. We currently can support `bash`` and `sh`.
316+
# By default `bash`` is used on non-Windows runners, which we support.
317+
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrunshell
318+
# TODO: support Powershell for Windows runners, which is the default shell in GitHub Actions.
319+
# Right now, the script with the default shell is passed to the parser, which will fail
320+
# if the runner is Windows and Powershell is used. But there is no easy way to avoid passing
321+
# the script because that means we need to accurately determine the runner's OS.
322+
elif step.get("run") and ("shell" not in step or step["shell"] in {"bash", "sh"}):
323+
try:
324+
name = "UNKNOWN"
325+
node_id = None
326+
if "id" in step:
327+
node_id = step["id"]
328+
if "name" in step:
329+
name = step["name"]
330+
331+
callee = create_bash_node(
332+
name=name,
333+
node_id=node_id,
334+
node_type=BashScriptType.INLINE,
335+
source_path=node.source_path,
336+
ci_step_ast=step,
337+
repo_path=repo_path,
338+
caller=job_node,
339+
recursion_depth=0,
340+
)
341+
except CallGraphError as error:
342+
logger.debug(error)
343+
continue
344+
job_node.add_callee(callee)
345345

346346
elif is_reusable_workflow_call_job(job):
347347
workflow_call_job_with_id = Identified[ReusableWorkflowCallJob](job_name, job)

tests/integration/run.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,12 @@ def run_command(self, cwd: str, macaron_cmd: str) -> int:
166166
" ".join(args),
167167
)
168168
return 1
169-
else:
170-
if res.returncode != 0:
171-
logger.error(
172-
"Command '%s' unexpectedly exited with non-zero code.",
173-
" ".join(args),
174-
)
175-
return 1
169+
elif res.returncode != 0:
170+
logger.error(
171+
"Command '%s' unexpectedly exited with non-zero code.",
172+
" ".join(args),
173+
)
174+
return 1
176175

177176
time_taken = (end_time - start_time) / 1e9
178177
logger.info(

0 commit comments

Comments
 (0)