class RuboCop::Cop::Metrics::AbcSize
(method calls), and conditions. See c2.com/cgi/wiki?AbcMetric<br>configured maximum. The ABC size is based on assignments, branches
This cop checks that the ABC size of methods is not higher than the
def complexity(node)
def complexity(node) assignment = 0 branch = 0 condition = 0 node.each_node do |child| if child.assignment? assignment += 1 elsif BRANCH_NODES.include?(child.type) branch += 1 elsif CONDITION_NODES.include?(child.type) condition += 1 end end Math.sqrt(assignment**2 + branch**2 + condition**2).round(2) end