Module: RuboCop::Cop::MethodComplexity
- Defined in:
- lib/rubocop/cop/mixin/method_complexity.rb
Instance Method Summary collapse
Instance Method Details
#check_complexity(node, method_name) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rubocop/cop/mixin/method_complexity.rb', line 12 def check_complexity(node, method_name) # Accepts empty methods always. return unless node.body max = cop_config['Max'] complexity = complexity(node.body) return unless complexity > max msg = format(class_msg, method: method_name, complexity: complexity, max: max) add_offense(node, message: msg) do self.max = complexity.ceil end end |
#class_msg ⇒ Object
6 7 8 9 10 |
# File 'lib/rubocop/cop/mixin/method_complexity.rb', line 6 def class_msg msg = self.class::MSG msg = self.class::YAYOI_MSG if msg.blank? msg end |