-
Notifications
You must be signed in to change notification settings - Fork 563
Add a RuleCollection object instead of a "loader" module #1063
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
Merged
Conversation
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
rw-access
commented
Mar 24, 2021
Co-authored-by: Justin Ibarra <[email protected]>
Co-authored-by: Justin Ibarra <[email protected]>
Co-authored-by: Justin Ibarra <[email protected]>
rw-access
commented
Apr 2, 2021
brokensound77
approved these changes
Apr 5, 2021
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.
LGTM, well done
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.
Issues
None, just refactoring
Summary
Follow up from #1029
Created a RuleCollection which is a mutable collection of rules. You can add directories, load from a dict, load from TOML and all the things we normally do, and rules get added to the collection. I don't want to use class methods on the collection, because you always load into a collection. So instead of saying "get me a collection for this directory", you can ask for a collection with
RuleCollection()
and then callload_directory
as a method on it. This gives more flexibility for what the caller can do.I also noticed that are a ton of functions that allow you to specify rule name, id or file.
And that seems like it adds some annoying complexity and I wonder if there's a better way to do it.
Maybe make every CLI function work on a file, because that works well for autocomplete and is the most intuitive. And we can add a few new functions to lookup a file by name or by ID. Then there's one extra step in the process, but it simplifies a lot of the code base.