-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Expected behavior
Style/DoubleNegation provides EnforcedStyle: allowed_in_returns to allow double negation in contexts that use boolean as a return value.
It should allow all the following methods:
def foo?
!!@foo
end
def mixed_condition?
!!@foo && another_condition?
end
def long_condition?
!!@foo && one_long_long_condition? &&
another_long_long_condition?
end
def long_condition?
!!@foo &&
one_long_long_condition? &&
another_long_long_condition?
endActual behavior
It works with single-line conditions but rejects multi-lines conditions :
C: [Correctable] Style/DoubleNegation: Avoid the use of double negation (!!). (https://rubystyle.guide#no-bang-bang)
!!@foo && one_long_long_condition? &&
^
C: [Correctable] Style/DoubleNegation: Avoid the use of double negation (!!). (https://rubystyle.guide#no-bang-bang)
!!@foo &&
^
Steps to reproduce the problem
See expected behavior
RuboCop version
$ bundle exec rubocop -V
1.80.2 (using Parser 3.3.9.0, Prism 1.4.0, rubocop-ast 1.46.0, analyzing as Ruby 3.4, running on ruby 3.4.4) +server [arm64-darwin24]
- rubocop-performance 1.26.0
- rubocop-rails 2.33.3
- rubocop-rspec 3.7.0
- rubocop-factory_bot 2.27.1
- rubocop-capybara 2.22.1
- rubocop-rspec_rails 2.31.0