Module: RuboCop::Cop::MinBodyLength

Included in:
Style::GuardClause, Style::Next
Defined in:
lib/rubocop/cop/mixin/min_body_length.rb

Overview

Common functionality for checking minimum body length.

Instance Method Summary collapse

Instance Method Details

#min_body_lengthObject



12
13
14
15
16
17
# File 'lib/rubocop/cop/mixin/min_body_length.rb', line 12

def min_body_length
  length = cop_config['MinBodyLength'] || 1
  return length if length.is_a?(Integer) && length > 0

  raise 'MinBodyLength needs to be a positive integer!'
end

#min_body_length?(node) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/rubocop/cop/mixin/min_body_length.rb', line 8

def min_body_length?(node)
  (node.loc.end.line - node.loc.keyword.line) > min_body_length
end