Class: RuboCop::Cop::Style::DisallowSafeNavigation

Inherits:
RuboCop::Cop
  • Object
show all
Extended by:
TargetRubyVersion
Defined in:
lib/rubocop/cop/style/disallow_safe_navigation.rb

Overview

The “safe navigation” operator &. makes it easier to work with and propagate nil values. This will disallow the safe navigation operator

Examples:


# bad
foo&.bar
a.foo&.bar

Constant Summary collapse

MSG =
'Do not use &.'.freeze

Instance Method Summary collapse

Instance Method Details

#on_csend(node) ⇒ Object



20
21
22
# File 'lib/rubocop/cop/style/disallow_safe_navigation.rb', line 20

def on_csend(node)
  add_offense(node)
end