Implement custom rule to check spek test discovery performance issues #2954
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new module
custom-checks
with for now one ruleSpekTestDiscovery
.This rule finds variable declarations in spek tests where
memoized
would help to improve the performance.All previous PR's improved the discovery time by ~200ms per module (500-1000ms in extreme cases like metrics and rules-style modules (parsing Kotlin files)).
In conclusion nearly every object we use to setup tests has to be considered as "heavy".
Exceptions are template strings and paths. I've excluded them from the rule.
Test frameworks like
Spek
which not only use reflection to find the tests but also need to instantiate a class and run the constructor closure are errorprone to such issues if one forgets to usememoized
or similar concepts.