Add selectors API to Linter() for fast-path filtering#3052
Open
MichaelChirico wants to merge 8 commits into
Open
Add selectors API to Linter() for fast-path filtering#3052MichaelChirico wants to merge 8 commits into
MichaelChirico wants to merge 8 commits into
Conversation
Introduce a generic `selectors` API for token-based linter filtering. Linters can now declare a character vector of required tokens or symbols via the `selectors` argument in the `Linter()` constructor. The core dispatch loop in `lint_impl_` checks these selectors against the expression'\''s parse data (using fast vector matching) before running the linter, skipping it instantly if no match is found. Special `"BACKTICK"` selector is supported to handle R'\''s lack of a dedicated backtick token. Migrated 7 slow expression-level linters to this new API: - unreachable_code_linter - seq_linter - any_duplicated_linter - list_comparison_linter - string_boundary_linter - sort_linter - keyword_quote_linter TAG=agy CONV=3167de05-de65-467a-876c-a7dcf1003aab
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3052 +/- ##
=======================================
Coverage 99.25% 99.25%
=======================================
Files 128 128
Lines 7369 7382 +13
=======================================
+ Hits 7314 7327 +13
Misses 55 55 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Another optimization hit on by Gemini -- basically declaring a set of tokens without which we can skip running a linter. These tokens are necessary but not sufficient to find lints.
There is some decent overlap with #2449 -- for file-level linters, this approach is not quite so effective since the % of files skipped is less than the % of expressions skipped.
As of now, the rough improvement on just the linters currently included is about 35%:
I can extend it to more linters if we think this is a worthwhile addition.