Do you see this issue in SonarQube or Sonarcloud, if you’re using them too?
Not using any of those.
Could you please share the analysis log? (you can enable it in sonarlint, it’s not enabled by default)
Analysing 'ImportAlias.kt'...
Index files
1 file indexed
1 source file to be analyzed
1/1 source file has been analyzed
1 source file to be analyzed
1/1 source file has been analyzed
No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
0 source files to be analyzed
0/0 source files have been analyzed
Found 1 issue and 0 hotspots
Unfortunately, I’m still not able to reproduce the issue and Sonar should handle aliases correctly.
I can suggest checking if the issue is present in Kotlin 1.8 and only appears in 1.9 (as support for Kotlin 1.9 was added not so long ago and your SL version might still be missing it.). And could you, please, try the latest SonarLint version, and tell me if you still see the issue?
Also, do you have any additional configuration of your SonarLint plugin? This could also affect the analysis.
Margarita,
I checked with Kotlin 1.8 and 1.9 but the behavior remains same. There is no configuration change either. I also tried with fresh IDE setup and it is still reproducible. I have attached sample project for reference.
@kedarjoshi thanks again for the reproducer. I was able to find the issue. The thing is that you’re using the same package, and that’s why import is reported as “redundant”, not “unused”. I was missing it and that’s why I couldn’t reproduce the issue.
Yes, in your case import is necessary, because of an alias. So I created a ticket to fix the issue: