Since Checkstyle 8.33
Checks whether file contains code. Java compiler is not raising errors on files with no code or all commented out. Files which are considered to have no code:
To configure the check:
<module name="Checker"> <module name="TreeWalker"> <module name="NoCodeInFile"/> </module> </module>
Example:
// the violation is on first line of file // public class Example1 { // single-line comment is not code // }
Example:
// the violation is on first line of file /* public class Example2 { block comment is not code } */
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