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



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

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

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

#min_body_length?(node) ⇒ Boolean

Returns:

  • (Boolean)


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

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