An anonymous class has more lines of code than the limit

tx0/java:long-anonymous-classstrictwarningmaintainability

What it finds

An anonymous class is read in the middle of the code that creates it, has no name to say what it is for, and cannot be tested on its own. A long one is easier to follow as a named class.

Counted are the lines of code of the class body. A class above the parameter max-lines, 40 by default, is reported.

From the rule's source, long_anonymous_class.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:long-anonymous-class" = "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:long-anonymous-class] reason="..."

tx0 explain tx0/java:long-anonymous-class shows the same in the terminal. Found a false positive? Report it.