-
-
Notifications
You must be signed in to change notification settings - Fork 777
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 reporting unused imports at file level #6390
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
schalkms
approved these changes
Aug 14, 2023
BraisGabin
approved these changes
Aug 16, 2023
cortinico
approved these changes
Aug 19, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this @arturbosch
Do we want to backport this to 1.x?
Yes please, this is a regression we introduced in 1.23.0 so I suggest a fix in 1.23.2 :) |
cortinico
added
the
pick request
Marker for PRs that should be ported to the 1.0 release branch
label
Aug 21, 2023
3flex
added a commit
to 3flex/detekt
that referenced
this pull request
Aug 31, 2023
Caused by detekt#6390 being merged after detekt#6397 without a rebase first
Merged
3flex
added a commit
that referenced
this pull request
Aug 31, 2023
cortinico
pushed a commit
that referenced
this pull request
Oct 30, 2023
mgroth0
pushed a commit
to mgroth0/detekt
that referenced
this pull request
Feb 11, 2024
mgroth0
pushed a commit
to mgroth0/detekt
that referenced
this pull request
Feb 11, 2024
Caused by detekt#6390 being merged after detekt#6397 without a rebase first
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
This PR was triggered by users of the IntelliJ plugin getting every unused import reported at the file level which clutters the editor: detekt/detekt-intellij-plugin#486 (comment)
This PR partly reverts the change to the emit logic of https://github.com/detekt/detekt/pull/5876/files#diff-9cf77f9ffcbf036bf5044d1ef99728b56aad97854246f3473f69d54b4b929380.
Emiting at the node is wrong in the case of the NoUnusedImports rule as in
beforeVisitChildNodes
the import usages are calculated and only reported inafterVisitChildNodes
from the file node (becausefileNode.imports
access is easy I suppose).With this revert the lines are again calculated with the offset function and lead to the same results as our MaxLineLength rule:
The other changed test cases are also now correct again e,g, the tested code for indentation rule is
val code = "fun main() {\n println()\n}"
so.hasStartSourceLocation(1, 13)
could not be correct due to the line breaks.Fixes #6105