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.
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.
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.
Hey @Megala_Natarajan,
I am having a look and I am currently having some trouble reproducing the issue. But as mentioned in the conversation above, it looks like SonarLint is doing the right thing while SonarQube is not.
So here are a few additional questions to help clear out the issue
What version of Java are you using?
Is the Java version of the project different from the one you use to run the scanner with the Gradle command?
Thank you for clarifying @Megala_Natarajan.
We can clear the Java version mismatch out of the possibilities.
I would like to rule out any analysis configuration issue here: When running the gradle command to analyze your code, is the Java runtime used a JRE or JDK?
This matters because the type resolution of IllegalArgumentException seems to be broken and causing this difference in behavior. I am asking about the Gradle command specifically because SonarLint usually has pretty sane configuration defaults in terms of analysis.
If the answer to the question above is a JRE, consider using a JDK or pointing to a local JDK installation using the sonar.java.jdkHome analysis parameter.