Repository navigation
[VarCouldBeVal] fix overrides false positives - #4664
Conversation
marschwar
left a comment
There was a problem hiding this comment.
Thank you for submitting the PR.
While I agree, that a lateinit var can never really become a val, I think the underlying issue here is the magic done by the framework. To detekt the variable never changes its value and therefor it could be val. Therefor changing your config to
VarCouldBeVal:
active: true
ignoreAnnotated: ['Inject']would in my opinion also be a valid fix.
Long story short - I think your approach here is valid. The issue that a private lateinit var is never assigned a value should be handled by a different rule.
Codecov Report
@@ Coverage Diff @@
## main #4664 +/- ##
=========================================
Coverage 84.58% 84.58%
Complexity 3434 3434
=========================================
Files 492 492
Lines 11329 11329
Branches 2058 2058
=========================================
Hits 9583 9583
Misses 701 701
Partials 1045 1045
Continue to review full report at Codecov.
|
f8b505c to
8d81554
Compare
I ended up doing this workaround for the Inject annotation as this was the main issue in one of our project. But there are many frameworks that rely on an annotation and a |
|
I don't think that we should ignore |
|
@meriouma Could you please change this PR to address the issue with I can see the arguments on either side. Since there is an easy workaround for your specific problem I would also not change it at the moment. Maybe this becomes a pattern and we could change it in the future. |
8d81554 to
85a6e3d
Compare
|
@marschwar Done! |
|
@marschwar Sure, no problem. I can rebase and rewrite the test case once #4575 is merged. |
85a6e3d to
b65dbd5
Compare
|
I've rebased and updated the test. |
I'm not sure this is correct as this seems a simple check, but this fixes #4661 and does not break other tests.