Skip to content

EmptyLineSeparator check does not validate newlines before comments #2974

@vovkab

Description

@vovkab
$ javac Test.java
$ cat Test.java
public class Test {

    public static final void method1() { }



    // Method 2 must fail
    public static final void method2() { }



    /**
     * Method 3 must fail
     */
    public static final void method3() { }
}


$ cat config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
    "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
    "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

<module name="Checker">
    <module name="TreeWalker">
        <module name="EmptyLineSeparator">
            <property name="allowNoEmptyLineBetweenFields" value="true"/>
            <property name="allowMultipleEmptyLines" value="false"/>
        </module>
    </module>
</module>


$ java -jar checkstyle-6.15-all.jar -c config.xml Test.java
Starting audit...
Audit done.

Expected:
method2 and method3 must fail with ... has more than 1 empty lines before. [EmptyLineSeparator]

Related tickets: #2067

http://checkstyle.sourceforge.net/config_whitespace.html#EmptyLineSeparator

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions