Files
werkregie/doc/prs/2026-10-14-PR#67-main-commands.md
claude-code a44ed35a38
werkator build succeeded after 00:58
werkator/deploy build succeeded after 00:26
The commands of Main.kt at a Mutation-CRAP of at most 15 (#67)
Co-authored-by: claude-code <claude-code@javagil.de>
2026-10-14 21:54:15 +02:00

50 lines
2.4 KiB
Markdown

# PR#67: The Commands of Main.kt at a Mutation-CRAP of at Most 15
Version: patch
> **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
- [PR#64](https://git.javagil.de/mi/werkregie/pulls/64), after which a branch build fails on each method above 15 in the files it changes.
- [PR#65](https://git.javagil.de/mi/werkregie/pulls/65), which changes `Main.kt` and waits for this PR.
## Problem
`Main.kt` holds the command line of werkregie-dashboard, nearly without tests.
Since PR#64, each change of it fails the branch build: 7 of its methods are above 15, `main` at 600.
PR#65 must change it, to read the required checks of a pull request.
## Non-Goals
- No change of the commands, their options, outputs or exit codes.
- No other file above 15, e.g. `PullRequestWatch.kt`; PR#65 changes that one.
## Solution
A method without killed mutants stays at 15 only up to a complexity of 3; a well tested one up to 15.
So the decisions move into tested functions, and what reads the terminal or the network decides nothing.
- `main` looks up its command in a table and calls it; a wrong call is a `UsageError`, which `main` prints with exit code 2.
- `Invocation`, in a file of its own, reads the command line: mode, `--config`, the environment, options and arguments.
The configuration is read only when a command needs it, as before only after `help` and `version`.
- Tested functions out of the commands:
- `watchTarget`: the pull request and the interval of `watch-pr`;
- `relayForgotten` and `loopback`: the answer of `forget-relay` by the server's status;
- `credentials` and `loggedIn`: user, password and the answer of `matrix login`;
- `zoneOf`, `firstStory`, `orNone` and `matrixOf`: the journal's zone, the story of a Taiga ref, optional parts of the configuration.
`pitestPartial mutationCrapCheck` against main: 162 mutants, the highest Mutation-CRAP 12, e.g. `main` and `forgetRelay`.
## Additional Changes
- `pitestPartial` also takes the Kotlin files that git does not track yet, e.g. a new file before its first commit;
so far it took only the changed ones.
- `doc/werkregie.werkbaum`: the mutation tests of PR#64 are deployed.
## Follow-up PRs
- PR#65: `watch-pr` reports `READY` only when each required check passed.