Skip to content
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

UnusedImports rule: fix false negative when same name identifiers are imported and used #3033

Merged
merged 1 commit into from
Aug 29, 2020

Conversation

t-kameyama
Copy link
Contributor

Fixes #3020

@codecov
Copy link

codecov bot commented Aug 29, 2020

Codecov Report

Merging #3033 into master will decrease coverage by 0.00%.
The diff coverage is 88.23%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3033      +/-   ##
============================================
- Coverage     79.16%   79.16%   -0.01%     
  Complexity     2543     2543              
============================================
  Files           434      434              
  Lines          7728     7737       +9     
  Branches       1466     1471       +5     
============================================
+ Hits           6118     6125       +7     
  Misses          824      824              
- Partials        786      788       +2     
Impacted Files Coverage Δ Complexity Δ
...lab/arturbosch/detekt/rules/style/UnusedImports.kt 86.88% <88.23%> (-1.58%) 4.00 <1.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 085adf0...933c726. Read the comment docs.

@t-kameyama t-kameyama force-pushed the issue_3020 branch 3 times, most recently from 6f99f9c to 1df460a Compare August 29, 2020 04:37
@arturbosch arturbosch added this to the 1.13.0 milestone Aug 29, 2020
@arturbosch arturbosch merged commit 6caf8ee into detekt:master Aug 29, 2020
@t-kameyama t-kameyama deleted the issue_3020 branch August 29, 2020 22:28
if (aliasName in (namedReferencesInKDoc + namedReferencesAsString)) return false
val identifier = identifier()
if (identifier in namedReferencesInKDoc) return false
return if (bindingContext == BindingContext.EMPTY) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is yet another rule where we're adding a mixed behavior based on Type Resolution: #2994

Ideally we should either:

  • Restrict this rule to work on TR only or
  • Remove the @requiresTypeResolution in the documentation as it's an overstatement
  • Revert this change and find a different solution that doesn't require TR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unused import not detected
4 participants