You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously imports like this were removed. But in some cases this would lead to code which no longer could be compile (see #2821). Therefore ktlint is rather conservative with removing the import. It is better to have an unused import compared to having code that cannot be compiled.
@paul-dingemans would you re-consider this decision and only do the safe path when there are ambiguous imports? In this case (this issue), there's a clear unused import with no risk of removal. I think #2821 only happens when there are imports with the same simple name.
Ktlint should take all lint/format decisions based on the file it scans only. It can not take into account any information which is to be retrieved from any other file.
We moved some classes around as a refactor and we ended up accidentally importing a class from the same package:
Steps to Reproduce
Production code (src/main/kotlin/foo/bar)
Test code (src/test/kotlin/foo/bar)
Expected Behavior
(
gradlew spotlessApply
)package foo.bar -import foo.bar.Production class ProductionTest { val subject = Production() }
Note: Android Studio shows it as unused.
Observed Behavior
No change.
Your Environment
.editorconfig
settings:ktlint_code_style = android_studio
The text was updated successfully, but these errors were encountered: