ViolatesTypeResolutionRequirements almost can't find itself #5443
TWiStErRob
started this conversation in
General
Replies: 1 comment 2 replies
-
Yes, the rule has potential false positives and negatives. I don't think we should change anything about it. I think this kind of issues force the limits of detekt and we should find ways to make detekt able to catch this issues. We should not model ourselfs to the detekt limitations. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@BraisGabin
ViolatesTypeResolutionRequirements
looks for usages ofbindingContext
. This is apparent most of the time. Except, with receivers, it's possible to write extension functions that hide this.There are two examples right in the file, which, if get refactored, will hide the fact that this rule is using
bindingContext
. (They're really nice reusable functions.)Repro: Try to move the two funs out of the file and make them non-private, then run
detektMain
->Even without context receiver this would be possible, the functions would just look uglier at the callsite.
I wanted to raise this false negative for awareness (you might've thought about it before), but I didn't raise this as an issue, because I think the rule is still good as a best effort. Maybe this needs to be documented on the rule, or support added for extensions? Alternatively this can be prevented by making
protected val bindingContext
so that extension functions can't see it. This would force rule writers to explicitly expose it.Beta Was this translation helpful? Give feedback.
All reactions