Skip to content

refactor(code-metrics): simplify audit-duplication, audit-suppressions and setup scripts - #15109

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14429-42831466496-1
Nov 10, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-14429-42831466496-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #14429

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Ran /simplify's four checks (reuse, simplification, efficiency, level of abstraction) over the nine listed code-metrics scripts and kept only edits that leave behavior the same. audit-duplication.sh's trend block now uses one is_natural predicate for its two inline integer-range checks and computes the previous copy count once instead of three times. registry-filter.py's sanctions_plain checks every suffix first, then whether the prefixes are distinct. audit-suppressions.sh's findings block replaces a function that ignored its argument with a constant. setup-apply.py's per-lane collectors-key test, written out twice, is now one helper. The other five files (cluster-clones.py, audit-complexity.sh, audit-size.sh, audit-type-debt.sh, setup-check.sh) were reviewed and left unchanged. Their remaining duplication is across files, which the issue leaves to the restructuring pass. A tried value-check helper for the shell option parsers made those files longer, so it was reverted. A rewrite of sanctions_cluster was reverted after review found it could raise on an invalid glob member where the old loop returned False first.

Not verified

  • The plugin's Python unit tests (test_registry_filter.py, test_cluster_clones.py, test_setup_apply.py) and the shell scripts were not executed: this lane allows no interpreter. Left to the PR's CI.
  • The ai-slop deterministic detector (detect.sh) could not run in this lane, so pass 5 of the tidy step was a rubric read only. The fragment's one body line is text the issue sets.
  • cant-fail-scan was not run with a base ref (the wrapper does not take one here); check-affected lists it as CI only.
  • ci-status green on the PR is left to the PR's CI.

Fix

  • plugins/code-metrics/skills/audit-duplication/scripts/audit-duplication.sh: the embedded trend Python gets an is_natural predicate shared by natural() and the lines check, and takes max(..., default=0) once in place of a matched list read with max() twice
  • plugins/code-metrics/skills/audit-duplication/scripts/registry-filter.py: sanctions_plain checks that every path is the entry or ends with /entry, then that the prefixes are distinct, in place of a loop with three exits
  • plugins/code-metrics/skills/audit-suppressions/scripts/audit-suppressions.sh: the findings block's action_no_rule_id(r), which ignored r, becomes the constant ACTION_NO_RULE_ID
  • plugins/code-metrics/skills/setup/scripts/setup-apply.py: new _in_collectors helper used by drop_unknown and by main's unknown-key warning, which each wrote out the per-lane collectors-key test
  • .changes/code-metrics/work-resolve-issue-issue-14429-42831466496-1-f8755853.md: new patch fragment, ### Changed, 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against 7ff1f00:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • check-changelog-fragments: all 20 fragments valid (run after the final edit)
  • check-changed-skills: 3 skills checked, 0 failed; the warnings are only the existing description and body lengths (run after the final edit)
  • check-affected: 14 passed, 5 skipped (typos not installed; 4 checks that run code from the checked tree), over 5 changed files (run after the final edit)
  • fresh-context review subagent on the whole diff: found one behavior difference (sanctions_cluster could raise re.error from pathglob on an invalid [..] member where the old loop returned False on a repeated directory first). Fixed by restoring the original loop. It confirmed every other hunk…
  • tidy (code-tidying:tidy-diff over the 14 changed hunks): passes 1-3 found nothing more to edit, and the one added comment states an invariant so it stays; pass 4 (write-for-humans) and pass 5 (ai-slop rubric read) found nothing to change in the fragment
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42831466496

Left out: the items under Not verified.

Related

#14429

Merge-Risk: max=MEDIUM demote=false head=7ff1f00c0f303320be781b9b671dc241c38a1b04 rubric=8.3.5 rater=claude-opus-5-5 checker=claude-opus-5-5

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 7ff1f00c0f303320be781b9b671dc241c38a1b04: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15109 (head 7ff1f00)

I found no security issues.

I read every hunk of all 5 changed files. None of them matches a trusted path, and the PR touches no workflow, action, plugin manifest, trust control, merge hold or standing instruction.

  • .changes/code-metrics/…f8755853.md: a new changelog fragment. It is prose only.
  • audit-duplication.sh (embedded trend Python):
    • The new is_natural predicate does the same check as the old inline integer-range tests, including rejecting bool.
    • max(..., default=0) is safe here because every class has at least one copy, so 0 can only mean nothing was seen before. That keeps the new/grown classification the same.
  • registry-filter.py sanctions_plain: same result as the old loop. A path that is neither the entry nor ends in /entry still returns False, and repeated prefixes still return False. path[:-len(suffix)] cuts the same characters as path[:-(len(entry)+1)]. The registry sanction logic accepts nothing new.
  • audit-suppressions.sh: a function that ignored its argument is now a constant string. Same output.
  • setup-apply.py _in_collectors: drop_unknown behaves the same. main's unknown-key warning now also matches key == <x>.collectors, but those keys are already in known, so the result is the same. It only controls a stderr warning in either case.

No injection, path, token or secret handling changes, and nothing new is trusted.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 7ff1f00c0f303320be781b9b671dc241c38a1b04: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

I read every hunk of all 5 changed files and checked each edit against #14429's main criterion: behavior stays the same.

  • audit-duplication.sh is_natural / natural: Old natural() rejected on bool or not int or out of range. The new code rejects on not (int and not bool and in range). That is the same check, and short-circuiting still keeps the range comparison away from non-ints. The inline lines check is identical.
  • audit-duplication.sh previous_copies: max(..., default=0) matches the old empty-matched branch only if no copies_before value can be 0. That holds: classes() rejects an empty instances list (L253-L254), so copies = len(keys) >= 1. The new comment states this correctly.
  • registry-filter.py sanctions_plain: The results are the same for all inputs, including an empty entry, a path equal to entry, and an empty paths list. Neither version can raise, so the old early False on a repeated prefix makes no observable difference.
  • audit-suppressions.sh ACTION_NO_RULE_ID: The function ignored its argument, and the constant's string is the same. Its only caller was updated, and nothing else in the plugin uses the old name.
  • setup-apply.py _in_collectors: drop_unknown behaves the same. In main, the added dotted == k term cannot match, because key not in known is checked first.
  • Fragment: It has bump: patch, ### Changed, and the exact body line the issue requires.

Closing issue #14429 criteria:

  • Behavior unchanged: met, by the reading above. Tests that could catch a regression already exist: test_registry_filter.py, test_setup_apply.py and audit-duplication.test.sh.
  • Only listed files plus fragments: met.
  • Size limits: met, with about 40 changed lines in 4 hand-edited files.
  • Fragment: met.
  • ci-status green: I can't check this from this lane.

Not verified by me: The PR author says the unit tests, the shell scripts and detect.sh were not run. Their check results are also author-claimed and unconfirmed. I ran nothing either; this review is a reading of the code only.

No path-scoped rule in .claude/rules/ adds criteria these script changes break. No plugin manifest changed. Nothing in the PR context asks the lane to approve the PR or skip a check.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 7ff1f00c0f303320be781b9b671dc241c38a1b04, the head its arming checks judged.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for 7ff1f00

The verifier passed this head. The capture artifact holds the capture summary, which says whether the capture ran, and any screenshot or video that passed the mask check; this comment uploads no file.

Capture artifact: pr-capture-15109-7ff1f00c0f303320be781b9b671dc241c38a1b04, expires on 2026-12-10.

One comment per pull request, updated in place for each new head.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 57c7cd8 Nov 10, 2026
65 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14429-42831466496-1 branch November 10, 2026 15:28
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 57c7cd867a67f35f8e4bf0f80ac76b81fab88c7d; later checks count it verified from this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify the audit-duplication, audit-suppressions, audit and 1 more code-metrics plugin code

0 participants