-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Findbugs is reporting false positive bugs SA_LOCAL_SELF_COMPARISON when using instanceof pattern matching #876
Comments
@mpet Can you try the latest and confirm if issue persists? |
This is the same issue as spotbugs/spotbugs#1992 most probably |
@hazendaz I will verify with: com.github.spotbugs spotbugs-maven-plugin 4.8.2.0 |
My understanding (based on spotbugs/spotbugs#1435 (comment) and spotbugs/spotbugs#1992) is that the issue was actually caused by compilers (ecj, javac) producing some redudant bytecode. Maybe while testing with the gradle plugin you also changed the compiler? It is not clear to me what was fixed (nor where or when). From what I can see only a unit test reproducing the issue was added to the SpotBugs project, but I might have missed something |
I am a bit confused now since when I run with the spotbugs maven plugin,spotbugs-maven-plugin, on the below code: Both spotbugs versions 4.7.3.0 and 4.8.2.0 But I get a different bug reported?! |
I think you need to share a way of reproducing the problem or we won't be able to help. |
This is really confusing since the messge from the people admin the SQ server was: |
@gtoison yes I understand I need to be able to reproduce the problem. I do not have access to the SQ instance since I am not admin. That is why I tried with sonar maven plugin since that was the best option. Not sure this is related to compiler since the same compiler is used in both cases: What is needed from SQ to show what is happening? |
FindBugs is the original name of the project. SonarSource made a plugin to use it in SonarQube. So 4.2.3 is the version of the SonarQube plugin and it uses SpotBugs 4.7.3 to perform the analysis. The plugin does not run on the server, it runs wherever the project is built. Normally after the project is compiled and the tests executed sonar runs the analysis (still on the computer running the build) and then only ships the findings (issues, coverage, etc.) to the SonarQube server. |
@gtoison we have been running it on windows and linux but the jdk 17 is the same from Azul. |
I think that you are referring to the JDK running your SonarQube server, but that shouldn't matter here. |
This cleanup includes: * Fix deprecations * Fix JavaDocs * Remove redundant toString calls * Remove redundant semicolons * Simplify boolean expressions * Use diamond operator * Use enhanced for loops * Use instanceof pattern matching * Use isEmpty instead of 0 comparisons * Use lambdas * Use static inner classes * Use StandardCharsets Also adds the SA_LOCAL_SELF_COMPARISON suppression similar as used in other repositories for spotbugs/sonar-findbugs#876. Signed-off-by: Wouter Born <[email protected]>
This cleanup includes: * Fix deprecations * Fix JavaDocs * Remove redundant toString calls * Remove redundant semicolons * Simplify boolean expressions * Use diamond operator * Use enhanced for loops * Use instanceof pattern matching * Use isEmpty instead of 0 comparisons * Use lambdas * Use static inner classes * Use StandardCharsets Also adds the SA_LOCAL_SELF_COMPARISON suppression similar as used in other repositories for spotbugs/sonar-findbugs#876. Signed-off-by: Wouter Born <[email protected]>
@mpet I think you might be running into an issue with Eclipse's compiler producing redundant bytecode. When SpotBugs analyzes that bytecode it finds the SA_LOCAL_SELF_COMPARISON which is indeed in the compiled .class file. |
Issue Description
When running sonar rules on java code that has the following construct:
https://docs.oracle.com/en/java/javase/17/language/pattern-matching-instanceof-operator.html#GUID-843060B5-240C-4F47-A7B0-95C42E5B08A7
Sonarqube rule: findbugs:SA_LOCAL_SELF_COMPARISON
gives a false positive.
Environment
Code (If needed)
The text was updated successfully, but these errors were encountered: