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
Add rule deprecation mechanism and deprecate DuplicateCaseInWhenExpression, MissingWhenCase, RedundantElseInWhen #5309
Conversation
|
...-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/config/validation/ConfigValidation.kt
Outdated
Show resolved
Hide resolved
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 that! Looks good!
I also prefer using the existing single file for this use case, as Nico mentioned.
...generator/src/main/kotlin/io/gitlab/arturbosch/detekt/generator/printer/DeprecatedPrinter.kt
Outdated
Show resolved
Hide resolved
97a901d
to
3f08963
Compare
Updated, and now it uses single file. |
detekt-generator/src/main/kotlin/io/gitlab/arturbosch/detekt/generator/collection/Rule.kt
Outdated
Show resolved
Hide resolved
...rone/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/DuplicateCaseInWhenExpression.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Nicola Corti <corti.nico@gmail.com>
…enerator/collection/Rule.kt Co-authored-by: Nicola Corti <corti.nico@gmail.com>
You'll have to suppress the deprecation locally inside
|
I did it like this, but it doesn't help @Suppress("DEPRECATION")
override fun instance(config: Config): RuleSet = RuleSet( |
I think you'll have to inline it: listOf(
AvoidReferentialEquality(config),
Deprecation(config),
DontDowncastCollectionTypes(config),
DoubleMutabilityForCollection(config),
@Suppress("DEPRECATION") DuplicateCaseInWhenExpression(config),
ElseCaseInsteadOfExhaustiveWhen(config),
EqualsAlwaysReturnsTrueOrFalse(config), |
You have more warnings:
|
14d7bad
to
2344934
Compare
Yes, that worked. Thanks! ?.map { if (it is KtAnnotatedExpression) it.lastChild as KtCallExpression else it } |
Right. |
You should be able to replicate locally with:
|
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.
I like your solution :)!
But I really think that we should not deprecate ElseCaseInsteadOfExhaustiveWhen
.
Can we also update the title of this PR mentioning which rule we deprecated? |
- Revert docs for 1.21.0 - Exclude ElseCaseInsteadOfExhaustiveWhen rule - Mark deprecated with Strikethrough font.
31702d6
to
77c61c3
Compare
Codecov Report
@@ Coverage Diff @@
## main #5309 +/- ##
===========================================
+ Coverage 0 85.84% +85.84%
- Complexity 0 3727 +3727
===========================================
Files 0 513 +513
Lines 0 12035 +12035
Branches 0 2232 +2232
===========================================
+ Hits 0 10331 +10331
- Misses 0 611 +611
- Partials 0 1093 +1093
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
LGTM Thank you so much for the contribution.
Close (#4973)
Exactly the same as.deprecation.properties
save for filenamedeprecation.rules
Uses
deprecation.properties
to write deprecated rules.