Skip to content
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 comment indentation inside switch statements #1147

Closed
Zopsss opened this issue Aug 22, 2024 · 1 comment
Closed

Incorrect comment indentation inside switch statements #1147

Zopsss opened this issue Aug 22, 2024 · 1 comment

Comments

@Zopsss
Copy link

Zopsss commented Aug 22, 2024

Detected at @checkstyle: checkstyle/checkstyle#15521 (comment)

We were working on improving Checkstyle's test cases for google style guide. We used google-java-format tool to format the input file and used google_checks.xml against it to ensure that we're following every rules. We had a case like:

    switch (a) {
      // comment
      case 1:
      default:
    }

formatter formatted it to something like:

    switch (a) {
        // comment
      case 1:
      default:
    }

the indentation for // comment increased, our test started failing and the violation message was:

764:9: Comment has incorrect indentation level 8, expected is 6, indentation should be the same level as line 765.

We faced this problem at 3 places in our input file, here's the full test result: checkstyle/checkstyle#15521 (comment)

Based on 4.8.4.1 Indentation & 4.2 Block indentation: +2 spaces, the content should be increased by 2 spaces but formatter increased the indentation by 4 spaces.

@cushon
Copy link
Collaborator

cushon commented Aug 24, 2024

This is a duplicate of #1127, which is fixed at head and will be included in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants