-
Notifications
You must be signed in to change notification settings - Fork 508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unused import when import is duplicated #1129
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
analog-alex
changed the title
Fix unsused import when import is duplicated
Fix unused import when import is duplicated
Mar 30, 2021
ktlint detects unused imports, such as: ``` import lib import lib2 // <- ktlint unused import rule is violated fun main() { lib.function(); } ``` However, when an import is duplicated -- and the duplicate import line is thus an unused import -- ktlint emits no rule violation. E.g: ``` import lib import lib // unused, but no violation fun main() { lib.function(); ``` This commit fixes that, emitting a rule violation when two imports have the same import path.
analog-alex
force-pushed
the
unused-duplicated
branch
from
March 30, 2021 13:29
9c6c5a7
to
06ad6ad
Compare
@analog-alex our dependency verification errors are fixed now. you should be able to revert the changes to |
Reverted! |
shashachu
added a commit
to shashachu/ktlint
that referenced
this pull request
Aug 6, 2021
- Used imports state has to be reset per-file
shashachu
added a commit
to shashachu/ktlint
that referenced
this pull request
Aug 6, 2021
- Used imports state has to be reset per-file - Allow repeated imports to be auto-corrected
shashachu
added a commit
that referenced
this pull request
Aug 6, 2021
romtsn
pushed a commit
to paul-dingemans/ktlint
that referenced
this pull request
Aug 8, 2021
* Fix unused import when import is duplicated ktlint detects unused imports, such as: ``` import lib import lib2 // <- ktlint unused import rule is violated fun main() { lib.function(); } ``` However, when an import is duplicated -- and the duplicate import line is thus an unused import -- ktlint emits no rule violation. E.g: ``` import lib import lib // unused, but no violation fun main() { lib.function(); ``` This commit fixes that, emitting a rule violation when two imports have the same import path. * Revert verification metadata * fix lint Co-authored-by: Yahor Berdnikau <[email protected]> Co-authored-by: Sha Sha Chu <[email protected]>
romtsn
pushed a commit
to paul-dingemans/ktlint
that referenced
this pull request
Aug 8, 2021
This reverts commit 3a43dbb.
romtsn
pushed a commit
to paul-dingemans/ktlint
that referenced
this pull request
Aug 8, 2021
* Fix regressions introduced in pinterest#1129 - Used imports state has to be reset per-file - Allow repeated imports to be auto-corrected * fix lint * Fix bad merge conflict * more merge fixes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
ktlint detects unused imports, such as:
However, when an import is duplicated -- and the duplicate import line is thus an unused import -- ktlint emits no rule violation.
IntelliJ treats it as a duplicate import ☝️
E.g:
This PR fixes that, emitting a rule violation when two imports have the same import path.
Checklist