2

Basically my question is: Is this a sonarqube bug or incorrect configuration? (The reported errors are from findbugs, this example is: findbugs:RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE) Sonar screenshot

What is my setup:

  • Sonarqube 7.5 with a Kotlin (company wide) profile and a Java (company wide) profile enabled for my project
  • Gradle 5.4 project with both Kotlin 1.3 and Java 11

I did not expect to see this findbugs warning in my Kotlin code, as the check that produces this warning is part of the Java profile.

To the best of my knowledge I cannot configure which profile to apply to which part of my code in de Gradle configuration. It happens automagically in Sonarqube.

So the next approach was to suppress the warnings. Both @Suppress from Kotlin and @SuppressWarnings from Java fail to suppress the issue.

Edit: That is the topic of SonarQube: How to suppress a warning in Kotlin code. Recent updates may yield different results. If that helps I’ll update.

Any tips on how to remove these Sonar issues from my project? I would prefer keeping the findbugs checks enabled.

Michiel Leegwater
  • 1,172
  • 4
  • 11
  • 27
  • Do you understand why this warning is appearing? I am seeing a similar warning on lateinit vars and wondered if you knew what was causing this and how to fix or suppress? Did you even get a solution?? – adrem7 Mar 18 '21 at 22:47
  • Alas, as far as I know there is no solution yet. It seems to me that it is a problem in sonar where the Java rules are applied to Kotlin. My guess is that the warnings are based on the bytecode. The bytecode for Kotlin is optimized on the premise that the compiler insures the issues detected by sonar will not occur. Suppression of these warnings has thus far failed. Amending the rule set was deemed too drastic in my case. – Michiel Leegwater Mar 20 '21 at 08:46
  • I think I agree that it's based on the bytecode as well. Our only "solution" to this was to have someone mark these issues as a false positive in SQ so they don't show up on our metrics. – adrem7 Apr 27 '21 at 11:23

0 Answers0