Class cohesion DevCenter
io.moderne.devcenter.ClassCohesionDevCenter
A DevCenter that finds class quality metrics for repositories and buckets the average LCOM4 (Lack of Cohesion of Methods, version 4) into HIGH / MEDIUM / LOW cohesion categories.
Recipe source
GitHub: code-quality-devcenter.yml, Issue Tracker, Maven Central
This recipe is composed of more than one recipe. If you want to customize the set of recipes this is composed of, you can find and copy the GitHub source for the recipe from the link above.
This recipe is available under the Moderne Source Available License.
Definition
- Recipe List
- Yaml Recipe List
- Find class quality metrics
- Find test coverage gaps
- DevCenter card from a data table column
- inputDataTable:
io.moderne.prethink.table.ClassQualityMetrics - cardName:
Average Class Maintainability - column:
maintainabilityIndex - aggregation:
AVERAGE - buckets:
[Bucket(name=F, moreThan=0), Bucket(name=D, moreThan=20), Bucket(name=C, moreThan=40), Bucket(name=B, moreThan=60), Bucket(name=A, moreThan=80)]
- inputDataTable:
- DevCenter card from a data table column
- inputDataTable:
io.moderne.prethink.table.ClassQualityMetrics - cardName:
Average Class Cohesion - column:
lcom4 - aggregation:
AVERAGE - buckets:
[Bucket(name=LOW, moreThan=10), Bucket(name=MEDIUM, moreThan=3), Bucket(name=HIGH, moreThan=0)]
- inputDataTable:
- DevCenter card from a data table column
- inputDataTable:
io.moderne.prethink.table.TestGaps - cardName:
Test Gaps Risk - column:
riskScore - aggregation:
SUM - buckets:
[Bucket(name=LOW, moreThan=0), Bucket(name=MEDIUM, moreThan=3), Bucket(name=HIGH, moreThan=10)]
- inputDataTable:
---
type: specs.openrewrite.org/v1beta/recipe
name: io.moderne.devcenter.ClassCohesionDevCenter
displayName: Class cohesion DevCenter
description: |
A DevCenter that finds class quality metrics for repositories and buckets the average LCOM4 (Lack of Cohesion of Methods, version 4) into HIGH / MEDIUM / LOW cohesion categories.
recipeList:
- io.moderne.prethink.quality.FindClassMetrics
- io.moderne.prethink.testing.coverage.FindTestGaps
- io.moderne.devcenter.BucketedMetricCard:
inputDataTable: io.moderne.prethink.table.ClassQualityMetrics
cardName: Average Class Maintainability
column: maintainabilityIndex
aggregation: AVERAGE
buckets:
- Bucket(name=F, moreThan=0)
- Bucket(name=D, moreThan=20)
- Bucket(name=C, moreThan=40)
- Bucket(name=B, moreThan=60)
- Bucket(name=A, moreThan=80)
- io.moderne.devcenter.BucketedMetricCard:
inputDataTable: io.moderne.prethink.table.ClassQualityMetrics
cardName: Average Class Cohesion
column: lcom4
aggregation: AVERAGE
buckets:
- Bucket(name=LOW, moreThan=10)
- Bucket(name=MEDIUM, moreThan=3)
- Bucket(name=HIGH, moreThan=0)
- io.moderne.devcenter.BucketedMetricCard:
inputDataTable: io.moderne.prethink.table.TestGaps
cardName: Test Gaps Risk
column: riskScore
aggregation: SUM
buckets:
- Bucket(name=LOW, moreThan=0)
- Bucket(name=MEDIUM, moreThan=3)
- Bucket(name=HIGH, moreThan=10)
Usage
This recipe has no required configuration options. Users of Moderne can run it via the Moderne CLI.
You will need to have configured the Moderne CLI on your machine before you can run the following command.
mod run . --recipe ClassCohesionDevCenter
If the recipe is not available locally, then you can install it using:
mod config recipes jar install io.moderne.recipe:rewrite-devcenter:1.24.0
See how this recipe works across multiple open-source repositories
Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.
Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.
Data Tables
- ClassQualityMetrics
- TestGaps
- UpgradesAndMigrations
- SourcesFileResults
- SearchResults
- SourcesFileErrors
- RecipeRunStats
Class quality metrics
io.moderne.prethink.table.ClassQualityMetrics
Per-class code quality metrics including WMC, LCOM4, TCC, CBO, and maintainability index.
| Column Name | Description |
|---|---|
| Source path | The path to the source file containing the class. |
| Class name | The fully qualified name of the class. |
| Line count | Number of lines in the class. |
| Method count | Number of methods defined in the class. |
| Field count | Number of fields defined in the class. |
| WMC | Weighted Methods per Class: sum of cyclomatic complexities of all methods. |
| LCOM4 | Lack of Cohesion of Methods (Hitz-Montazeri): number of connected components in the method-field access graph. 1 = cohesive, >1 = should be split. |
| TCC | Tight Class Cohesion: proportion of directly connected method pairs (sharing field access). 0.0-1.0, higher is more cohesive. |
| CBO | Coupling Between Objects: number of distinct classes this class is coupled to. |
| Maintainability index | Composite score (0-100) combining Halstead Volume, cyclomatic complexity, and LOC. Higher is more maintainable. |
Test gaps
io.moderne.prethink.table.TestGaps
Public non-trivial methods that have no test coverage, ranked by risk score.
| Column Name | Description |
|---|---|
| Source path | The path to the source file containing the untested method. |
| Class name | The fully qualified name of the class. |
| Method name | The simple name of the untested method. |
| Method signature | The full method signature. |
| Cyclomatic complexity | The cyclomatic complexity of the untested method. |
| Risk score | Risk score combining complexity and architectural centrality (call count). Higher = more critical gap. |
| Gap reason | Why this gap matters, e.g., 'complexity 15, called by 8 methods, no test coverage'. |
| Suggested test class | Suggested fully qualified name for the test class. |
Upgrades and migrations
io.moderne.devcenter.table.UpgradesAndMigrations
Progress towards organizational objectives on library or language migrations and upgrades.
| Column Name | Description |
|---|---|
| Card | The display name of the DevCenter card |
| Ordinal | The ordinal position of this value relative to other values. |
| Value | The display value of the current state of this repository. |
| Minimum version | The minimum matching version that is currently in use. |
Source files that had results
org.openrewrite.table.SourcesFileResults
Source files that were modified by the recipe run.
| Column Name | Description |
|---|---|
| Source path before the run | The source path of the file before the run. null when a source file was created during the run. |
| Source path after the run | A recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run. |
| Parent of the recipe that made changes | In a hierarchical recipe, the parent of the recipe that made a change. Empty if this is the root of a hierarchy or if the recipe is not hierarchical at all. |
| Recipe that made changes | The specific recipe that made a change. |
| Estimated time saving | An estimated effort that a developer to fix manually instead of using this recipe, in unit of seconds. |
| Cycle | The recipe cycle in which the change was made. |
Source files that had search results
org.openrewrite.table.SearchResults
Search results that were found during the recipe run.
| Column Name | Description |
|---|---|
| Source path of search result before the run | The source path of the file with the search result markers present. |
| Source path of search result after run the run | A recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run. |
| Result | The trimmed printed tree of the LST element that the marker is attached to. |
| Description | The content of the description of the marker. |
| Recipe that added the search marker | The specific recipe that added the Search marker. |
Source files that errored on a recipe
org.openrewrite.table.SourcesFileErrors
The details of all errors produced by a recipe run.
| Column Name | Description |
|---|---|
| Source path | The file that failed to parse. |
| Recipe that made changes | The specific recipe that made a change. |
| Stack trace | The stack trace of the failure. |
Recipe performance
org.openrewrite.table.RecipeRunStats
Statistics used in analyzing the performance of recipes.
| Column Name | Description |
|---|---|
| The recipe | The recipe whose stats are being measured both individually and cumulatively. |
| Source file count | The number of source files the recipe ran over. |
| Source file changed count | The number of source files which were changed in the recipe run. Includes files created, deleted, and edited. |
| Cumulative scanning time (ns) | The total time spent across the scanning phase of this recipe. |
| Max scanning time (ns) | The max time scanning any one source file. |
| Cumulative edit time (ns) | The total time spent across the editing phase of this recipe. |
| Max edit time (ns) | The max time editing any one source file. |