Cohesion and coupling in the code city, RFC 0002 step 2 (0.19.0) #37

Merged
mi merged 1 commits from mihoe/cohesion-coupling-city into main 2026-10-04 11:37:48 +02:00
Owner

Related Links

The Problem

Since PR#36 the report measures cohesion and coupling per class, but the code city did not show them.

The Scenarios

  • @MC-CK-008 the city has the metrics lcom4 (relative: a package shows the median), efferent_coupling and afferent_coupling (absolute: a package shows the sum); a building without LCOM4 has no value, never 0.
  • @MC-CK-009 the report page opens the city coloured by Mutation-CRAP, by cohesion (1 green, 2 yellow, from 3 red) or by coupling (the viewer's own bounds, until step 3 brings a limit).
Verified by

The Solution

  • ReportInput reads the section classes; CodeCity measures a building by its methods and, where known, its class's cohesion and coupling.
  • The report page builds three links from one layout, area=rloc&height=complexity, each with its colour.
  • werkcrappit-pit applies the Gradle plugin 0.18.0, whose gate reads schema version 2, which ends the failing nightly mutationCrapCheck since PR#36.
  • ReportInput.designs reads one class in design: at first one method, it exceeded werkcrappit's own limit of 9, which a round-trip test of report and reader and the split brought back.
  • Version 0.19.0.

Open Questions

  • werkcrappit's own city shows the new metrics only once its Gradle plugin is raised to 0.19.0: the export of its build runs on the released plugin.

🤖 Generated with Claude Code

## Related Links - [RFC 0002](../rfcs/0002-cohesion-and-coupling.md), step 2; [PR#36](2026-10-04-PR%2336-cohesion-coupling-measured.md), step 1 ## The Problem Since PR#36 the report measures cohesion and coupling per class, but the code city did not show them. ## The Scenarios - `@MC-CK-008` the city has the metrics `lcom4` (relative: a package shows the median), `efferent_coupling` and `afferent_coupling` (absolute: a package shows the sum); a building without LCOM4 has no value, never 0. - `@MC-CK-009` the report page opens the city coloured by Mutation-CRAP, by cohesion (1 green, 2 yellow, from 3 red) or by coupling (the viewer's own bounds, until step 3 brings a limit). ##### Verified by - [CodeCityTest](../../werkcrappit-pit/src/test/java/de/javagil/werkcrappit/pit/codecharta/CodeCityTest.java) `theCityShowsCohesionAndCoupling` - [CodeCityPageTest](../../werkcrappit-pit/src/test/java/de/javagil/werkcrappit/pit/codecharta/CodeCityPageTest.java) `thePageOpensTheCityByCohesionOrCoupling` - [CodeChartaFunctionalTest](../../werkcrappit-gradle-plugin/src/functionalTest/java/de/javagil/werkcrappit/gradle/CodeChartaFunctionalTest.java) `theMetricsComeFromTheReport`: every class of a real build's report reaches its building ## The Solution - `ReportInput` reads the section `classes`; `CodeCity` measures a building by its methods and, where known, its class's cohesion and coupling. - The report page builds three links from one layout, `area=rloc&height=complexity`, each with its colour. - werkcrappit-pit applies the Gradle plugin 0.18.0, whose gate reads schema version 2, which ends the failing nightly `mutationCrapCheck` since PR#36. - `ReportInput.designs` reads one class in `design`: at first one method, it exceeded werkcrappit's own limit of 9, which a round-trip test of report and reader and the split brought back. - Version 0.19.0. ## Open Questions - werkcrappit's own city shows the new metrics only once its Gradle plugin is raised to 0.19.0: the export of its build runs on the released plugin. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
mi added 1 commit 2026-10-04 11:26:45 +02:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mi merged commit 8bde21b517 into main 2026-10-04 11:37:48 +02:00
mi deleted branch mihoe/cohesion-coupling-city 2026-10-04 11:37:48 +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#37