-
-
Notifications
You must be signed in to change notification settings - Fork 766
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
Lazy regex evaluation on Rules #1080
Conversation
Added a test verifying the lazy initialization behaviour when disabled and the proper failure when enabled.
0b4776d
to
c871551
Compare
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.
Looks good to me implementation-wise!
@@ -0,0 +1,29 @@ | |||
package io.gitlab.arturbosch.detekt.api.internal |
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.
Lets move this class out from internal as it will be used by detekt-rules
and maybe third party extensions.
Please add one sentence that key
and default
are actually used to retrieve a config property.
it("should not fail when disabled with faulty regex pattern") { | ||
val configValues = mapOf("active" to "false", LateinitUsage.IGNORE_ON_CLASSES_PATTERN to "*Test") | ||
val findings = LateinitUsage(TestConfig(configValues)).lint(code) | ||
assertThat(findings).hasSize(0) |
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.
You can use .isEmpty
here and above in the old code :)
@arturbosch updated with your feedback :) |
Thanks, feel free to add yourself to the readme and create additional PR with the more regex changes :) |
@arturbosch Added my name in README.md! You can merge this one and I will follow up with a new one for the rest of the Rules :) |
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 investigating and implementing this issue! Great work! :)
This PR resolves the eager Regex evaluation discussed in #1064
LazyRegex
class that evaluates aRegex
needed inside a rule, only when it is requested and only once.LazyRegex
inLateinitUsage
rule.@arturbosch I would be more than happy to migrate the rest of the
Regex
usages insideRule
s (if any) once you think this is a proper solution!