Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix pylint message else-if-used #888

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ ignore_missing_imports = true
fail-under = 10.0
suggestion-mode = true # Remove this setting when pylint v4 is released.
load-plugins = [
"pylint.extensions.check_elif",
"pylint.extensions.for_any_all",
"pylint.extensions.overlapping_exceptions",
"pylint.extensions.set_membership",
Expand Down
9 changes: 4 additions & 5 deletions src/macaron/repo_finder/commit_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,12 +776,11 @@ def _compute_tag_version_similarity(
# A half value is used here as otherwise it can lead to the same score as a tag_suffix that is
# equal to the last part.
score = score - 0.5
elif tag_suffix not in release_set:
# The suffix does not match, and is not similar.
score = score + 1
else:
if tag_suffix not in release_set:
# The suffix does not match, and is not similar.
score = score + 1
else:
score = score + 0.2
score = score + 0.2
else:
# If no suffix pattern can be created the suffix cannot be matched to the last version part.
score = score + 1
Expand Down
62 changes: 31 additions & 31 deletions src/macaron/slsa_analyzer/ci_service/github_actions/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,37 +311,37 @@ def build_call_graph_from_node(node: GitHubWorkflowNode, repo_path: str) -> None
)
external_node.model = create_third_party_action_model(external_node)
job_node.add_callee(external_node)
else:
# Check the shell type configuration. We currently can support `bash`` and `sh`.
# By default `bash`` is used on non-Windows runners, which we support.
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrunshell
# TODO: support Powershell for Windows runners, which is the default shell in GitHub Actions.
# Right now, the script with the default shell is passed to the parser, which will fail
# if the runner is Windows and Powershell is used. But there is no easy way to avoid passing
# the script because that means we need to accurately determine the runner's OS.
if step.get("run") and ("shell" not in step or step["shell"] in {"bash", "sh"}):
try:
name = "UNKNOWN"
node_id = None
if "id" in step:
node_id = step["id"]
if "name" in step:
name = step["name"]

callee = create_bash_node(
name=name,
node_id=node_id,
node_type=BashScriptType.INLINE,
source_path=node.source_path,
ci_step_ast=step,
repo_path=repo_path,
caller=job_node,
recursion_depth=0,
)
except CallGraphError as error:
logger.debug(error)
continue
job_node.add_callee(callee)

# Check the shell type configuration. We currently can support `bash`` and `sh`.
# By default `bash`` is used on non-Windows runners, which we support.
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrunshell
# TODO: support Powershell for Windows runners, which is the default shell in GitHub Actions.
# Right now, the script with the default shell is passed to the parser, which will fail
# if the runner is Windows and Powershell is used. But there is no easy way to avoid passing
# the script because that means we need to accurately determine the runner's OS.
elif step.get("run") and ("shell" not in step or step["shell"] in {"bash", "sh"}):
try:
name = "UNKNOWN"
node_id = None
if "id" in step:
node_id = step["id"]
if "name" in step:
name = step["name"]

callee = create_bash_node(
name=name,
node_id=node_id,
node_type=BashScriptType.INLINE,
source_path=node.source_path,
ci_step_ast=step,
repo_path=repo_path,
caller=job_node,
recursion_depth=0,
)
except CallGraphError as error:
logger.debug(error)
continue
job_node.add_callee(callee)

elif is_reusable_workflow_call_job(job):
workflow_call_job_with_id = Identified[ReusableWorkflowCallJob](job_name, job)
Expand Down
13 changes: 6 additions & 7 deletions tests/integration/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,12 @@ def run_command(self, cwd: str, macaron_cmd: str) -> int:
" ".join(args),
)
return 1
else:
if res.returncode != 0:
logger.error(
"Command '%s' unexpectedly exited with non-zero code.",
" ".join(args),
)
return 1
elif res.returncode != 0:
logger.error(
"Command '%s' unexpectedly exited with non-zero code.",
" ".join(args),
)
return 1

time_taken = (end_time - start_time) / 1e9
logger.info(
Expand Down
Loading