Skip to content
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

Allow extension system to load in custom OffensesFormatter #264

Closed
wants to merge 3 commits into from

Conversation

alexevanczuk
Copy link
Contributor

What are you trying to accomplish?

Today, packwerk supports a configurable OffensesFormatter. 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 run bundle binstubs packwerk. Instead, the user needs to copy exe/packwerk into their local bin/packwerk and pass in a different formatter to Packwerk::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 in packwerk.yml to load in a formatter via a setting on Packwerk::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

  • Bugfix
  • New feature
  • Non-breaking change (a change that doesn't alter functionality - i.e., code refactor, configs, etc.)

Checklist

  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • It is safe to rollback this change.

@alexevanczuk alexevanczuk requested a review from a team as a code owner November 17, 2022 16:52
@alexevanczuk
Copy link
Contributor Author

I thought of an alternate implementation I think may be better. A --format option that matches on the name of a formatter. Then packwerk yml can specify the default. I'll put up a different PR later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant