The number of fields of a class is above the limit

tx0/java:field-countstrictwarningmaintainability

What it finds

A class with many fields keeps a lot of state, and its methods each touch a part of it: often it is several classes in one.

Counted are the variables a class or enum declares in its fields, other than constants (static final fields). A class above the parameter max, 20 by default, is reported.

From the rule's source, too_many_fields.rs.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:field-count" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:field-count] reason="..."

tx0 explain tx0/java:field-count shows the same in the terminal. Found a false positive? Report it.