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