Module: RuboCop::Cop::CodeLength
- Includes:
- ConfigurableMax
- Included in:
- Style::ClassLength, Style::MethodLength
- Defined in:
- lib/rubocop/cop/mixin/code_length.rb
Overview
Common functionality for checking length of code segments.
Instance Method Summary collapse
- #check(node, *_) ⇒ Object
- #count_comments? ⇒ Boolean
-
#irrelevant_line(source_line) ⇒ Object
Returns true for lines that shall not be included in the count.
- #max_length ⇒ Object
Methods included from ConfigurableMax
Instance Method Details
#check(node, *_) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/rubocop/cop/mixin/code_length.rb', line 17 def check(node, *_) length = code_length(node) return unless length > max_length add_offense(node, :keyword, format(, length, max_length)) do self.max = length end end |
#count_comments? ⇒ Boolean
13 14 15 |
# File 'lib/rubocop/cop/mixin/code_length.rb', line 13 def count_comments? cop_config['CountComments'] end |
#irrelevant_line(source_line) ⇒ Object
Returns true for lines that shall not be included in the count.
28 29 30 |
# File 'lib/rubocop/cop/mixin/code_length.rb', line 28 def irrelevant_line(source_line) source_line.blank? || !count_comments? && comment_line?(source_line) end |
#max_length ⇒ Object
9 10 11 |
# File 'lib/rubocop/cop/mixin/code_length.rb', line 9 def max_length cop_config['Max'] end |