-
As we start integrating in Packwerk, we are wondering how you report violations to the dev. Our plan was during CI we'd like to parse the reports to let the devs know there is a package/privacy violation. Even a danger plugin could work as well, but they require a machine readable report. Has anyone needed this feature before? Line 119 in 0858c42 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
IIRC |
Beta Was this translation helpful? Give feedback.
-
Hey @silasb , Alex here from Gusto's Product Infrastructure team. We created the Packwerk VSCode Extension and as you said, we parse the output using regular expressions. We were also wondering if we can be able to pass in a This executes the CLI formatter = YourModule::YourFancyFormatter.new
style = Packwerk::OutputStyles::Coloured.new
Packwerk::Cli.new(style: style, offenses_formatter: formatter) This is an implementation of # typed: strict
# typed: strict
module YourModule
module YourFancyFormatter
extend T::Sig
include Packwerk::OffensesFormatter
sig { override.params(offenses: T::Array[T.nilable(Packwerk::Offense)]).returns(String) }
def show_offenses(offenses)
# Here you can do anything you want!
# If you want, you can just go right ahead and modify the offenses output to display in a way
# that is useful for the engineers at your company. Note that since we're dealing with in-memory
# representations of `Packwerk::Offense`, it's inherently machine readable.
# However, you can also serialize the array of `Packwerk::Offense` in a JSON format so that other
# systems can parse that however they want
end
end
end
end If we wanted packwerk to output JSON, then we could just implement a new formatter in packwerk that is switched to with the I'm curious though if this solution would work for you in an interim state as we learn more about what the JSON public interface should be. If this doesn't solve things, please share what's missing 🙏 |
Beta Was this translation helpful? Give feedback.
-
Just wanted to provide an update on this – you can now pass in your own custom offenses formatter without too much funny business! https://github.com/Shopify/packwerk/blob/main/USAGE.md#custom-offense-formatter |
Beta Was this translation helpful? Give feedback.
IIRC
packwerk check
returns machine readable output by default - should be rubocop compatible. That's the format that the VSCode extension uses.