SonarLint is not showing all records compared to referenced SonarQube server
Asked Answered
H

3

12

We are using SonarQube server version 5.3 with SonarLint 2.0 in connected mode. As an IDE we use Eclipse Mars 2.0 and when we compare results found by SonarQube server with results found by SonarLint within IDE, the results differ (example file 274 errors in IDE, 826 issues in SonarQube!).

One of the usual differentiations is that "Variable could be declared final".

Also one of my colleagues who is using SonarLint for IntelliJIdea is having similar issues (Idea version 2016.1.1, SonarLint 2.0.2, example file - same as used for comparison in IDE 293 errors).

I wonder why there are such differentiations against the server and even between IDEs.

Could someone help me out on this? Thanks.

Homage answered 11/5, 2016 at 9:28 Comment(0)
C
13

I'm facing a similar issue, illustrated by this example: SonarLint 2.0.2: 99 issues. SonarQube 5.4 UI: 116 issues. Differences caused by 2 rules which belong to the Checkstyle Plugin.

As you are talking about "Variable could be declared final" I'm assuming the rule behind your missing issues is pmd:LocalVariableCouldBeFinal, which belongs to the PMD Plugin.

Fabrice has commented on this topic in SonarQube Google Group they "won't add support for any external engine": SonarQube Google Group (this is true for PMD, Checkstyle, Findbugs and others...)

So sadly we can only use rules mentioned in SonarLint rules list which are provided by SonarQube out of the box (i.e. their Java Plugin).

Coff answered 12/5, 2016 at 10:35 Comment(2)
I see! Thanks a lot for the explanation about external engines, now it makes much more sense.Homage
A very good answer indeed! Perhaps, the remedy would be for people to create a new Quality Profile in SonarQube, making use of the mapping of rules and then activate that profile instead of what's available in FindBugs and PMD. I guess this should be a new feature request for the SonarQube product---uplifting FindBugs based profile to SonarSource analyzer.Madel
N
6

First of all, SonarQube runs a full analysis of your project while SonarLint only analyses the files that you open. So I don't really know how your comparison of issue count can make sense (unless you opened all files one by one in Eclipse).

Second, there are some known reasons why SonarLint will show less or more issues than SonarQube:

  • Some rules based on metrics are computed only in SonarQube. For instance:
    • Insufficient (line or branch) coverage
    • Insufficient comment density
    • Duplicated code
  • You might have defined issue exclusions on SonarQube, which are not taken into account yet in SonarLint
    • But this will come soon
  • You might have defined source code exclusions on SonarQube, which are not taken into account yet in SonarLint
    • But this will come soon
Nowicki answered 11/5, 2016 at 11:41 Comment(3)
First of all, thanks for the answer. I appreciate quick response. Second - I understand that for some issues you need multiple files analyzed (for example for immutability issues etc.) - however I don't believe that you need that specifically for "Variable could be declared final" kind of error - you should need only nearest context there, shouldn't you? I don't have any issue exclusions on SonarQube and source code exclusions do not affect area tested. Also I understand the argument about metrics - and I would understand those missing.Homage
However, if I concentrate specifically on Variable could be declared final, I don't really understand why these are not displayed.Homage
Ok, read comment about external engines from @jan-s and it makes sense now.Homage
F
-1

If you just click on the Project, It won't work, You need to go into the project and Click on the java files, Once you start clicking on the Java files present in the Project.You would see SonarLint getting activated and showing you all the errors present.It worked for me

Found answered 25/4, 2017 at 6:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.