Skip to content

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

Merged
arturbosch merged 1 commit into
detekt:masterfrom
t-kameyama:issue_3020
Aug 29, 2020
Merged

UnusedImports rule: fix false negative when same name identifiers are imported and used#3033
arturbosch merged 1 commit into
detekt:masterfrom
t-kameyama:issue_3020

Conversation

@t-kameyama

Copy link
Copy Markdown
Contributor

Fixes #3020

@codecov

codecov Bot commented Aug 29, 2020

Copy link
Copy Markdown

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
Copy Markdown
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