Skip to content

CodeWitness 1.0.26

Latest

Choose a tag to compare

@github-actions github-actions released this 09 Nov 15:04

CodeWitness 1.0.26 removes three pieces of dead code the compiler cannot see and splits the report's densest
method. It exists because a second static analyser — GooseBuckle — was pointed at this repository, and the most
useful result of that exercise was discovering that most of what it reported was wrong: after checking every
finding against the source, 3 of its 144 were genuine defects, 12 were the tool's own false positives (filed in
its journal as GB-86EB2C52, GB-281F773D, GB-4C945B5D and GB-17B09680), and the remainder were design
choices or complexity measures on code that is deliberately long. What landed is what survived that check.

What changed

  • Three dead assignments are gone. PythonDependencyAnalyzer.analyseDependencies built a ProjectInfo it
    never read — the method works from context.projectRoot() — and VerificationEngine.recordDatabase assigned
    each of its two DATABASE_FIXTURE evidence records to a local evidence that neither branch ever read. The
    ledger.add(...) calls stay, because the record is the point and the local never was. This is the shape
    GB-QLT-UNU-001 exists to catch, and it caught one of the two in the engine and missed the other.

  • HtmlReportWriter.appendEnvironment is four methods instead of one. It was 79 lines at cognitive
    complexity 59 and cyclomatic complexity 35 — the highest complexity density in the tree, ahead of
    VerificationEngine.verify's 73 over 388 lines. It is now appendEnvironment (12 lines: resolve the snapshot
    and the run, open the section, make three calls) over appendSnapshot (the toolchain keys and the two
    timestamps, with the run's own clock as the fallback), appendPhases (the phase table, including the phases
    that were skipped) and appendBudget (the limits, the usage, and the warning when a limit truncated the run).
    The two if/else pairs became early returns, so every literal and the emission order are unchanged, and each
    new helper takes two or three parameters — under the threshold of the rule that would otherwise have flagged
    the extraction itself.

  • Measured effect. GooseBuckle 0.2.5 over this tree reports 140 findings where it reported 144: the three
    dead locals and both appendEnvironment complexity findings are gone, and no finding was added. The
    duplication count is unchanged at 69, which is the intended outcome — nothing was rearranged to move a number.

What this does not fix

  • The four long verify methods are untouched. VerificationEngine.verify is 388 lines at cognitive 73 and
    cyclomatic 53; GeneratedTestsStrategy.verify is 201, ExistingTestsStrategy.verify 185 and
    StaticAnalysisStrategy.verify 154. All four are guard-clause sequences, and the obvious extraction trades a
    long-function finding for a seven-parameter helper — the same smell wearing a hat. Decomposing the engine's
    phase method is a change of its own, and it is not a drive-by in a release that is otherwise subtractive.

  • The two files over the project's own 2000-line threshold stay over it: VerificationEngine.java at 2340
    and SqliteVerificationStore.java at 2186. The repository's notes record the engine as decomposed from 1,829
    lines, so this is a documented drift rather than a new one, and it deserves its own slice.

  • 69 cross-adapter duplication findings remain. They are real — CppSourceScan against CSharpSourceScan,
    CppXml against CSharpXml, the mutation testers and the test contexts — but they are a design decision
    across 16 sibling adapters, and the repair is to lift the shared shapes into codewitness-adapter-support,
    not 69 individual edits.

  • 11 GB-QLT-UNU-001 findings remain and are wrong. Each names a local that is used later in the method that
    declares it. They disappear when GooseBuckle fixes GB-86EB2C52; they are not worked around here.

Verified for this release

  • Full reactor suite: 1,785 tests, 0 failures, 0 errors, 0 skipped — the same count as 1.0.25, because both
    changes are behaviour-preserving and neither needed a new test to describe a behaviour that nothing changed.
  • The dead-code guard was proved to fire. Deleting the ledger.add(...) call for the unprepared-database
    record — the call whose local was removed — failed VerificationEngineTest.anUnpreparedDatabaseIsReported at
    line 222 with "…EV-005 [DEPENDENCY_SCAN/INCONCLUSIVE…] ==> expected: but was: ", i.e. the run
    carried no DATABASE_FIXTURE record. The call was restored and the suite is green.
  • The refactor's invariant is asserted, not assumed. HtmlReportWriterTest requires the report's section
    ids, environment among them, and the HTML assertions run over the extracted methods; the emission order and
    every literal were carried across by hand and are byte-identical in source.
  • Self-check against the built jar (./codewitness verify . --requirements selfcheck/requirements.yaml --config selfcheck/codewitness.yaml --no-mutation --max-duration 30m): all seven ground rules VERIFIED,
    1,785 tests executed and passed, 0 findings — five suppressed with their reasons — coverage 71.3% line
    (25,791/36,155) and 59.6% branch, 30 resolved dependencies with 0 advisories from OSV, exit 0 in 1 m 56 s.
    Run CW-2026-11-09-JYY36. selfcheck/README.md quotes this run.
  • ./codewitness version prints codewitness 1.0.26.

Process note

The refactor was aimed at the wrong function first, and a measurement was the reason. GooseBuckle reported
ConfigLoader.parse as spanning 473 lines, which made it the single largest function in the tree and the obvious
place to start. Brace-matching that finding against the source showed the method closes at line 253 and is 129
lines — under the rule's own 150-line threshold — and that 11 of the 15 long-function findings on this tree name
an end line past the function, sometimes the end of the file. Only four were real, and the work moved to
appendEnvironment, which the same tool measures correctly and which has the worst complexity density of
anything it found.

The lesson is the one this project already applies to its own evidence, pointed at somebody else's: "the project's
own tests pass"
is not proof, and neither is another tool's line count. A finding is evidence only after the
thing it describes has been looked at. Checking first cost one brace-matcher; refactoring first would have
rewritten a 129-line method that needed nothing, and the release note would have claimed it was 473 lines long.

Compatibility

  • No CLI command, flag, exit code, report key, SARIF profile, codewitness.yaml key or adapter-SPI change. Every
    change is inside a method body, a private helper or a declaration that nothing read.
  • No public API change: HtmlReportWriter's new methods are private, ConfigLoader is untouched, and both
    edited classes keep their signatures and their behaviour.
  • The rendered report.html is unchanged, section for section and byte for byte — the split moved code, not text.