Module: RuboCop::Cop::MethodComplexity Private

Extended by:
Macros, ExcludeLimit
Includes:
IgnoredMethods, RuboCop::Cop::Metrics::Utils::RepeatedCsendDiscount
Included in:
RuboCop::Cop::Metrics::AbcSize, RuboCop::Cop::Metrics::CyclomaticComplexity
Defined in:
lib/rubocop/cop/mixin/method_complexity.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

This module handles measurement and reporting of complexity in methods.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ExcludeLimit

exclude_limit

Methods included from RuboCop::Cop::Metrics::Utils::RepeatedCsendDiscount

#discount_for_repeated_csend?, #reset_on_lvasgn, #reset_repeated_csend

Methods included from IgnoredMethods

#ignored_method?, #ignored_methods

Class Method Details

.included(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Ensure cops that include ‘MethodComplexity` have the config `attr_accessor`s that `ignored_method?` needs.



18
19
20
# File 'lib/rubocop/cop/mixin/method_complexity.rb', line 18

def self.included(base)
  base.extend(IgnoredMethods::Config)
end

Instance Method Details

#on_block(node) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
32
33
34
35
# File 'lib/rubocop/cop/mixin/method_complexity.rb', line 29

def on_block(node)
  define_method?(node) do |name|
    return if ignored_method?(name)

    check_complexity(node, name)
  end
end

#on_def(node) ⇒ Object Also known as: on_defs

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



22
23
24
25
26
# File 'lib/rubocop/cop/mixin/method_complexity.rb', line 22

def on_def(node)
  return if ignored_method?(node.method_name)

  check_complexity(node, node.method_name)
end