class RuboCop::Cop::Metrics::ModuleLength
Checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
You can set literals you want to fold with `CountAsOne`. Available are: 'array', 'hash', and 'heredoc'. Each literal will be counted as one line regardless of its actual size.
@example CountAsOne: ['array', 'heredoc']
module M ARRAY = [ # +1 1, 2 ] HASH = { # +3 key: 'value' } MSG = <<~HEREDOC # +1 Heredoc content. HEREDOC end # 5 points
Public Instance Methods
on_casgn(node)
click to toggle source
# File lib/rubocop/cop/metrics/module_length.rb, line 39 def on_casgn(node) module_definition?(node) { check_code_length(node) } end
on_module(node)
click to toggle source
# File lib/rubocop/cop/metrics/module_length.rb, line 35 def on_module(node) check_code_length(node) end
Private Instance Methods
message(length, max_length)
click to toggle source
# File lib/rubocop/cop/metrics/module_length.rb, line 50 def message(length, max_length) format('Module has too many lines. [%<length>d/%<max>d]', length: length, max: max_length) end