uber / prototool

Your Swiss Army Knife for Protocol Buffers
MIT License
5.04k stars 345 forks source link

Build a "pluggable" lint rule #489

Open eleduardo opened 5 years ago

eleduardo commented 5 years ago

The linting rules that the tool ships with are extremely powerful and very flexible. I have run into the need of adding a couple more rules but instead of contributing the rules themselves as features I was thinking if it would be better to provide a 'plugin' model where a set of pluggable modules can be added to the tool from the consumer side and via the configuration the tool just invokes those plugins.

If the team feels this could be a valuable contribution I could start working on it and send a PR where we could start the discussion.

For configuration something like this could work

lint: group: uber2 ignores: .... rules: ..... pluggable:

Any concerns with implementing something like this?

smaye81 commented 5 years ago

I like this idea, but it is most likely a major change to allow a plugin model for rules, which I'd like to think through first. I'm up for discussion here though on how you see this working.

artbegolli commented 5 years ago

Would definitely be interested in something like this

eleduardo commented 5 years ago

Sorry for the delay, in the following weeks and I can try a prototype so that we can discuss with code... My idea was to use the built in plugin support in go to create a linter rule that can load module based on configuration passed in the lint secion of the yaml file. In the config you could create an array of modules each pointing to the .so module and passing some common key value pairs... Each module just implements the same set of interfaces and structures that the regular linters do.

I can prototype this in the form a of PR and start the discussion from there.