Skip to content

refactor(code-metrics): share the PATH-tool probe across collectors - #15619

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-15593-43261285169-1
Nov 12, 2026
Merged

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

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #15593

Summary

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

Moved the PATH-tool probe that lizard, radon, scc and shellmetrics each repeated into adapter_paths.path_probe(name), next to version_output. Each collector keeps a one-line probe() that calls path_probe(NAME), so dispatch(probe=probe) and every main() stay as they were. I chose the one-line def over a lambda at the dispatch call because it keeps the probe symbol and the dispatch lines unchanged. The output, the 'NAME not on PATH' message and the exit codes are the same as before.

Not verified

  • scripts/run-ruff.sh check on the changed files: this lane can run only its named wrappers, so ruff could not run here. Left to the PR's CI. The review subagent read the import order and found no unused imports
  • test_lizard.py, test_radon.py, test_scc.py, test_shellmetrics.py and test_adapter_paths.py: this lane cannot run a test runner. Left to the PR's CI
  • ci-status green: a PR CI check, left to the PR's CI
  • tidy: the code passes (simplify, comments, residue) found nothing to edit. The markdown passes (write-for-humans, ai-slop fix) were skipped because the fragment's one line is the exact text the issue asks for. Proposal not applied: replace each one-line probe() with probe=lambda: path_probe(NAME)…
  • The change is left uncommitted, as the runner's instructions say, so the runner makes the patch. That overrides the skill's commit step
  • Untracked dotfiles (.bashrc, .bash_profile, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) are in the working tree but were not made by this run and are not part of the change

Fix

  • plugins/code-metrics/scripts/collectors/adapter_paths.py: added path_probe(name) -> int after version_output, and imported shutil
  • plugins/code-metrics/scripts/collectors/lizard.py: probe() now returns path_probe(NAME); imports path_probe instead of version_or_unknown and version_output
  • plugins/code-metrics/scripts/collectors/radon.py: probe() now returns path_probe(NAME); imports path_probe instead of version_or_unknown and version_output
  • plugins/code-metrics/scripts/collectors/scc.py: probe() now returns path_probe(NAME); imports path_probe instead of version_or_unknown and version_output
  • plugins/code-metrics/scripts/collectors/shellmetrics.py: probe() now returns path_probe(NAME); imports path_probe instead of version_or_unknown and version_output
  • .changes/code-metrics/work-resolve-issue-issue-15593-43261285169-1-a4178e00.md: new patch fragment, '### Changed' with 'Internal restructuring, no behavior change.'

Verification

The runner ran each check from the base copy against 27220de:

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

The run reports:

  • check-changelog-fragments: all 2 fragments under .changes/ valid (ran before and after tidy)
  • check-changed-skills: no changed skills, nothing to gate (ran before and after tidy)
  • check-affected: 13 passed, 6 skipped (shellcheck: no changed shell; typos: not installed; three validate-plugins sub-checks that run code from the checked tree; changed-skills: no skill file), over 6 changed files
  • Grep: shutil.which and sys.* are still used in each of the four collectors (in collect and the error prints), so neither import is now unused
  • Grep: no file in the repository cites line numbers in the five changed .py files, so no line citation went stale
  • Grep: the collector tests run probe as a subprocess against PATH stubs and check only stdout and the exit code; none imports or patches the removed names
  • Fresh-context review subagent: no findings. It confirmed path_probe matches the old body line for line, imports are complete and in order, and nothing else imports the removed names from these modules
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/43261285169

Left out: the items under Not verified.

Related

#15593

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

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 27220de655171a65e5e967736d5f0163cda117bc: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15619, no security issues found

I read every hunk of all 6 changed files, so this is a full review.

This PR is a refactor. The PATH-tool probe() body was repeated in the lizard, radon, scc and shellmetrics collectors. It now lives in one place, adapter_paths.path_probe(name) (adapter_paths.py#L151). The new function matches the removed bodies line for line:

  • It finds the tool with shutil.which(name).
  • It runs it through the existing version_output(exe, name) (L137).
  • It prints the result through version_or_unknown (L132), which is in the same module.

Each collector still passes its own NAME constant, so nothing attacker-controlled reaches the lookup. The change adds no new subprocess call, shell string, path or input. The changelog fragment is plain prose.

  • No changed file matches a trusted-path glob.
  • No trust control, merge hold, token scope, kill switch or plugin manifest is touched.
  • No standing instruction is removed.
  • No embedded directives in the PR context.
  • No spend or cost impact.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings.

I read every hunk of all 6 changed files.

The PR moves the probe() body that four collectors each repeated into adapter_paths.path_probe(name). I compared the new function at adapter_paths.py#L151-L161 with each removed body in lizard.py, radon.py, scc.py and shellmetrics.py, line by line. Only NAME became name. The "not on PATH" message, the stderr target, the exit codes and the stdout version line are all the same.

What I checked against closing issue #15593:

  • The probe exists once and all four collectors use it: met. Each collector's probe() now returns path_probe(NAME), so the dispatch(probe=probe) calls are unchanged.
  • Behavior is unchanged: met as far as I can see by reading the code. The probe tests in test_lizard.py, test_radon.py, test_scc.py and test_shellmetrics.py already cover this. Each runs the probe verb as a subprocess and asserts on "not on PATH" and on the version output when a stub tool is on PATH, so a regression in the shared function would fail them.
  • Imports: version_or_unknown and version_output are no longer used in the four collectors, and the PR drops them. shutil and sys are still used in each collector's collect, for example lizard.py#L111, so neither import is now unused. shutil is newly imported in adapter_paths.py, in sorted order.
  • Scope and size: met. The PR edits only the listed files plus a patch fragment with the exact wording the issue asks for, and it is far under 400 lines and 15 files.
  • Ruff, the test files and ci-status: these acceptance criteria are left to CI. I did not run them (this lane has no shell), and the PR says it did not run them either.

No plugin manifest changed, so the manifest checks don't apply. The PR context contains no embedded instructions aimed at this lane.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Merge-Risk: unrated reason=no-rating

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit 224ddba Nov 12, 2026
52 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-15593-43261285169-1 branch November 12, 2026 17:40
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 224ddbabd30597af5724583c38c1da447ee1b386; 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.

Share the PATH-tool probe across the code-metrics collectors

0 participants