Unused import false positives (still)

We just migrated from SonarQube 8.9 LTS to 9.9 LTS. We use the default ruleset and the latest Gradle plugin ( After the migration we see a lot of false positives for imports for delegation functions which were already covered in these issues (import androidx.compose.runtime.getValue):

Is this a regression or are the fixes (SONARKT-139, SONARKT-182) not shipped?

I tried to check which SonarKotlin version we are using (build into 9.9 I guess?), but was not able to find out.


Can you provide a compact reproducer: import and use?


Hi @ganncamp,

it’s the exact same issue as mentioned in kotlin:S1128 False Positive Jetpack Compose with the same minimal code sample: kotlin:S1128 False Positive Jetpack Compose

Since we are using SonarQube 9.9 LTS selfhosted, is there a chance that some of the rules are outdated? How can I verify that we are using the latest ones?

Hello @G00fY2,

Thanks for your message. I need a bit more information to be able to investigate the issue:

  1. Is it happening on SQ or in SL? As you’re talking about SonarQube and the thread you’re referencing is about SonarLint. If it’s SonarLint, is it connected mode or not?
  2. Could you, please, share the analysis configuration?
  3. Could you, please, share the analysis log?
  4. Are you mixing Java & Kotlin code?
  5. Have you changed the values of the properties sonar.java.libraries and sonar.java.binaries?


@Margarita_Nedzelska @ganncamp

  1. The issue is happening on SQ (Version 9.9 (build 65466)) and SonarLint IDEA plugin
  2. We have no special analysis configuration in place and the configuration is generally working flawlessly in our multi module Android project.
  3. Where can I get this log from? I am also not sure if I can share this.
  4. All modules are Kotlin only.
  5. We do not set these properties

The issue is also happening in the IDE when using latest stable Android Studio (2022.1.1 Patch 2) with SonarLint This issue is super easy to reproduce. You can simply create an “Empty Compose Activity” project in the default “New project” wizard of Android studio. In there add a Compose delegation function, e.g.:

var test by remember { mutableStateOf(false) }

The result will be false-positive warnings about unused imports:

Hello @G00fY2,

Thanks for the reproducer. I was able to reproduce the issue. I need some time to investigate why this is happening and under which circumstances. Will get back to you with an explanation, a ticket, and maybe a workaround, if possible.


1 Like

@Margarita_Nedzelska thanks for your quick response.

For the time being we disabled this rule, sine we also rely on other CI checks (in our case detekt) for unused imports in Kotlin.

But we are looking forwards for this fp to be fixed, as it adds noise when using the IDE plugin and generally disabling rules should be avoided.

1 Like

Hello @G00fY2,

I found the root cause of the issue and a possible solution. Took me some time to figure it out :slight_smile:

Anyway, here is the ticket: [SONARKT-307] - Jira

The fix is trivial, so we’ll try to fix it with the next release as we’re currently working on the Kotlin analyzer.

If you want to get the fix, you have to be on the latest SonarQube or SonarCloud as we’re not backporting FPs to the LTS.



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.