Class: Ducalis::Recursion

Inherits:
RuboCop::Cop::Cop
  • Object
show all
Defined in:
lib/ducalis/cops/recursion.rb

Constant Summary collapse

OFFENSE =
<<-MESSAGE.gsub(/^ +\|\s/, '').strip
  It seems like you are using recursion in your code. In common, it is not a bad idea, but try to keep your business logic layer free from refursion code.
MESSAGE

Instance Method Summary collapse

Instance Method Details

#on_def(node) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/ducalis/cops/recursion.rb', line 11

def on_def(node)
  @method_name, _args, body = *node
  return unless body
  return unless send_call?(body) || send_self_call?(body)

  add_offense(node, :expression, OFFENSE)
end