werkcrappit's own hotspots: tests, smaller methods, a ratchet at 20 (0.16.2) #31

Merged
mi merged 1 commits from mihoe/own-hotspots into main 2026-10-03 17:24:00 +02:00
Owner

Related Links

  • PR#30, the nightly build that measured werkcrappit itself

The Problem

The first nightly report of werkcrappit on itself showed 13 of 45 classes red, from 21 methods at a Mutation-CRAP of 9 or more.
Two kinds: methods whose mutants the tests did not notice, and methods too complex to be green even with every mutant killed, since Mutation-CRAP is never below the complexity.

Non-Goals

  • Every red method: RealLines.count, Gate.judge, CodeChartaExport.export and JsonReader.string are well tested but complex; splitting them is left for later.
  • New behaviour: only tests, smaller methods and one bug fix.

The Solution

  • Tests for the surviving mutants of Levelization.breakCycles (now package-private, so its rule is testable without a whole city), RealLines.endOfLiteral, Json.compact, the class files of the report's provenance, GateResult.describe and ClassReferences (class header, array, method descriptor, annotation and method-handle constants).
  • The Json.compact test found a bug: a null value threw a NullPointerException; the code city's checksum never had one so far.
  • MethodEvaluator.evaluate (complexity 16) is split into tally and state; CodeCity.metrics (complexity 11) reads each metric with an accessor of its definition instead of a switch.
  • A ratchet: werkcrappit { maxMutationCrap = 20 } for werkcrappit-pit, the highest value after these changes, 19.59, rounded up; the nightly mutationCrapCheck fails above it.
    codeCharta { colorRedFrom = 9 } keeps the next candidates red, which 90 % of 20 would not.
  • Version 0.16.2.

Follow-up PRs

  • Split the four complex but well tested methods above, then lower the limit.

Attachments

Local PIT runs of werkcrappit-pit

Nightly 2026-10-03 After this PR
Highest Mutation-CRAP 22.9 19.6
Methods at 9 or more 21 10
Red classes (from 9) 13 of 45 8 of 45
Mutants killed 82 % 88 %

🤖 Generated with Claude Code

## Related Links - [PR#30](2026-10-03-PR%2330-nightly-mutation-testing.md), the nightly build that measured werkcrappit itself ## The Problem The first nightly report of werkcrappit on itself showed 13 of 45 classes red, from 21 methods at a Mutation-CRAP of 9 or more. Two kinds: methods whose mutants the tests did not notice, and methods too complex to be green even with every mutant killed, since Mutation-CRAP is never below the complexity. ## Non-Goals - Every red method: `RealLines.count`, `Gate.judge`, `CodeChartaExport.export` and `JsonReader.string` are well tested but complex; splitting them is left for later. - New behaviour: only tests, smaller methods and one bug fix. ## The Solution - Tests for the surviving mutants of `Levelization.breakCycles` (now package-private, so its rule is testable without a whole city), `RealLines.endOfLiteral`, `Json.compact`, the class files of the report's provenance, `GateResult.describe` and `ClassReferences` (class header, array, method descriptor, annotation and method-handle constants). - The `Json.compact` test found a bug: a `null` value threw a `NullPointerException`; the code city's checksum never had one so far. - `MethodEvaluator.evaluate` (complexity 16) is split into `tally` and `state`; `CodeCity.metrics` (complexity 11) reads each metric with an accessor of its definition instead of a `switch`. - A ratchet: `werkcrappit { maxMutationCrap = 20 }` for `werkcrappit-pit`, the highest value after these changes, 19.59, rounded up; the nightly `mutationCrapCheck` fails above it. `codeCharta { colorRedFrom = 9 }` keeps the next candidates red, which 90 % of 20 would not. - Version 0.16.2. ## Follow-up PRs - Split the four complex but well tested methods above, then lower the limit. ## Attachments ### Local PIT runs of werkcrappit-pit | | Nightly 2026-10-03 | After this PR | |---|---|---| | Highest Mutation-CRAP | 22.9 | 19.6 | | Methods at 9 or more | 21 | 10 | | Red classes (from 9) | 13 of 45 | 8 of 45 | | Mutants killed | 82 % | 88 % | 🤖 Generated with [Claude Code](https://claude.com/claude-code)
mi added 1 commit 2026-10-03 16:53:23 +02:00
mi merged commit bcb2b46695 into main 2026-10-03 17:24:00 +02:00
mi deleted branch mihoe/own-hotspots 2026-10-03 17:24:00 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mi/werkcrappit#31