Skip to content

IndentationCheck: incorrect validation for class definition #2629

@rnveach

Description

@rnveach

D:> type 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">
    <property name="charset" value="ASCII" />
    <property name="severity" value="error" />
    <property name="fileExtensions" value="java" />

    <module name="TreeWalker">
        <module name="Indentation">
        </module>
    </module>
</module>

D:> type test.java

package test;

class
    Test1 {//indent:4 exp:0 // CS says invalid
}
public
    class Test2 {//indent:4 exp:4 // CS os OK, but this should be warning
}

D:> java -jar checkstyle-6.12.1-all.jar -c config.xml test.java

Starting audit...
test.java:4: error: 'class def ident' have incorrect indentation level 4, expected level should be 0.
Audit done.
Checkstyle ends with 1 errors.

I was expecting CS to not report any error on line 4 because similar code (the 2nd class) does require the line to be indented.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions