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

[VarCouldBeVal] Override vars will not be flagged if bindingContext is not set #4477

Merged

Conversation

severn-everett
Copy link
Contributor

This addresses issue #4474

Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

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

I think we should ship this change as it is, but instead add a:

if(bindingContext == BindingContext.EMPTY) return`

statement inside the visitKtFile method on top of this class. The problem is that this rule is a rule annotated with @RequiresTypeResolution, but failing to add early return statement is allowing to run this rule without TR.

This is a bit of a bummer as this rule is now a mixed rule (see #2994) which I believe it should have never been (see #3880)

@BraisGabin
Copy link
Member

Cortinico is right, I was mistaken here.

We should just disable the rule and honor the annotation. Something like adding

if (bindingContext == BindingContext.EMPTY) return

should do the trick

@codecov
Copy link

codecov bot commented Jan 20, 2022

Codecov Report

Merging #4477 (c366477) into main (a9c38b8) will decrease coverage by 0.22%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #4477      +/-   ##
============================================
- Coverage     84.32%   84.10%   -0.23%     
- Complexity     3298     3306       +8     
============================================
  Files           473      473              
  Lines         10591    10794     +203     
  Branches       1907     1994      +87     
============================================
+ Hits           8931     9078     +147     
- Misses          675      688      +13     
- Partials        985     1028      +43     
Impacted Files Coverage Δ
...lab/arturbosch/detekt/rules/style/VarCouldBeVal.kt 83.50% <100.00%> (-4.00%) ⬇️
...osch/detekt/rules/bugs/UselessPostfixExpression.kt 71.73% <0.00%> (-0.99%) ⬇️
...urbosch/detekt/rules/performance/ArrayPrimitive.kt 74.19% <0.00%> (-0.81%) ⬇️
.../arturbosch/detekt/rules/style/CanBeNonNullable.kt 72.61% <0.00%> (-0.52%) ⬇️
.../arturbosch/detekt/formatting/wrappers/Filename.kt 100.00% <0.00%> (ø)
...urbosch/detekt/formatting/wrappers/FinalNewline.kt 100.00% <0.00%> (ø)
...sch/detekt/formatting/wrappers/ModifierOrdering.kt 100.00% <0.00%> (ø)
...ch/detekt/formatting/wrappers/MaximumLineLength.kt 100.00% <0.00%> (ø)
...turbosch/detekt/rules/style/UnusedPrivateMember.kt 92.81% <0.00%> (+0.13%) ⬆️
... and 2 more

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 a9c38b8...c366477. Read the comment docs.

@cortinico cortinico changed the title Override vars will not be flagged if bindingContext is not set [VarCouldBeVal] Override vars will not be flagged if bindingContext is not set Jan 28, 2022
@cortinico cortinico added this to the 1.20.0 milestone Jan 28, 2022
@cortinico cortinico merged commit 8a39d2a into detekt:main Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants