Issue Count Mismatch in Sonarlint and Soanrqube

If your question is about SonarLint in the IntelliJ Platform, VS Code, Visual Studio, or Eclipse, please post it in that sub-category.

Otherwise, please provide:

  • Operating system: Windows
  • IDE name and flavor/env: Android Studio

And a thorough description of the problem / question:
Sonarlint analysis for a file is done using connected mode. For a same rule, the issue is reported in sonarqube but not in sonarlint.
The Rule is enabled in Sonarlint as well. Even after whole project scan , the issue was not reported in sonarlint.

Rule : Java - java:S1162

Hi,

Can you provide your SonarLint version and the code in question?

 
Thx,
Ann

Hi Ann,

SonarLint Version - 10.5.0.78339

Code

Hi,

Thanks for these details.

Could I also have your SonarQube version and a screenshot of the code/issue in SonarQube?

 
Thx,
Ann

Hi Ann,

Sonarqube Version - * Enterprise Edition

  • Version 9.9.1 (build 69595)

Issue Screenshot -

Hi,

Thanks for this.

If I look at the rule description, the code sample explicitly marks throwing an IllegalArgumentException as ‘Compliant’. So it’s not clear to me whether the problem is that SonarLint doesn’t raise the issue or that SonarQube does.

I’m going to flag this for the language experts to adjudicate the issue, and then we can go from there.

 
Ann

Hello @Megala_Natarajan,

Thanks for raising the issue.

In this case, SL is correct, as IllegalARgumentException is a RuntimeException, and the issue shouldn’t be shown. This makes me think that the rule implementation works correctly and that the issue might be a misconfiguration.

Could you please share your configuration/properties with us? Also, let me know if you’re using Gradle and how exactly you run the analysis. Most likely, something is missing in the configuration of the analysis, and it affects the result.

Best,
Margarita

Hi Margarita,

Yes we use Gradle for sonar analysis. Below is the command we use

./gradlew sonar -x compileHighDebugUnitTestKotlin -Dsonar.projectKey=mahindra-cid-myvehicle -Dsonar.projectName=mahindra-cid-myvehicle -Dsonar.host.url=https://mrv-sonarqube.mahindra.com/ -Dsonar.login=**** -Dsonar.test.exclusions='**/test/**,**/androidTest/**'

Do you build the project before analyzing it and which version of the scanner for Gradle are you using?

We run the scan post project build.
Sonar Plugin version used in gradle is 3.5.0.2730