Module: RuboCop::Cop::MethodComplexity
- Includes:
- ConfigurableMax
- Included in:
- RuboCop::Cop::Metrics::AbcSize, RuboCop::Cop::Metrics::CyclomaticComplexity, RuboCop::Cop::Metrics::PerceivedComplexity
- Defined in:
- lib/rubocop/cop/mixin/method_complexity.rb
Overview
This module handles measurement and reporting of complexity in methods.
Instance Method Summary collapse
- #on_def(node) ⇒ Object (also: #on_defs)
Methods included from ConfigurableMax
Instance Method Details
#on_def(node) ⇒ Object Also known as: on_defs
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rubocop/cop/mixin/method_complexity.rb', line 9 def on_def(node) max = cop_config['Max'] complexity = complexity(node) return unless complexity > max add_offense(node, :keyword, format(self.class::MSG, node.method_name, complexity, max)) do self.max = complexity.ceil end end |