FP on squid:IndentationCheck with switch case indentation

Hi,

I’d like to keep the SonarJava squid:IndentationCheck activated but I still face the following issue http://sonarqube-archive.15.x6.nabble.com/Java-Check-of-indentation-of-switch-case-td5033050.html that raises a lot of false positive. Is there any plan to fix this false-positive?

Thank you

Regards,

David

Hi @racodond !

Given that this coding convention from oracle is actually pretty hard to find and was not maintained since 1999 (20 years ago). Given that other java coding guidelines (google one for instance) are not promoting this indentation style I strongly believe that this is not really an issue that is worth fixing on our side.
If you want to work around this I would suggest you to implement your own indentation check as a custom rule.
Thanks for your understanding.

Did you ever create your own rule?

The Sun/Oracle style makes more sense, because it looks at the semantics rather than the syntax. If you just look at syntax, everything between the curly braces should be indented. (But then why is code after a case statement indented? There are no braces there!) But semantically, the switch statement is just a specialized form of if-then-else, so a case statement is equivalent to elseif (which is aligned with the if) and a default statement is equivalent to else (which is also aligned with the if).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Hey @MisterPi ,

Please create a new thread with your question, with clear examples and a code reproducer highlighting your point. This thread is 2 years old and the Java analyzers evolved a lot in between.

Cheers,
Michael