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
Change the way we locate and filter Rules #1278
Comments
More information on possible api changes: In some other issue we discussed the overhead of creating all rules upfront and then filter the active ones. I see your point in creating the rules one time and reuse them. That was also the actual design. Have you benchmark'd the creation and filtering or was this just an idea? |
I agree with @arturbosch that a benchmark would make sense here. Either way, I think this is a topic which should be addressed after v1. |
I ran some benchmarks with and without the changes and there is no noticable performance impact. I also see the point of reusing rules and some of the problems that come with it. I'll close this issue. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics. |
Currently the
Detektor
will do the following during a run:KtFile
RuleSetProvider
sRuleSetProvider
which will visit all rules (or do test pattern filtering)However between one file and the next, the rules we want to run and the config will not change. We want to run each file over the same set of Rules. The test pattern is a slight exception here but the same still applies for each file that matches the test pattern.
My suggestion is: Instead of getting every single rule for every single file and doing active checks in the rules we could precompute the list of Rules we're interested in when we create the
Detektor
(and another list for the rules to run on the files matching the test pattern). Then we have all rules we care about and simply pass each file to each of the identified (and relevant) rules.I see two benefits in doing this:
KtFile
Detektor
some filtering inRuleSetProvider
(test pattern) and some filtering inRule
. If we would precompute the list of Rules we could handle the test pattern andactive
filtering in that component instead of spreading this out over multiple components.I played around with this a bit and this would essentially make
RuleSetProvider
just return it's list ofRule
s and theDetektor
would then operate on theRule
s directly instead of passing files to theRuleSetProviders
.I have a branch in which I tried this in a bit of a hacky way. If we agree that this might be worth pursuing I would continue working on it. (see: https://github.com/arturbosch/detekt/compare/master...Mauin:mr/rule_set_perf?expand=1
Detektor
andRuleManager
are the interesting classes)The text was updated successfully, but these errors were encountered: