Class: RuboCop::Cop::Performance::Snif

Inherits:
Base
  • Object
show all
Defined in:
lib/rubocop/cop/performance/snif.rb

Overview

Prevent using ‘snif`. Consider using `detect`.

Examples:

# bad
period.equity_packs.snif(:code, 'ONCALL')

# good
period.equity_packs.detect { |equity_pack| equity_pack.code == 'ONCALL' }

Constant Summary collapse

MSG =
'Use `detect` instead.'

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



22
23
24
25
26
# File 'lib/rubocop/cop/performance/snif.rb', line 22

def on_send(node)
  return unless snif?(node)

  add_offense(node)
end