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
ElseCaseInsteadOfExhaustiveWhen - Add ignoredSubjectTypes config key (#5623) #5634
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5634 +/- ##
============================
============================
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 👍
...ne/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ElseCaseInsteadOfExhaustiveWhen.kt
Outdated
Show resolved
Hide resolved
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
...ne/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ElseCaseInsteadOfExhaustiveWhen.kt
Fixed
Show fixed
Hide fixed
...ne/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ElseCaseInsteadOfExhaustiveWhen.kt
Fixed
Show fixed
Hide fixed
...ne/src/main/kotlin/io/gitlab/arturbosch/detekt/rules/bugs/ElseCaseInsteadOfExhaustiveWhen.kt
Fixed
Show fixed
Hide fixed
@mmorozkov I initially created this rule and I really like the addition in this PR. The new config property is especially useful for LGTM |
@cortinico |
@@ -70,6 +79,10 @@ class ElseCaseInsteadOfExhaustiveWhen(config: Config = Config.empty) : Rule(conf | |||
if (whenExpression.elseExpression == null) return | |||
|
|||
val subjectType = subjectExpression.getType(bindingContext) | |||
if (ignoredSubjectTypes.contains(subjectType?.fqNameOrNull().toString())) { |
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.
nit:
if (ignoredSubjectTypes.contains(subjectType?.fqNameOrNull().toString())) { | |
if (ignoredSubjectTypes.contains(subjectType?.fqNameOrNull()?.toString())) { |
I don't know what contains
thinks about null
. But checking for "null"
doesn't seem 100% correct.
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.
Done!
Could you check comment? Once that is addressed I think that this is good to go. |
A new `ignoredSubjectTypes` property with an empty default value was introduced. It can be configured with a list of subject types fully qualified names which should be ignored by the `ElseCaseInsteadOfExhaustiveWhen` rule.
@BraisGabin Done! |
@BraisGabin anything left to do there? Otherwise, we should get this merged for inclusion in the detekt next version. |
@BraisGabin @schalkms @cortinico guys is there anything that block this one from being merged? |
@mmorozkov No blockers left. I'll merge this. If @BraisGabin has anything to add, we will create a new PR. |
A new
ignoredSubjectTypes
property with an empty default value was introduced. It can be configured with a list of subject types fully qualified names which should be ignored by theElseCaseInsteadOfExhaustiveWhen
rule.Fixes #5623