False-Positive in kotlin:S1128

Must-share information:

  • SonarQube Enterprise v9.9.5 (build 90363)
  • SonarQube Gradle Plugin 5.0.0.4638
  • I do not know how it is deployed, if relevant for this issue, I can inquire this information from my IT dept

I looked through the public issue tracker and could not find a similar issue, so here I go, if this is not the right place to place this please do point me in a direction as I could not find another obvious place to report it to.

As the title says its about a false-positive in rule kotlin:S1128 “Unnecessary imports should be removed” when using this import from Jetbrains Compose:
import androidx.compose.runtime.getValue
or
import androidx.compose.runtime.setValue

The imports are necessary according to the compiler for using e.g.
androidx.compose.foundation.interaction.collectIsPressedAsState (see PressInteraction.kt:84 in Compose; requires getValue import)
or
androidx.compose.runtime.remember (see Composables.kt:24 in Compose; requires setValue import).

Thank you. If I can add any other information to help anyone in fixing this issue, please let me know.

Hey there.

They definitely do apply! And the most important value, the SonarQube version, should be easily found in the footer of your SonarQube instance.

Hey Colin, thank you for your answer and info regarding version. I will add the info I can find to the first post.

Hello Timon,

Thanks for the report. This is indeed an issue with our Kotlin analyzer in your version of SonarQube.

The good news is that this issue is fixed in newer versions of the analyzer, deployed starting in SonarQube 10.1. Your SonarQube version will need to be upgraded for you to receive this fix. If you can’t do this right now and the rule is too noisy, you can also disable it until your SonarQube is upgraded.

1 Like

Thanks for the answer Johann, happy to hear. Must have missed that issue in the tracker somehow, I will try to be more thorough in my search next time.

1 Like