New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect indentation check for method preceded by annotation, with method parameter on separate line #5154

Closed
andersthorbeck opened this Issue Sep 28, 2017 · 5 comments

Comments

Projects
None yet
5 participants
@andersthorbeck

andersthorbeck commented Sep 28, 2017

Anderss-MacBook-Pro:checkstyle andtho$ javac Test.java

Anderss-MacBook-Pro:checkstyle andtho$ cat Test.java

package bugreport;

class Test {

  @interface Annotation1 {
    String field1();
    String field2();
  }

  @interface Annotation2 {};

  @Annotation1(field1 = "foo", field2 = "bar")
  public @Annotation2 String method( // violation
      String param
  ) {
    return null;
  }

}

Anderss-MacBook-Pro:checkstyle andtho$ 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">
      <property name="basicOffset" value="2"/>
      <property name="braceAdjustment" value="0"/>
      <property name="caseIndent" value="2"/>
      <property name="throwsIndent" value="4"/>
      <property name="lineWrappingIndentation" value="4"/>
      <property name="arrayInitIndent" value="2"/>
    </module>
  </module>
</module>

Anderss-MacBook-Pro:checkstyle andtho$ java -jar checkstyle-8.2-all.jar -c config.xml Test.java

Starting audit...
[ERROR] /Users/andtho/code/sandbox/bug_reports/checkstyle/Test.java:13: 'public' has incorrect indentation level 2, expected level should be 6. [Indentation]
Audit done.
Checkstyle ends with 1 errors.

Expected no indentation error.

The error occurs when the parameter param is on a new line; it does not occur when the entire method signature (except @Annotation1) is on one line. It also does not occur when @Annotation1 is omitted.

I need to be able to put parameters on a new line, as the method signature exceeds the maximum line width (in real-life code), so this is an actual issue.

Note, when I indent public to indentation level 6, the expected indentation level is increased to 10, and then to 14, 18, etc.

@rnveach rnveach added the indentaion label Sep 28, 2017

@romani romani added the approved label Sep 28, 2017

@AADudkin

This comment has been minimized.

Show comment
Hide comment
@AADudkin

AADudkin commented Oct 27, 2017

I'm on it

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Oct 28, 2017

Member

@AADudkin , Indentation Check is the most complicated Check in whole Checkstyle, and probably requires complete rewrite. Try to fix, but feel free to drop this issue. There are more issues that is more ease to resolve and they are more painful for users.

Member

romani commented Oct 28, 2017

@AADudkin , Indentation Check is the most complicated Check in whole Checkstyle, and probably requires complete rewrite. Try to fix, but feel free to drop this issue. There are more issues that is more ease to resolve and they are more painful for users.

@AADudkin

This comment has been minimized.

Show comment
Hide comment
@AADudkin

AADudkin Nov 12, 2017

I dropped issue. Currently don't have enough time to contribute.

AADudkin commented Nov 12, 2017

I dropped issue. Currently don't have enough time to contribute.

@djydewang

This comment has been minimized.

Show comment
Hide comment
@djydewang

djydewang Dec 3, 2017

Contributor

I am on it.

Contributor

djydewang commented Dec 3, 2017

I am on it.

djydewang added a commit to djydewang/checkstyle that referenced this issue Dec 3, 2017

Issue checkstyle#5154: Incorrect indentation check for method precede…
…d by annotation, with method parameter on separate line

djydewang added a commit to djydewang/checkstyle that referenced this issue Dec 3, 2017

Issue checkstyle#5154: Incorrect indentation check for method precede…
…d by annotation, with method parameter on separate line

djydewang added a commit to djydewang/checkstyle that referenced this issue Dec 5, 2017

Issue checkstyle#5154: Incorrect indentation check for method precede…
…d by annotation, with method parameter on separate line

djydewang added a commit to djydewang/checkstyle that referenced this issue Dec 12, 2017

Issue checkstyle#5154: Incorrect indentation check for method precede…
…d by annotation, with method parameter on separate line

djydewang added a commit to djydewang/checkstyle that referenced this issue Dec 12, 2017

Issue checkstyle#5154: Incorrect indentation check for method precede…
…d by annotation, with method parameter on separate line

djydewang added a commit to djydewang/checkstyle that referenced this issue Dec 12, 2017

Issue checkstyle#5154: Incorrect indentation check for method precede…
…d by annotation, with method parameter on separate line

rnveach added a commit that referenced this issue Dec 16, 2017

Issue #5154: Incorrect indentation check for method preceded by annot…
…ation, with method parameter on separate line
@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach Dec 16, 2017

Member

Fix was merged

Member

rnveach commented Dec 16, 2017

Fix was merged

@rnveach rnveach closed this Dec 16, 2017

@rnveach rnveach added this to the 8.6 milestone Dec 16, 2017

@rnveach rnveach added the bug label Dec 16, 2017

timurt added a commit to timurt/checkstyle that referenced this issue Dec 19, 2017

Issue checkstyle#5154: Incorrect indentation check for method precede…
…d by annotation, with method parameter on separate line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment