Custom SonarQube Quality Profile rules are not shown in Intellij SonarLint

Intellij version: 2021.2.2 Ultimate Edition
SonarLint plugin: 5.3.0.36775
SonarQube version: Community Edition Version 9.0.1 (build 46107)

Hi,
in SonarQube we have defined a custom Java Quality Profile which we set as default for Java projects.
We would like to use the rules from this profile in our Intellij using the SonarLint plugin. We have bound SonarLint with the correct Project and SonarQube server, but when we click on update binding we just get the default SonarWay Quality Profile rules imported.
Is there a way to explicitly tell SonarLint to use our custom Quality Profile?

Hello @Timon,

Thanks for letting us know about the problem and welcome to the community!
Unfortunately, I can not reproduce the issue. Once you configured the connection and created binding to the project SonarLint should pick up active Quality Profile from server it’s connected to and apply all rules settings.
To be on the same page I’ll add pictures of how it looks like on my box.
New quality profile with only one active rule is set to default on SonarQube:

Project scanned by SonarQube with new quality profile:

IntelliJ settings:

No issues reported on SonarLint even though we can see there are plenty of them in the code.

But if we will introduce the single one we activated in the new quality profile - it will be reported.

And if bindings are disabled - everything from local SonarLint settings is reported again:

If you spotted some difference between your actions and what you see on pictures - that’s may be the reason of the problem. If what I posted above doesn’t help - please answer below and we will continue troubleshooting. Maybe it will be useful to mention exact rules and your expectations about them (you want them to be enabled or disabled by new quality profile).

Have a good day!

2 Likes

Hello,

thank you for the clear answer. We tried something similar and could confirm that SonarLint uses the default Quality Profile from the Project we connected to. However, we noticed that SonarLint doesn’t show all the warnings that we see in SonarQube. In the following screenshots you can see that in SonarQube we have 11 notifications from five different rules, while IntelliJ shows only six notifications from four rules.

Is this difference to be expected?

Hello @Timon.
Sorry answer took so long.
Short answer - yes, this is expected. Some rules are executed only on remote :sonarqube: or :sonarcloud: server, and some rules are executed only locally on :sonarlint:.

Now long answer. Usually you can rely on this rule reference site: https://rules.sonarsource.com.
In the lower part of the description of each rule you can see icons of the products where this rule is available.
Screenshot 2021-10-07 at 16.39.47

But there are six unfortunate exclusions from this rule. They only executed on SonarQube or SonarCloud server side and not available in SonarLint. But for historical reasons they are not included in that rule reference site I’ve linked above.
So here the list of this rules:

  • Insufficient branch coverage
  • Insufficient line coverage
  • Insufficient comment density
  • Duplicated blocks (your case)
  • Failed unit tests
  • Skipped unit tests

Hope it helps.

1 Like

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