-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
Description
Expected behavior
Lint/SafeNavigationConsistency
should not occur.
Actual behavior
Lint/SafeNavigationConsistency
occurs.
Steps to reproduce the problem
user&.freeze && user == current_user
https://gist.github.com/nna774/ca3957f172424ac8a1a7e1b32ea48373
test.rb:3:17: W: Lint/SafeNavigationConsistency: Use . instead of unnecessary &..
user&.freeze && user == current_user
^^^^^^^^^^^^^^^^^^^^
2 files inspected, 1 offense detected
Similar to the second pattern( foo&.bar && foo.baz
), I think this should be considered good.
https://docs.rubocop.org/rubocop/cops_lint.html#examples-lintsafenavigationconsistency
RuboCop version
$ bundle exec rubocop -V
1.67.0 (using Parser 3.3.5.0, rubocop-ast 1.32.3, analyzing as Ruby 2.7, running on ruby 3.3.3) [arm64-darwin23]
yuiseki