Skip to content

refactor(code-tidying): simplify the audit-dead-code scan scripts - #15163

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14432

Summary

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

Simplified dead-code-scan.sh and lib/dead-code-shapes.sh with no change to outputs, exit codes, flags or function names. A new lane_files helper replaces 17 repeated pairs of dc_account_lane_files and lane_line calls, taking the Lane line's files= count from the argument count, which matches the old count at every call site. list_search_files_z replaces two duplicated git-or-find pipelines. in_ts_files now looks up an associative set filled while files are classified, instead of scanning TS_FILES linearly for each knip finding. The --max cap is one awk | cut step instead of if/cp/cut. In the shapes library, dc_shape_tier's two tier-2 arms are merged and dc_locate_binary is shorter. I kept the four explicit lane-selection lines because a loop form calling "lane_$lane" hides the lane functions from shellcheck (SC2329).

Not verified

  • dead-code-scan.test.sh was not run: this lane can run only its named wrappers, so the suite is left to the PR's CI
  • tidy-diff skipped passes 4 and 5 (the markdown passes) on the changelog fragment: the issue fixes its body word for word, so a rewrite could not be applied. Passes 1 to 3 ran and made no edit; one proposal is to inline the now one-line in_ts_files, whose caller is outside the changed lines
  • cant-fail-scan was not run: it audits test files, and this change touches none
  • ci-status green on the PR is left to the PR's CI

Fix

  • plugins/code-tidying/skills/audit-dead-code/scripts/dead-code-scan.sh: added the lane_files and list_search_files_z helpers and used them in the knip, vulture, gopls and grep lanes; in_ts_files now reads the TS_IN_SCOPE associative set; the --max cap is a single awk (m <= 0 means no cap) piped…
  • plugins/code-tidying/skills/audit-dead-code/scripts/lib/dead-code-shapes.sh: merged dc_shape_tier's two tier-2 case arms into one; dc_locate_binary tries dc_resolve_local_binary first, then command -v, in fewer lines
  • .changes/code-tidying/work-resolve-issue-issue-14432-42883579691-1-33d330d6.md: patch fragment, ### Changed, 'Internal simplification, no behavior change.'

Verification

The runner ran each check from the base copy against fc5bcec:

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

The run reports:

  • check-changelog-fragments: all 3 fragments valid
  • check-changed-skills: audit-dead-code PASS, 0 errors, 2 warnings about the existing SKILL.md description and body length (this change did not touch SKILL.md)
  • check-affected: 13 passed, 6 skipped; shellcheck passes on both scripts (the first run failed with SC2329 against a lane-selection loop, which I reverted)
  • fresh-context review subagent: found one behavior difference. A --max of 2^63 or more wraps negative under $((10#...)); the old code then emitted every candidate, but the first draft's 'm == 0' would have emitted only drift rows. Fixed with 'm <= 0', and the reviewer confirmed every other change…
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42883579691

Left out: the items under Not verified.

Related

#14432

Merge-Risk: max=MEDIUM demote=false head=fc5bcec4bfd9a1953c08f6ae5c423cb75efd2b75 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 fc5bcec4bfd9a1953c08f6ae5c423cb75efd2b75: read 3 of 3 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15163, a refactor of the audit-dead-code scan scripts

No security issues found.

I read every hunk of all 3 changed files:

  • plugins/code-tidying/skills/audit-dead-code/scripts/dead-code-scan.sh
  • plugins/code-tidying/skills/audit-dead-code/scripts/lib/dead-code-shapes.sh
  • .changes/code-tidying/work-resolve-issue-issue-14432-42883579691-1-33d330d6.md

None of them matches a trusted-path glob. None is a trust control, a merge hold, a plugin manifest or an instruction surface.

What I checked:

  • Binary resolution (dc_locate_binary). The lookup order is the same as before: dc_resolve_local_binary (repo-local) first, then command -v on PATH. The rewrite forwards "$@", which is the same name start_dir repo_root arguments the old code passed one by one. Callers still read the path through $(...), so no new lookup location or execution path is added.
  • The reference search (list_search_files_z). It keeps the same NUL-separated git ls-files -z / find -print0 listing, piped into xargs -0 grep -F -f <keyfile> --. The -- and the -F fixed-string matching stay in place, so the file names reaching grep are handled no differently than before.
  • lane_files, TS_IN_SCOPE, the --max awk cap and the merged dc_shape_tier arms. These only change bookkeeping and output filtering inside the scan. There is no new shell interpolation of untrusted input, no eval, and no handling of credentials or network calls.
  • The changelog fragment. It is prose only.

PR context: no embedded text tells the lane to pass the PR, skip a check, drop a finding or post somewhere else.

This was the first review of this PR (blocking only: no), so all severities were in scope. I dispatched no subagents, because there was no candidate to check.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: PR #15163, simplifying the audit-dead-code scan scripts

No findings. I read every hunk of all 3 changed files, plus the unchanged code that the changed lines call. None of the changed files matches a trusted-path glob. This is the first review of this pull request, so it is not blocking-only.

Behavior-preservation check (closing issue #14432, "Behavior is unchanged")

  • lane_files helper. It counts files with $# where the old code used $nfiles or ${#X[@]}, and the counts match at every call site. In knip and gopls, nfiles="${#repo_owned[@]}" is set just before the guarded calls (dead-code-scan.sh#L458, #L657). The no-manifest branches keep the ${X[@]+...} guard, so an empty array still gives files=0.
  • Vulture's bare "${PY_FILES[@]}". This is safe under set -u, because the lane returns early when PY_FILES is empty (#L550).
  • TS_IN_SCOPE set. It is declared at top level and filled at the only TS_FILES+= site (L308), so it always holds the same members as TS_FILES. The in_ts_files lookup uses the same repo-relative keys as before.
  • list_search_files_z. It runs the same git-or-find selection, in the same working directory, for both grep pipelines.
  • --max cap. MAX is checked against ^[0-9]+$ and normalised with 10# (L112–117). The awk test m <= 0 reproduces the old ((MAX > 0)) split, including the case where a huge value wraps negative.
  • dc_shape_tier. The merged tier-2 arm lists the same nine shapes as before.
  • dc_locate_binary. Callers pass the same three arguments, and dc_resolve_local_binary prints only on success, with no trailing newline. Every caller captures the result with $(...), so the change from a subshell capture to a direct call does not change what they get.
  • Changelog fragment. It has bump: patch and the required ### Changed body, word for word.

Acceptance criteria

  • Only the two listed files and one fragment are edited, and the change is well under 400 lines.
  • The dead-code-scan.test.sh run and green CI are author-claimed and unverified: the PR says the suite was not run in the lane. I could not run it either, because this lane has no shell.
  • Nothing in the PR context reads as an instruction to this lane.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for fc5bcec

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-15163-fc5bcec4bfd9a1953c08f6ae5c423cb75efd2b75, 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 62e8711 Nov 10, 2026
63 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14432-42883579691-1 branch November 10, 2026 20:57
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 6, survived 1, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 86%; mutation score 86%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/code-tidying/skills/audit-dead-code/scripts/dead-code-scan.sh 5 0 0 0 0 0
plugins/code-tidying/skills/audit-dead-code/scripts/lib/dead-code-shapes.sh 1 1 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
plugins/code-tidying/skills/audit-dead-code/scripts/lib/dead-code-shapes.sh:249 SBR productive input-gap

The run's summary has the full report.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 62e8711cff8eaaf7a4806ebbd080fd854cf9f18b; 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-dead-code code-tidying plugin code

0 participants