Sha256: 130100d7331b10079be5847a63131c46a90407f459b6d3993a21f26c03541e7e
Contents?: true
Size: 793 Bytes
Versions: 5
Compression:
Stored size: 793 Bytes
Contents
# encoding: utf-8 module RuboCop module Cop module Metrics # This cop checks if the length a method exceeds some maximum value. # Comment lines can optionally be ignored. # The maximum allowed length is configurable. class MethodLength < Cop include OnMethod include CodeLength private def on_method(node, _method_name, _args, _body) check_code_length(node) end def message(length, max_length) format('Method has too many lines. [%d/%d]', length, max_length) end def code_length(node) lines = node.loc.expression.source.lines.to_a[1..-2] || [] lines.reject! { |line| irrelevant_line(line) } lines.size end end end end end
Version data entries
5 entries across 5 versions & 2 rubygems