NoCodeInFile

Since Checkstyle 8.33

Description

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:
  • File with no text
  • File with single-line comment(s)
  • File with a multi line comment(s).

Examples

To configure the check:


<module name="Checker">
  <module name="TreeWalker">
    <module name="NoCodeInFile"/>
  </module>
</module>

Example:


// violation first line 'The file does not contain any code'
// public class Example1 {
// single-line comment is not code
// }

Example:


// violation first line 'The file does not contain any code'
/*
 public class Example2 {
 block comment is not code
 }
*/

Example of Usage

Violation Messages

All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.

Fully Qualified Name

com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck

Use this fully qualified class name in configuration when an exact class reference is required.

Parent Module

TreeWalker