Skip to content

Indentation: false positive for try child on the same line #5685

@pbludov

Description

@pbludov

https://checkstyle.org/checks/misc/indentation.html#Indentation

/var/tmp $ javac TestClass.java:
/var/tmp $ cat TestClass.java:

class TestClass {
    void method() {
        try { return; // Line 3
        }
        catch (Exception e) { return; // Line 5
        }
    }
}

/var/tmp $ cat config.xml:

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
        "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
        "http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<module name="Checker">
  <module name="TreeWalker">
    <module name="Indentation"/>
  </module>
</module>

/var/tmp $ java -Duser.language=en -Duser.country=US -jar checkstyle-8.8-all.jar -c config.xml TestClass.java:

Starting audit...
[ERROR] /var/tmp/TestClass.java:3: 'try' child has incorrect indentation level 8, expected level should be 12. [Indentation]
[ERROR] /var/tmp/TestClass.java:5: 'catch' child has incorrect indentation level 8, expected level should be 12. [Indentation]
Audit done.
Checkstyle ends with 1 errors.

There should be no violations.

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