A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rubocop/rubocop/issues/13835 below:

Detect unnecessary safe navigation · Issue #13835 · rubocop/rubocop · GitHub

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4