werkcrappit showed how complex and how well tested a method is, but not how well a class holds together or how strongly classes depend on each other.
Non-Goals
The code city and the gate: RFC 0002 steps 2 and 3.
Any change of Mutation-CRAP.
The Scenarios
@MC-CK-001 to @MC-CK-006 as agreed for RFC 0002, in the new feature file 08-cohesion-coupling.feature.
@MC-CK-007, added while implementing: the component accessors, equals, hashCode and toString of a record count no more than generated methods.
The first measurement of werkcrappit itself showed every record with an LCOM4 equal to its number of components, from 10 to 15, at the top of the list: javac generates these methods without the mark Lombok puts on its own.
Verified by
DesignAnalysisTest, one test per scenario @MC-CK-001 to @MC-CK-005 and @MC-CK-007
A new package design: Cohesion reads the class files of a top-level class and its nested classes with ASM and connects methods by calls and shared instance fields; DesignAnalysis folds the references the edges already use onto the top-level classes for Ce and Ca.
The listener measures every class of the directory code roots at the end of the run, werkcrappit's excluded classes left out; ClassFiles.classNames moved from the CodeCharta export, which enumerates the code roots the same way.
mutation-crap.json has schema version 2 with the section classes; the gate and the export read version 2. mutation-crap.md lists the ten classes with the highest LCOM4, with their method groups, and the ten with the highest Ce.
ADR 0004 notes the new schema version.
Version 0.18.0.
Open Questions
werkcrappit measures itself with the listener of the same commit but judges with the released Gradle plugin, whose gate reads schema version 1: the nightly mutationCrapCheck of werkcrappit-pit fails until the plugin there is raised to 0.18.0, in the next PR.
Methods that use no field and call nothing are a group each; MutationCrapListenerFactory has LCOM4 3 for name, description and getListener.
Whether such stateless methods should count is a question for the limits of step 3, with the numbers of hsadmin-ng at hand.
Attachments
werkcrappit-pit measured by itself
58 top-level classes, 28 with methods to judge: 19 with LCOM4 1, 6 with 2, 3 with 3.
The highest Ce: MutationCrapListener 21, CodeChartaExport 17, JsonReport 12.
## Related Links
- [RFC 0002](../rfcs/0002-cohesion-and-coupling.md), step 1
## The Problem
werkcrappit showed how complex and how well tested a method is, but not how well a class holds together or how strongly classes depend on each other.
## Non-Goals
- The code city and the gate: RFC 0002 steps 2 and 3.
- Any change of Mutation-CRAP.
## The Scenarios
- `@MC-CK-001` to `@MC-CK-006` as agreed for RFC 0002, in the new feature file `08-cohesion-coupling.feature`.
- `@MC-CK-007`, added while implementing: the component accessors, `equals`, `hashCode` and `toString` of a record count no more than generated methods.
The first measurement of werkcrappit itself showed every record with an LCOM4 equal to its number of components, from 10 to 15, at the top of the list: javac generates these methods without the mark Lombok puts on its own.
##### Verified by
- [DesignAnalysisTest](../../werkcrappit-pit/src/test/java/de/javagil/werkcrappit/pit/design/DesignAnalysisTest.java), one test per scenario `@MC-CK-001` to `@MC-CK-005` and `@MC-CK-007`
- [MutationCrapListenerTest](../../werkcrappit-pit/src/test/java/de/javagil/werkcrappit/pit/listener/MutationCrapListenerTest.java) `theReportCarriesCohesionAndCouplingOfEveryClass` for `@MC-CK-006`
## The Solution
- A new package `design`: `Cohesion` reads the class files of a top-level class and its nested classes with ASM and connects methods by calls and shared instance fields; `DesignAnalysis` folds the references the edges already use onto the top-level classes for Ce and Ca.
- The listener measures every class of the directory code roots at the end of the run, werkcrappit's excluded classes left out; `ClassFiles.classNames` moved from the CodeCharta export, which enumerates the code roots the same way.
- `mutation-crap.json` has schema version 2 with the section `classes`; the gate and the export read version 2.
`mutation-crap.md` lists the ten classes with the highest LCOM4, with their method groups, and the ten with the highest Ce.
- ADR 0004 notes the new schema version.
- Version 0.18.0.
## Open Questions
- werkcrappit measures itself with the listener of the same commit but judges with the released Gradle plugin, whose gate reads schema version 1: the nightly `mutationCrapCheck` of werkcrappit-pit fails until the plugin there is raised to 0.18.0, in the next PR.
- Methods that use no field and call nothing are a group each; `MutationCrapListenerFactory` has LCOM4 3 for `name`, `description` and `getListener`.
Whether such stateless methods should count is a question for the limits of step 3, with the numbers of hsadmin-ng at hand.
## Attachments
### werkcrappit-pit measured by itself
58 top-level classes, 28 with methods to judge: 19 with LCOM4 1, 6 with 2, 3 with 3.
The highest Ce: `MutationCrapListener` 21, `CodeChartaExport` 17, `JsonReport` 12.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Related Links
The Problem
werkcrappit showed how complex and how well tested a method is, but not how well a class holds together or how strongly classes depend on each other.
Non-Goals
The Scenarios
@MC-CK-001to@MC-CK-006as agreed for RFC 0002, in the new feature file08-cohesion-coupling.feature.@MC-CK-007, added while implementing: the component accessors,equals,hashCodeandtoStringof a record count no more than generated methods.The first measurement of werkcrappit itself showed every record with an LCOM4 equal to its number of components, from 10 to 15, at the top of the list: javac generates these methods without the mark Lombok puts on its own.
Verified by
@MC-CK-001to@MC-CK-005and@MC-CK-007theReportCarriesCohesionAndCouplingOfEveryClassfor@MC-CK-006The Solution
design:Cohesionreads the class files of a top-level class and its nested classes with ASM and connects methods by calls and shared instance fields;DesignAnalysisfolds the references the edges already use onto the top-level classes for Ce and Ca.ClassFiles.classNamesmoved from the CodeCharta export, which enumerates the code roots the same way.mutation-crap.jsonhas schema version 2 with the sectionclasses; the gate and the export read version 2.mutation-crap.mdlists the ten classes with the highest LCOM4, with their method groups, and the ten with the highest Ce.Open Questions
mutationCrapCheckof werkcrappit-pit fails until the plugin there is raised to 0.18.0, in the next PR.MutationCrapListenerFactoryhas LCOM4 3 forname,descriptionandgetListener.Whether such stateless methods should count is a question for the limits of step 3, with the numbers of hsadmin-ng at hand.
Attachments
werkcrappit-pit measured by itself
58 top-level classes, 28 with methods to judge: 19 with LCOM4 1, 6 with 2, 3 with 3.
The highest Ce:
MutationCrapListener21,CodeChartaExport17,JsonReport12.🤖 Generated with Claude Code