Class: Rubocop::Cop::Style::SingleLineMethods

Inherits:
Cop
  • Object
show all
Defined in:
lib/rubocop/cop/style/single_line_methods.rb

Overview

This cop checks for single-line method definitions. It can optionally accept single-line methods with no body.

Constant Summary collapse

MSG =
'Avoid single-line method definitions.'

Instance Attribute Summary

Attributes inherited from Cop

#autocorrect, #corrections, #debug, #disabled_lines, #offences

Instance Method Summary collapse

Methods inherited from Cop

#add_offence, all, #autocorrect_action, cop_name, cop_type, #do_autocorrect, #ignore_node, inherited, #initialize, lint?, #name, rails?, style?

Constructor Details

This class inherits a constructor from Rubocop::Cop::Cop

Instance Method Details

#allow_empty?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/rubocop/cop/style/single_line_methods.rb', line 11

def allow_empty?
  SingleLineMethods.config['AllowIfMethodIsEmpty']
end

#on_def(node) ⇒ Object



15
16
17
# File 'lib/rubocop/cop/style/single_line_methods.rb', line 15

def on_def(node)
  check(node)
end

#on_defs(node) ⇒ Object



19
20
21
# File 'lib/rubocop/cop/style/single_line_methods.rb', line 19

def on_defs(node)
  check(node)
end