class RuboCop::Cop::Metrics::MethodLength
Checks if the length of a method exceeds some maximum value. Comment lines can optionally be allowed. The maximum allowed length is configurable.
You can set constructs you want to fold with ‘CountAsOne`.
Available are: ‘array’, ‘hash’, ‘heredoc’, and ‘method_call’. Each construct will be counted as one line regardless of its actual size.
NOTE: The ‘ExcludedMethods` and `IgnoredMethods` configuration is deprecated and only kept for backwards compatibility. Please use `AllowedMethods` and `AllowedPatterns` instead. By default, there are no methods to allowed.
@example CountAsOne: [‘array’, ‘hash’, ‘heredoc’, ‘method_call’]
def m array = [ # +1 1, 2 ] hash = { # +1 key: 'value' } <<~HEREDOC # +1 Heredoc content. HEREDOC foo( # +1 1, 2 ) end # 4 points
Constants
- LABEL
Public Instance Methods
on_block(node)
click to toggle source
# File lib/rubocop/cop/metrics/method_length.rb, line 57 def on_block(node) return unless node.method?(:define_method) check_code_length(node) end
Also aliased as: on_numblock
on_def(node)
click to toggle source
# File lib/rubocop/cop/metrics/method_length.rb, line 50 def on_def(node) return if allowed_method?(node.method_name) || matches_allowed_pattern?(node.method_name) check_code_length(node) end
Also aliased as: on_defs
Private Instance Methods
cop_label()
click to toggle source
# File lib/rubocop/cop/metrics/method_length.rb, line 66 def cop_label LABEL end