8

I'm experimenting with SonarLint for IntelliJ, but I'm a bit wary of it. It doesn't seem to be offering anything more than IntelliJ already does, and there's no way to even look at what rules it is offering, let alone change them.

Now, maybe it does add something, but, right now, I'm being spammed by false positives. Things like saying a variable is nullable when it was asserted not null in the very previous line. Is there any way to silence the false positives so I can concentrate on what's left?

Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681
  • If it's anything like working with SonarQube directly then adding the comment: `//NOSONAR` on the line in question should stop it. Haven't tested it though, hence this as a comment suggestion not an answer. – Harmelodic Mar 17 '16 at 01:05
  • 2
    @Harmelodic That might be possible, but I'm not littering my code with meta comments due to _false positives_. – Daniel C. Sobral Mar 18 '16 at 08:25

1 Answers1

12

Standalone Mode

Out of the box, in the stadanlone mode, SonarLint uses a set of default rules. You can find the list of rules in the SonarLint webpage.

Update: You can now configure the rules in the settings.

Connected Mode

It is possible to bind projects to a SonarQube server, and use its Quality Profiles, allowing to customize the rules being used and share the rule set within a team.

On top of that, any known issue in SonarQube that is marked as false positive or won't fix will not be displayed in SonarLint.

Finally, even though we don't promote this feature, you can always add a //NOSONAR as a comment to hide issues.

Changing Highlighting

By default, issues created by SonarLint are highlighted as warnings in IntelliJ, but it can be changed in the following location: Settings > Editor > Colors & Fonts > SonarLint.
It can be useful to make it more clear what SonarLint is contributing with.

Giving Feedback

It would be great if you could show concrete examples of false positives. The rules are constantly being improved, as you can see in this tracker, and feedback is always appreciated. You can open a topic here about false positives.

Duarte Meneses
  • 2,868
  • 19
  • 22
  • I found myself wanting to mark a false positive too. In [my case](https://gist.github.com/spaceCamel/658770b62155e566d9417313363687d2) sonar complains because there is no `equals` alongside `compareTo`. I am not implementing equals because the superclass does that for me. Implementing `equals` in a superclass works well because it's the super class of all my tiny-types: domain specific wrappers around a single field of a more generic type. Do you agree this is a false-positive? – acorello Apr 20 '17 at 14:16