Skip to content

Detect unnecessary safe navigation #13835

@fatkodima

Description

@fatkodima

Annoyed by polluted code and people not understanding what safe navigation operator is and using it everywhere.
If it is known that a variable can't be nil, suggest removing useless safe navigation calls.

# bad
x = var.foo # <--- here, if var is nil, an error will be raised in any case
var&.bar    # <--- unnecessary safe navigation

# good
x = var.foo
var.bar

# bad
if var
  var&.foo
end

# good
if var
  var.foo
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions