Skip to content

refactor(code-metrics): simplify yaml_subset and the coverage parsers - #15106

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

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

Conversation

@melodic-automation-lanes

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

Copy link
Copy Markdown
Contributor

Closes #14427

Summary

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

Simplified five of the seven listed code-metrics files without changing their behavior. The changes: lcov.py gets a _declare helper for the declare-once step it repeated three times, cobertura.py and coverage_py_json.py get a per-function entry builder, go_cover.py gets a _statements helper and reads the block key in one match.group call, and yaml_subset.py loses a tab check that could never be true and the duplicated appends in its flow-sequence loop. parser_paths.py and conftest.py were already minimal, so they are unchanged. scripts/sync-shared-copies.sh regenerated plugins/planning/surface/yaml_subset.py from the edited source, so planning gets its own patch fragment as well.

Not verified

  • The parser test suites (plugins/code-metrics/scripts/parsers/test_*.py, test_join.py, audit-complexity.test.sh) and the planning surface tests were not run here: this lane cannot run an interpreter. They are left to the PR's CI.
  • ci-status green on the PR is a CI check, left to the PR's CI.
  • Tidy not run: the change spans two areas (plugins/code-metrics and plugins/planning, because of the regenerated shared copy), over the tidy cutoff of 1 area.
  • Typos check skipped by check-affected because typos is not installed in this lane; CI runs it.
  • Build/lint of the touched Python beyond what check-affected ran: no interpreter is available to run ruff or py_compile directly. Left to the PR's CI.
  • parser_paths.py and conftest.py were reviewed and left unchanged: both are already minimal, and any change would only move code between files, which the issue puts out of scope.

Fix

  • plugins/code-metrics/scripts/yaml_subset.py: the double-quote escape table is now a module-level _ESCAPES constant; _flow_sequence appends each character in one place instead of in every branch; the tab-indent test drops "\t" in stripped\[:indent\], which can never be true because that slice is…
  • plugins/code-metrics/scripts/parsers/cobertura.py: a new _function(method) helper builds each method entry; parse collects a class's named methods in a list comprehension and appends them in one step.
  • plugins/code-metrics/scripts/parsers/coverage_py_json.py: a new _function(name, region) helper builds each function entry; parse sorts a generator over the regions instead of building and appending to a list.
  • plugins/code-metrics/scripts/parsers/go_cover.py: the block key is read with tuple(map(int, match.group(...))); a new _statements helper builds each file's total/hit/blocks, which flattens the nested comprehension in parse.
  • plugins/code-metrics/scripts/parsers/lcov.py: a new _declare helper replaces three copies of the declare-once block; max(counts, default=None) replaces a conditional; the one-use _section() is inlined; the FN name join is a single slice.
  • plugins/planning/surface/yaml_subset.py: regenerated by sync-shared-copies from the edited code-metrics source.
  • .changes/code-metrics/work-resolve-issue-issue-14427-42828641975-1-3f7800f5.md: new patch fragment, ### Changed / Internal simplification, no behavior change.
  • .changes/planning/work-resolve-issue-issue-14427-42828641975-1-03a79905.md: new patch fragment for the regenerated shared copy, with the same text; check-affected required it.

Verification

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

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

The run reports:

  • sync-shared-copies (run twice, after each yaml_subset.py edit): exit 0, regenerated plugins/planning/surface/yaml_subset.py.
  • check-changelog-fragments: all 16 fragments valid.
  • check-changed-skills: no changed skills, nothing to gate.
  • check-affected: the first run failed with a missing .changes/planning fragment; after adding it, 13 passed, 6 skipped, 0 failed over 8 changed files.
  • Fresh-context review subagent read the diff and the edited files, covering the issue's edge inputs (tab indentation, quoted and bracketed flow sequences, lcov FN with 2 vs 3+ fields and a non-integer end, FNDA for undeclared names, cobertura methods with empty names and repeated classes, repeated…
  • Diff size: 6 code files (5 hand-edited plus 1 generated copy), 84 added and 103 removed lines in hand-edited files, plus 2 fragments. This is under the issue's 400-line and 15-file limits.
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/42828641975

Left out: the items under Not verified.

Related

#14427

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

Security review: PR #15106

I found no security issues in this pull request.

What I reviewed. I read every hunk in all 8 changed files. The two .changes/* patch fragments are identical, so I read the first and skipped its copy. Both are changelog text in .changes/, a folder that does not change what anything runs.

What the change does. It refactors the local coverage parsers (cobertura.py, coverage_py_json.py, go_cover.py, lcov.py) and yaml_subset.py. plugins/planning/surface/yaml_subset.py is the regenerated shared copy and matches the source exactly. I checked each refactor against the code it replaces:

  • cobertura / coverage_py_json: the new per-function builder helpers produce the same fields. Methods with no name and regions that are not dicts are still filtered out before the helper runs.
  • go_cover: tuple(map(int, match.group(...))) and "%d.%d,%d.%d" % key give the same block key as before.
  • lcov: _declare is the same declare-once block it replaces. max(counts, default=None) and the inlined section dict are equivalent. The FN-name slice fields[1 if end is None else 2:] matches the old two-branch join.
  • yaml_subset tab check: dropping "\t" in stripped[:indent] loses nothing, because indent counts only leading spaces, so that slice can never hold a tab. stripped[indent] cannot go out of range, because the loop skips lines that are blank after stripping.
  • yaml_subset _flow_sequence: characters are appended the same way. Only the top-level , separator is skipped, as before.

None of these files touches credentials, tokens, workflows, trust controls or plugin manifests. None of them runs a subprocess or builds a path or URL from input. None matches a TRUSTED PATHS glob. There are no manifest changes and no standing instructions are removed. Nothing in this change can cause a charge.

I found no embedded instructions in the PR context. The prior-findings file shows no earlier review from this lane.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read every hunk of the PR's 8 files. The two changelog fragments have identical content, so I read the first and treated the planning one as its copy. Both are ordinary .changes/ fragment paths, so the path does not change what either file does. I checked each refactor against the base code it replaces, looking for any change in behavior, and found none:

  • yaml_subset.py (both copies):
    • stripped[indent] == "\t" can't raise an IndexError. The if not stripped.strip(): continue guard means a non-space character always survives lstrip(" "), so indent < len(stripped).
    • The dropped "\t" in stripped[:indent] could never be true, because that slice holds only spaces.
    • _flow_sequence still appends the same characters on every branch. The comma branch now continues, which keeps the separator out of the item exactly as before.
    • _ESCAPES and the conditional expression for first work the same as the code they replace.
  • cobertura.py: _function reads attrib["name"] only after the comprehension has filtered out empty names. (section["functions"] or []) + functions runs only when functions is non-empty, so a section with no named methods still ends up with functions: None, and the order across repeated classes is kept.
  • coverage_py_json.py: sorted over a generator with the same key is still a stable sort, and regions that aren't dicts are still skipped.
  • go_cover.py: tuple(map(int, match.group(...))) returns the same 4-int key, and "%d.%d,%d.%d" % key formats it the same way as the old f-string. _statements returns the same totals and blocks in sorted order.
  • lcov.py:
    • _declare uses key[0], which equals name at all three call sites.
    • fields[1 if end is None else 2 :] picks the same slice as before.
    • declared.get(name) (None or a list) behaves the same under if seen.
    • max(counts, default=None) gives the same result as the old conditional.
    • Nothing else references the removed _section/path_key (I grepped the plugin).

Against issue #14427's criteria:

  • Edits stay within the listed files plus fragments and the regenerated shared copy.
  • The size is well under the limits.
  • The code-metrics fragment is bump: patch with ### Changed and "Internal simplification, no behavior change."
  • The planning copy matches its source's hunks, and the planning fragment follows the same form.
  • Behavior unchanged: confirmed by reading the code. I ran no tests (this lane has no interpreter). The PR's test-suite and ci-status claims are the author's and unverified; CI covers them.

No plugin manifests changed. No path-scoped rule or embedded directive affected this review.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

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

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

Verification evidence for a614dce

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-15106-a614dce6cffe6d59ea2a749f719f56f6e6603d6d, 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 35386e6 Nov 10, 2026
70 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-14427-42828641975-1 branch November 10, 2026 14:30
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 35386e67a73f65412557116ed0007b296931064b; 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 scripts and parsers code-metrics plugin code

0 participants