Sha256: 8f75d373bc34fd2a728056781debeb4e6e3e820f9bc5d269fceb57f969fd2e18

Contents?: true

Size: 644 Bytes

Versions: 10

Compression:

Stored size: 644 Bytes

Contents

# encoding: utf-8

module Rubocop
  module Cop
    module Style
      # 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 CheckMethods
        include CodeLength

        private

        def message
          'Method has too many lines. [%d/%d]'
        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

10 entries across 10 versions & 1 rubygems

Version Path
rubocop-0.22.0 lib/rubocop/cop/style/method_length.rb
rubocop-0.21.0 lib/rubocop/cop/style/method_length.rb
rubocop-0.20.1 lib/rubocop/cop/style/method_length.rb
rubocop-0.20.0 lib/rubocop/cop/style/method_length.rb
rubocop-0.19.1 lib/rubocop/cop/style/method_length.rb
rubocop-0.19.0 lib/rubocop/cop/style/method_length.rb
rubocop-0.18.1 lib/rubocop/cop/style/method_length.rb
rubocop-0.18.0 lib/rubocop/cop/style/method_length.rb
rubocop-0.17.0 lib/rubocop/cop/style/method_length.rb
rubocop-0.16.0 lib/rubocop/cop/style/method_length.rb