Allow extension system to load in custom OffensesFormatter #264
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.
What are you trying to accomplish?
Today,
packwerk
supports a configurableOffensesFormatter
. However, the only way to configure it is to load the CLI itself. This means that this feature is not usable if a user has runbundle binstubs packwerk
. Instead, the user needs to copyexe/packwerk
into their localbin/packwerk
and pass in a different formatter toPackwerk::Cli.new
.This PR makes this more user-friendly by leveraging the extension system to load in a new formatter. This way, a user can use the vanilla
packwerk
binstub and load in their own offenses formatter more easily.What approach did you choose and why?
I chose to use the
require
directive inpackwerk.yml
to load in a formatter via a setting onPackwerk::Configuration
. The system first prioritizes the local input variable, then the configuration, then the default formatter.What should reviewers focus on?
Is there a more ideal API to set the custom formatter? Is there any reason we wouldn't want to encourage this via the extension system?
Type of Change
Checklist