jish / pre-commit

A slightly improved pre-commit hook for git
https://jish.github.io/pre-commit/
Other
796 stars 96 forks source link

Pass command line options to Rubocop #175

Closed padde closed 10 years ago

padde commented 10 years ago

The title says it all: Is it possible to pass command line options to Rubocop?

Specifically, we need to set --fail-level error, since we want everything less severe than an error not to prevent a commit. Unfortunately, Rubocop only provides this as a command line option, but not as an option in the YAML config file. Thanks!

padde commented 10 years ago

Maybe bbatsov/rubocop#1324 will fix the issue for us. Still, it would be useful to be able to pass command line arguments.

mpapis commented 10 years ago

hmm, we do not have support for extra flags, but you could add it quite easily somewhere around here: https://github.com/jish/pre-commit/blob/master/lib/plugins/pre_commit/checks/rubocop.rb#L24

@jish what do you think?

jish commented 10 years ago

Yea, I'm not sure what the correct solution is here. If you want team-wide configuration, then .rubycop.yml would be the best solution -- although, it looks like your specific option is not supported in their config file :(

We do support writing custom checks in config/pre-commit.rb. If you enable the local check, then you can run your own custom Ruby code, and all contributors to the project will run the same code, and it can be tracked using source control.

padde commented 10 years ago

@mpapis @jish sorry to bother you again. Have you decided yet how to proceed?

It's good to know that there's a plan B but going with the local check, we'd basically have to re-write and hard code the entire rubocop check for all of our projects, just to pass a command line flag. Of course we could make it into a gem, but all of this seems overkill :-(

I'd be happy to work on a PR, but only if this whole thing is even an option for you guys. Let me know what you think. Thanks!

mpapis commented 10 years ago

looks like rubocop can not decide on the ticket, I think we should be for adding extra command line flags - @jish what do you think?

@padde do you want to have have some fun with the PR or we should do it?

padde commented 10 years ago

@mpapis I'd be happy to give it a try ;-)

padde commented 10 years ago

@mpapis I've sent my PR, I think we can continue the discussion there, so feel free to close this issue.