Skip to content

false positive Lint/SafeNavigationConsistency #13365

@nna774

Description

@nna774

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy