Since Checkstyle 5.0
Rationale: It is considered good practice to only define one outer type per file.
name | description | type | default value | since |
---|---|---|---|---|
max | Specify the maximum number of outer types allowed. | int | 1 |
5.0 |
To configure the check to accept 1 outer type per file:
<module name="Checker"> <module name="TreeWalker"> <module name="OuterTypeNumber"/> </module> </module>
Example:
// violation 2 lines above 'Outer types defined is 3 (max allowed is 1)' public class Example1 { } class Example { void exampleMethod() {} } enum outer { }
To configure the check to accept 2 outer types per file:
<module name="Checker"> <module name="TreeWalker"> <module name="OuterTypeNumber"> <property name="max" value="3"/> </module> </module> </module>
Example:
public class Example2 { } class Examples { void exampleMethod() {} } enum outer1 { }
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.sizes