-
-
Notifications
You must be signed in to change notification settings - Fork 821
Improve binding context management #5130
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
Improve binding context management #5130
Conversation
e12cc92 to
a278380
Compare
0264491 to
ec37d30
Compare
a278380 to
95be282
Compare
ec37d30 to
59f8919
Compare
95be282 to
0e37bf7
Compare
59f8919 to
7da777b
Compare
0e37bf7 to
c1bd249
Compare
|
🤔 |
c1bd249 to
46d79c9
Compare
46d79c9 to
608d49e
Compare
.../io/gitlab/arturbosch/detekt/authors/RequiresTypeResolutionRulesDoesNotRunWithoutAContext.kt
Fixed
Show fixed
Hide fixed
608d49e to
b41bbac
Compare
|
I like to idea of removing this boilerplate check, but:
|
No, there are more rules with mixed behavior. But those are not annotated with
I was thinking about that too. But that would force us to use reflection apis. I'm not against. It would be a way cleaner approach if we are fine with the usage of reflection. |
|
Why would we not use reflection? Because of a runtime performance penalty? |
To be honest, because I'm an Android developer and reflection is the devil there. But you are completely right, I don't see a good reason to don't use reflection here. That would make this rule completely useless and that's good! The code that doesn't exist doesn't have bugs :) I'm keeping this open for now but I'll open other PR implementing the reflection idea. If we merge the other one I'll close this one. |
| * | ||
| * <noncompliant> | ||
| * @@RequiresTypeResolution | ||
| * class MyRule(config: Config = Config.empty) : Rule(config) { |
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.
My 2 cents here: shouldn't we just instead have a Rule subclass or a parameter to the Rule constructor, or a property inside Rule that users can override?
While a generic visitCondition works, it does not prevent from rules accidentally using TR and forgetting to add the @RequiresTypeResolution annotation.
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.
While a generic visitCondition works, it does not prevent from rules accidentally using TR and forgetting to add the @RequiresTypeResolution annotation.
You are right. That is why #5148 is still needed
31fd7ef to
a231471
Compare
|
I'm closing this one. #5176 is clearly a better solution. |
This is the first step to work on #3577
We had different ways/places to disable a rule to don't run when it doesn't have a proper
bindingContext. But it wasn't a very efficient way because we were checking it while we where traversing the PSI tree.detekthas thisvisitConditionthat let to any rule to decide if it should be executed or not. This should be way more performant because we disable the rule before we start traversing the PSI tree.And the new rule ensures that we make this in a consistent way.
This PR uses the new
detekt-authorsmodule implemented on #5129