Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Indentation: Annotation with RParen on new line when followed by other annotations causes invalid expectation #3733
temp $ javac CheckstyleRightParenBug.java
temp $ cat CheckstyleRightParenBug.java
temp $ cat config.xml
temp $ java -jar checkstyle-7.4-all.jar -c config.xml CheckstyleRightParenBug.java
I expect the closing parenthesis to be at the same level as the start of the annotation, but this is only enforced on the last annotation before the class declaration. This error also occurs on annotations of other elements as well (class variables, methods, etc.). They are all erroneously expected to be one basic offset deeper than they should be.
Stepping through the test code, I see that the two annotations are bunched together when calling checkAnnotationIndentation in LineWrappingHandler.java. The parameter atNode includes the lines from all the annotations and the public access modifier preceding the (class|method) declaration. lastAnnotationNode gets set to the last line of the last annotation, and not the last line of the current annotation.
I understand that resources are limited in addressing this (and the other indentation) bugs. I will take a stab at fixing it when I get some free time.