Sha256: 573f34985c311e7fe2812933b1e8dcd97901ed200fb2fd8a5269eb0b778ffa76
Contents?: true
Size: 800 Bytes
Versions: 11
Compression:
Stored size: 800 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 OnMethodDef include CodeLength private def on_method_def(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
11 entries across 11 versions & 1 rubygems