-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[Feature Request] Support add default argument in ~/.rubocop.yml #2253
Comments
like a function in bash shell, e.g. function rubocop () {
command rubocop -fe "$@"
} |
At this point it would be difficult to introduce a configuration parameter acting as "generic default command line options", because we've already added a lot of configuration parameters that are default values for individual CLI options:
But I do think it would be possible to add an |
thanks. AllCops: DefaultFormatter is good, I just hope can config more things |
I approve of this feature, I was just trying to implement it myself. |
One problem with that is that So what if you had multiple I am inclined to say that a shell alias would be the best thing for you. |
I would like to be able to set a default formatter. And especially when running rubocop as a rake task. "What if you had multiple values of DefaultFormatter?" Well, what if you have multiple values of any parameter? You must already have an order of precedence or enabling a cop in one place and disabling it in another would be very interesting. |
@apowers, there is a big difference. Most parameters make sense even if changed for each source file. And that is what RC does, if you have different RC config files in different subdirectories. The proposed Actually, the internal methods which select the formatter(s) to use don't even look at the paths to the files being checked. It shouldn't matter when selecting the formatter. |
@alexdowad What you say is correct, but there is a way to circumvent the problem posed by our per-directory configuration functionality. The trick is to say that a global config parameter like that is taken from the configuration for the current directory. I used it here when I faced a similar problem for Edit: Made the link robust by linking to a tagged version instead of master. |
@jonas054, OK, let me code something up. |
….yml The new config parameter can be used like: AllCops: DefaultFormatter: fuubar It is only applied once, close to the beginning of program execution. Whatever .rubocop.yml file applies within the working directory from which RuboCop is run, will decide what the default formatter is. Previously, setting formatters was the responsibility of Options. This doesn't work any more. It is not possible to load .rubocop.yml first, extract the value of DefaultFormatter, and then use it within Options. Why? Because the options affect how the config file is loaded, from where it is loaded, and so on. We can't load a config file until we first parse the options. Therefore, both the selection of a default formatter, as well as adding the formatter for --auto-gen-config, must be done after `Options#parse`.
Support add default argument in ~/.rubocop.yml, e.g. settings default formatter to emacs (-fe)
The text was updated successfully, but these errors were encountered: