From 3ab905939c3081dfe86a754f5d3c93f5c6990e2a Mon Sep 17 00:00:00 2001 From: Ole Herman Schumacher Elgesem <4048546+olehermanse@users.noreply.github.com> Date: Tue, 12 May 2026 14:26:41 +0200 Subject: [PATCH] Fixes for issues pointed out by GitHub Code Quality The fixes were generated by Copilot Autofix, but since it does not support combining multiple into 1 commit / PR I had to do this part manually. Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Ole Herman Schumacher Elgesem --- src/cfengine_cli/format.py | 2 -- src/cfengine_cli/lint.py | 4 ++-- src/cfengine_cli/masterfiles/analyze.py | 4 ++-- src/cfengine_cli/masterfiles/check_download_matches_git.py | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/cfengine_cli/format.py b/src/cfengine_cli/format.py index 0979f82..2c1bc13 100644 --- a/src/cfengine_cli/format.py +++ b/src/cfengine_cli/format.py @@ -811,8 +811,6 @@ def _autoformat( if prev_sib and prev_sib.type in BLOCK_TYPES and not fmt.empty: fmt.blank_line() fmt.macro_indent = indent - elif text(node).startswith("@else"): - indent = fmt.macro_indent fmt.print(node, 0) return diff --git a/src/cfengine_cli/lint.py b/src/cfengine_cli/lint.py index 048bf21..d6acb3a 100644 --- a/src/cfengine_cli/lint.py +++ b/src/cfengine_cli/lint.py @@ -1268,8 +1268,8 @@ def _lint_json_plain(filename: str) -> int: data = f.read() r = 0 try: - data = json.loads(data) - except: + json.loads(data) + except json.JSONDecodeError: r = 1 print(_pass_fail_filename(filename, r)) diff --git a/src/cfengine_cli/masterfiles/analyze.py b/src/cfengine_cli/masterfiles/analyze.py index 1846697..2b1fb67 100644 --- a/src/cfengine_cli/masterfiles/analyze.py +++ b/src/cfengine_cli/masterfiles/analyze.py @@ -52,7 +52,7 @@ def finalize_vcf(versions_dict, checksums_dict, files_dict): # sort each version list, descending working_dict[c][f] = sorted( working_dict[c][f], - key=lambda v: version_as_comparable_list(v), + key=version_as_comparable_list, reverse=True, ) # sort filepaths, alphabetically @@ -68,7 +68,7 @@ def finalize_vcf(versions_dict, checksums_dict, files_dict): # sort each version list, descending working_dict[f][c] = sorted( working_dict[f][c], - key=lambda v: version_as_comparable_list(v), + key=version_as_comparable_list, reverse=True, ) # sort checksums diff --git a/src/cfengine_cli/masterfiles/check_download_matches_git.py b/src/cfengine_cli/masterfiles/check_download_matches_git.py index 0e54e7d..7069d2f 100644 --- a/src/cfengine_cli/masterfiles/check_download_matches_git.py +++ b/src/cfengine_cli/masterfiles/check_download_matches_git.py @@ -68,7 +68,7 @@ def check_download_matches_git(versions): extraneous_count += len(only_dl) differing_count += len(value_diff) - nonmatching_versions.sort(key=lambda v: version_as_comparable_list(v), reverse=True) + nonmatching_versions.sort(key=version_as_comparable_list, reverse=True) # fully sort differences.json: working_dict = diffs_dict["differences"]