-
Notifications
You must be signed in to change notification settings - Fork 113
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
Configurable parsers (continued) #375
base: main
Are you sure you want to change the base?
Configurable parsers (continued) #375
Conversation
Co-authored-by: Davis Namsons <davisnamsons@gmail.com>
I have signed the CLA! |
I had some tests failing sporadically, so I've managed to surface three different failure modes with the seeds: I still need to track down the root cause, but the default parsers aren't registered in seeds Unfortunately, I haven't had time to dig into it. Hopefully I'll get to it on the weekend |
@richardmarbach 1. Remove
|
Thanks for looking into it, @euglena1215! Those fixes resolved the outstanding issues with the tests. |
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.
Please let me help get this pull request merged!
I have suggested several fixes, but I'm not a committer. So I'll leave the revision policy to you.
Hi @gmcgibbon ! Is there any information missing to review this pull request? I would like to provide that support! |
I'm also interested in using the Packwerk HAML plugin! Is there anything else needed for this pull request? or is it just waiting for review? |
Co-authored-by: Davis Namsons davisnamsons@gmail.com
Due to stalled activity in #243, I took liberty and completed the change requests from #243 (comment)
Due to messy merge conflicts, I decided to redo the feature with a fresh commit history. I co-authored @dnamsons, as he did most of the hard work!
This is the first time I've used minitest, so I'd love some feedback on my usage. The rest of the PR body is a copy of the original.
What are you trying to accomplish?
As discussed on #142, this change allows for additional parsers to be added.
This also allows extracting the erb parser out of packwerk(which might be desired - #142 (comment)).
What approach did you choose and why?
modified the
Packwerk::Parsers::Factory
class to store parsers in an instance variable and made this variable modifiable via the use of anattr_accessor
.moved the regex constants into their respective parser classes and added a new method
.match?
to each parser class which verifies if a given path is relevant to the parser.changed
Packwerk::Parsers::Factory#for_path
to iterate through the defined parsers to find a parser whosematch?
method returns true.I considered multiple different alternatives to how new parsers can be defined(and the existing ones removed) but could not land on a satisfactory solution, so I stuck with the simplest one in hopes I could get some advice on how best to proceed.
Currently every parser is initialized anew for every new file that matches with its regex. I considered either storing already initialized parser instances in the
parsers
instance variable or, alternatively, creating a sort of a "cache" of parser instances but wasn't sure on which would be preferable.What should reviewers focus on?
As mentioned above, my current approach to the the configuration of parsers is simplistic, I would appreciate any input on how to make this be more in line with the general structure of packwerk.
Type of Change
Additional Release Notes
Checklist