I have read check documentation: https://checkstyle.sourceforge.io/checks/whitespace/emptylineseparator.html#EmptyLineSeparator
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words
Code:
/*
* Copyright 2025
*/
package benchimarkfilesmakeup;
import java.util.List; // Expected violation
public class Test {
}
Config:
/var/tmp $ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="localeLanguage" value="en"/>
<module name="TreeWalker">
<module name="EmptyLineSeparator">
<property name="tokens" value="IMPORT"/>
<property name="allowMultipleEmptyLines" value="false"/>
</module>
</module>
</module>
Cli:
/var/tmp $ java -jar checkstyle-10.26.1-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /var/tmp/Test.java:8:1: 'CLASS_DEF' should be separated from previous line. [EmptyLineSeparator]
Audit done.
The Checkstyle documentation states that:
“Checks for empty line separators before package, all import declarations, fields, constructors, methods, nested classes, static initializers and instance initializers.”
This suggests that only the tokens listed in the tokens property should be checked.
However, the behavior is inconsistent:
False Positive (FP): It reports a violation before the CLASS_DEF line — even though CLASS_DEF is not in the token list.
False Negative (FN): It fails to report a violation for the IMPORT statement that is not preceded by an empty line — even though IMPORT is in the token list.
I have read check documentation: https://checkstyle.sourceforge.io/checks/whitespace/emptylineseparator.html#EmptyLineSeparator
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words
Code:
Config:
Cli:
The Checkstyle documentation states that:
“Checks for empty line separators before package, all import declarations, fields, constructors, methods, nested classes, static initializers and instance initializers.”
This suggests that only the tokens listed in the tokens property should be checked.
However, the behavior is inconsistent:
False Positive (FP): It reports a violation before the CLASS_DEF line — even though CLASS_DEF is not in the token list.
False Negative (FN): It fails to report a violation for the IMPORT statement that is not preceded by an empty line — even though IMPORT is in the token list.