-
-
Notifications
You must be signed in to change notification settings - Fork 755
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
Core handles active rules #6782
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6782 +/- ##
=========================================
Coverage 84.94% 84.95%
+ Complexity 3890 3887 -3
=========================================
Files 573 574 +1
Lines 12910 12913 +3
Branches 2445 2443 -2
=========================================
+ Hits 10967 10970 +3
Misses 721 721
Partials 1222 1222 ☔ View full report in Codecov by Sentry. |
8aa35d8
to
d5f3264
Compare
d5f3264
to
a6e84d0
Compare
a6e84d0
to
c9593e9
Compare
c9593e9
to
82cdad8
Compare
82cdad8
to
fe83a9a
Compare
fe83a9a
to
433e3b8
Compare
433e3b8
to
24ea51a
Compare
24ea51a
to
3ccd34c
Compare
3ccd34c
to
27410f3
Compare
27410f3
to
863a91e
Compare
...kt-formatting/src/test/kotlin/io/gitlab/arturbosch/detekt/formatting/AutoCorrectLevelSpec.kt
Fixed
Show fixed
Hide fixed
863a91e
to
54894b1
Compare
@@ -11,8 +11,7 @@ import io.gitlab.arturbosch.detekt.api.internal.createPathFilters | |||
import io.gitlab.arturbosch.detekt.core.ProcessingSettings | |||
import org.jetbrains.kotlin.psi.KtFile | |||
|
|||
fun Config.isActive(): Boolean = | |||
valueOrDefault(Config.ACTIVE_KEY, true) | |||
internal fun Config.isActive(default: Boolean): Boolean = valueOrDefault(Config.ACTIVE_KEY, default) |
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.
Could we rename this to isActiveOrDefault
?
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.
Also the location of the method is a bit misleading. The file is RuleSets
but it is an extension on Config that is used in the context of rules, rulesets and processors.
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 are right with both comments. I did the changes.
* Rules doesn't handle if they are active or not * rename isActive to isActiveOrDefault --------- Co-authored-by: marschwar <marschwar@users.noreply.github.com>
Until now core said to all the rules to execute, even if they were disabled, and then the rules decide if they should execute or not looking at their own configuration.
This PR changes that. Now the rule doesn't know if it is active or not. Now the core checks if a rule is active or not and decide what to do. This simplifies a bit more the
Rule
API. Also, this is not the final PR in this regard. The suppression is right now handled by the rule and I would like to move that tocore
too. But that will be done later.This comes with a bonus:
Config.empty
is finally "empty". Until now it was empty except for theactive
parameter. That one always returnedtrue
instead of the expectednull
.Also, I was looking how to test this and I found out that the tests were there already. That's the reason I created #6781 I was just looking how to test this and refactor those tests when I found out that this was already tested.