New rule java:S8445 disagrees with commony used Google Java Style

Apparently there is a new rule in the default Sonar Way, namely S8445: Group import declarations by specificity. The ordering specified there disagrees with the widely used Google Java Style: Google Java Style Guide

Is it really a good idea for Sonar to make a quasi authoritative choice here? I understand that we can create a custom profile, but I strongly prefer staying with the default Sonar Way, if possible.

Wow, this rule just created 20 new issues across a small repo on the free plan where I can’t customize the quality profile. I 100% agree with Philpp that this is not a good new rule. We also use the Google Java Style Guide. Please don’t enable this rule as the default…

Hi Philipp and Scott!

Thank you for your feedback! I apologize for the friction caused by the initial output from S8445.

With Java 25 finalizing module imports, we believe this new construct necessitates checking the grouping and ordering of imports. However, our initial implementation proved too opinionated and, as you noted, conflicted with the Google Java Style Guide.

We are planning (SONARJAVA-6146) to relax the rule as follows:

  • import module should come first.
  • import and import static should be grouped together, but their relative order will no longer be enforced.
  • On-demand (wildcard) imports will be treated the same as specific imports.

We believe these relaxed requirements are non-controversial, allowing us to keep the rule in the default quality profile. Please let us know if you have any further feedback or concerns!

1 Like

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