Since Checkstyle 5.3
Checks that the outer type name and the file name match. For example,
the class Foo
must be in a file named
Foo.java
.
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="OuterTypeFilename"/> </module> </module>
Example file content with name of file Example1.java
public class Example1 {}
Example file content with name of file Example2.java
class Example2ButNotSameName {} // violation
Example file content with name of file Example3.java
interface Example3ButNotSameName {} // violation
Example file content with name of file Example4.java
enum Example4ButNotSameName {} // violation
Example file content with name of file Example5.java
class Example5ButNotSameName {} // violation
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