64 lines
3.2 KiB
Markdown
64 lines
3.2 KiB
Markdown
# 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.
|
|
|
|
## Related Links
|
|
|
|
- [werkregie PR#64](https://git.javagil.de/mi/werkregie/pulls/64), the Mutation-CRAP gate of each build.
|
|
- [werkregie PR#74](https://git.javagil.de/mi/werkregie/pulls/74), still open, which changes these four classes and builds on this PR.
|
|
|
|
## 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.
|