Files
werkregie/doc/prs/2026-10-14-PR#75-crap-sources.md
claude-code 7769fdd294
werkator build succeeded after 00:58
werkator/deploy build succeeded after 00:23
Dashboard, RelayClient, ClaudeCodeSource and GiteaSource at a Mutation-CRAP of at most 15 (#75)
Co-authored-by: claude-code <claude-code@javagil.de>
2026-10-14 17:51:17 +02:00

3.2 KiB

PR#75: Dashboard, RelayClient, ClaudeCodeSource and GiteaSource at a Mutation-CRAP of at Most 15

WARNING: This document describes only the change applied in this PR. It may already be outdated once the next PR is merged. Historic PR documentation is not maintained along with new PRs; treat it as a snapshot.

Problem

Since werkregie PR#64, a branch fails on each method above a Mutation-CRAP of 15 in a class it changes. The open werkregie PR#74 changes Dashboard, RelayClient, ClaudeCodeSource and GiteaSource; 16 of their methods are above 15, GiteaSource.pullRequestItem at 1806 on main: a complexity of 42 without a killed mutant, 42² + 42; PR#74 adds a branch to it, which makes 44² + 44 = 1980.

Non-Goals

  • No change of behaviour.
  • No other class; Main is the matter of werkregie PR#67.

Solution

The methods keep their behaviour; tests and a split bring each of them to at most 15. A method of a cyclomatic complexity above 15 cannot reach 15 by tests alone, so these were split:

  • GiteaSource.pullRequestItem (complexity 42): pullRequest builds the PullRequest from statusesOf, reviewsOf, isDraft, automerge and conflictSince.
  • GiteaSource.flags (63): werkrevisor's state in the inner class Review; stuckFlags, reworkFlags, mergeFlag and ownReviewFlags in the order of the flags before.
  • GiteaSource.activityItem (19) and pushItem (16): subjectOf, activityUrl and commitsOf.
  • ClaudeCodeSource.desktopItem (27): stateOf, desktopUrl, phoneUrl, and the item built apart from the filter.
  • ClaudeCodeSource.Asks.of (18): flag, reason, waitsForUser and ask; of returned emptyList() early, and PIT's mutant that returns an empty list instead changes nothing there; now of wraps the Flag? of flag, whose early returns are null.
  • ClaudeCodeSource.readLive: isAlive and liveOf.

New tests:

  • GiteaSourceFetchTest runs GiteaSource.fetch against a fake Gitea: pull requests with statuses, reviews, the timeline and the time of a conflict, the activity feed, the token sources.
  • ClaudeCodeSourceTest: two processes of one session, process files without a pid or broken, Desktop sessions without a title or archived while running, Jev at a threshold of 0.
  • DashboardTest: a source without a ttl, a failing source, a refresh in the background.
  • RelayClientTest: the token sources, a missing server address, an invalid name, another HTTP status.

ClaudeCodeSource no longer resets the time of Jev's last failure after a success: a new request comes only after that time plus a minute, so the reset changed nothing.

The ratchet of the nightly run falls from 1806 to 812, now MatrixSource.message; the change of dashboard/build.gradle.kts makes the check stricter, not weaker.

Version 0.45.1.

Open Questions

None.

Follow-up PRs

  • werkregie PR#74, the author session of a stuck pull request, rebased onto this PR.