-
-
Notifications
You must be signed in to change notification settings - Fork 771
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
Refactor Analyzer so that RuleSetProvider.instance is only called once #3555
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3555 +/- ##
============================================
- Coverage 77.53% 77.52% -0.02%
Complexity 2829 2829
============================================
Files 464 464
Lines 8769 8769
Branches 1713 1713
============================================
- Hits 6799 6798 -1
- Misses 1046 1047 +1
Partials 924 924
Continue to review full report at Codecov.
|
Twice for each rule? We call it once per file and one more time when we instantiate the analyzer, right? And in this last one we don't care about the configuration because we just want to extract the ids. I imagine that this last part is not true for what you want to do with SARIF, right? All those calls to |
Agreed.
|
To make sure the idea is communicated properly:
|
@schalkms I am reverting this since this is for 1.17 release. We are probably waiting for Kotlin 1.4.32 so that we can release 1.16.1 |
@schalkms sorry again, my bad. Can you please reopen this changeset and tag it with a |
Background
I WTF'ed when debugging #3515. Also, my colleague @kkoser WTF'ed when working on a custom detekt rule.
Solution
The problem here is that we are not only calling RuleSetProvider.instance() twice for each rule, but the first time to generate
IdMapping
is even wrong because the top-level config instead ofconfig.subConfig(it.ruleSetId)
is passed to each ruleSet.To fix this, I have refactored the code to share
Sequence<>
to make sureRuleSetProvider.instance()
.(Technically, RuleSetProvider.instance() is called again in
:detekt-output-sarif/RuleDescriptors.kt
, but I am going to address this in #3554)