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.
Hello 👋
I want to revisit the idea we discussed in #196, as I really want to have some custom checkers in my project that are not ready to be upstreamed yet (e.g., #192).
Currently, I’m not sure how I can do that (reopening a processor class and redefining the
CHECKERS
constant maybe?). So I propose an approach that is heavily inspired by the RuboCop gem.What changed?
ColumnChecker
, it will be added toColumnsProcessor
; fromIndexChecker
toIndexesProcessor
, and so on.DefaultMessage
if the class is not found. This allows us to get rid ofSLUG_TO_WRITER
(something I attempted before in Dry simple writer #149). Most importantly, we can have simple writers for our custom checkers.require
. It works similarly to the one from RuboCop — you can require a checker or a whole gem (I haven’t tested the gem case).How does it work?
Here’s an example of integrating the checker from #192 into a dummy project:
That’s it; as you can see, the project-specific checker works as expected and prints our custom error message.
Final thoughts
I would love to hear everyone’s thoughts on this. I hope I can start having custom checkers in my project soon, whether with my proposed approach or something else.
If the proposed approach is acceptable, I can work on the documentation and extend the Rails examples in the repo to demonstrate custom checkers.
Thank you.