Incorrect Warning "Kotlin:S1128 unnecessary import"

  • Operating system: Windows 11 Pro / 23H2 / 22631.3593
  • SonarLint plugin version: SonarLint
    (with. Android Studio 2023.3.1 Patch 1 / Build #AI-233.14808.21.2331.11709847)
  • Programming language you’re coding in: Kotlin
  • Kotlin Compiler Version : 1.9.0
  • Language Version & API Version : Latest stable (2.0) (same both)

And a thorough description of the problem / question:

In Kotlin code, Sonarlint plugin warning kotlin:S1128 for the below import:


This import is used in your code as follows:

Surface(modifier = modifier) {
        contentPadding = PaddingValues(horizontal = 8.dp
        modifier = modifier
    ) {
        items(subMenuCollectionData) { item ->
            Text(modifier = Modifier
                .clickable { onItemSelected(item.text) }

sonarlint_log.txt (64.1 KB)

If I remove the import statement import, the code will not compile because items is an extension function provided by the package, and it is necessary for the LazyColumn to work correctly with collections.
I think this issue might be similar to the one described in the following link: False-positive java:S1128 unnecessary import.