We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The default setting of Style/InverseMethods includes:
Style/InverseMethods
Style/InverseMethods: InverseMethods: :any?: :none? :even?: :odd? :==: :!= :=~: :!~ :<: :>= :>: :<=
I would like to unset the :< and :> entries, as the inverse methods are not correct when comparing classes, e.g.
:<
:>
!(Integer < String)
is not equivalent to
Integer >= String
In reading #4289 as well as https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md#inheritance-of-hashes-vs-other-types my understanding is that i should be able to unset them with:
Style/InverseMethods: InverseMethods: :<: ~ :>: ~
I would expect the above to result in (via rubocop --show-cops):
rubocop --show-cops
Style/InverseMethods: InverseMethods: :any?: :none? :even?: :odd? :==: :!= :=~: :!~
Instead the result is:
Style/InverseMethods: InverseMethods: :any?: :none? :even?: :odd? :==: :!= :=~: :!~ :<: :>:
This will continue to erroneously flag code such as !(a < b) (which, in addition, is autocorrected to a b).
!(a < b)
a b
I have written a failing test to capture the desired behavior:
context 'when a file inherits and overrides a hash with nil' do let(:file_path) { '.rubocop.yml' } before do create_file('.rubocop_parent.yml', <<-YAML.strip_indent) Style/InverseMethods: InverseMethods: :any?: :none? :even?: :odd? :==: :!= :=~: :!~ :<: :>= :>: :<= YAML create_file('.rubocop.yml', <<-YAML.strip_indent) inherit_from: .rubocop_parent.yml Style/InverseMethods: InverseMethods: :<: ~ :>: ~ :foo: :bar YAML end it 'removes hash keys with nil values' do inverse_methods = configuration_from_file['Style/InverseMethods']['InverseMethods'] expect(inverse_methods).to eq( '==': :!=, '=~': :!~, any?: :none?, even?: :odd?, foo: :bar ) end end
0.67.2
The text was updated successfully, but these errors were encountered:
[Fix rubocop#6926] Allow nil values to unset config defaults
27080f6
[Fix #6926] Allow nil values to unset config defaults
fc0fe57
Successfully merging a pull request may close this issue.
The default setting of
Style/InverseMethods
includes:I would like to unset the
:<
and:>
entries, as the inverse methods are not correct when comparing classes, e.g.is not equivalent to
In reading #4289 as well as https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md#inheritance-of-hashes-vs-other-types my understanding is that i should be able to unset them with:
Expected behavior
I would expect the above to result in (via
rubocop --show-cops
):Actual behavior
Instead the result is:
This will continue to erroneously flag code such as
!(a < b)
(which, in addition, is autocorrected toa b
).Steps to reproduce the problem
I have written a failing test to capture the desired behavior:
RuboCop version
0.67.2
The text was updated successfully, but these errors were encountered: