rubocop -n runs Rubocop without coloring the output.
Rubocop runs with colors.
rubocop -n
0.47.1 (using Parser 2.4.0.0, running on ruby 2.3.1 x86_64-darwin15)
Here's what I found out. There was only --no-color option, without optional [no-] part. When --[no-]color was introduced, the shorthand version of this flag (-n) wasn't taken into account.
https://github.com/bbatsov/rubocop/commit/a5ce6dfe62c6411609d285e4befcc0fec28e9d57#diff-aabedc1d8225971d14fe2ceecc1be1e1
OptionParser just don't knows that -n is a negative flag:
require 'optparse'
option_parser = OptionParser.new do |cli|
cli.on('-n', '--[no-]color', 'Force color output on or off.') do |color|
p color
end
end
option_parser.parse(['--color'])
option_parser.parse(['--no-color'])
option_parser.parse(['-n'])
true
false
true
I suggest to drop this flag.
What do you think?
It looks like you found the reason for this issue already. It seems like the only options are to split this out so there is a --color option and a -n, --no-color option, or split it out so that we have a --[no-]color option and a -n option that sets no color. I am not sure which would be preferred or if anyone has another idea how to fix this. What are your thought @bbatsov?
I guess another other option could be to remove the -n flag since it seems like it has been broken for over a year, and as far as I know, this is the first that anyone has mentioned it.
I guess another other option could be to remove the -n flag since it seems like it has been broken for over a year, and as far as I know, this is the first that anyone has mentioned it.
Yeah, probably this functionality doesn't warrant having short option names at all.
@bbatsov may I submit PR that removes the short option?
@sadovnik PRs are always welcome. I don't think anyone has started this work, so I say go for it.
I guess another other option could be to remove the -n flag since it seems like it has been broken for over a year, and as far as I know, this is the first that anyone has mentioned it.
Yeah, probably this functionality doesn't warrant having short option names at all.
Agree. Also -n is not the most intuitive option for disabling color. 馃檪