29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/complexity.rb', line 29
def process
nobj, mscope = namespace, scope
if statement.tokens.to_s =~ /^def\s+(#{METHODMATCH})/m
meth = $1.gsub(/\s+/,'')
if meth =~ /(?:#{NSEPQ}|#{CSEPQ})([^#{NSEP}#{CSEPQ}]+)$/
mscope, meth = :class, $1
nobj = P(namespace, $`) unless $` == "self"
end
obj = MethodObject.new(nobj, meth, mscope)
obj[:complexity] = 1
statement.block.each do |token|
obj[:complexity] += 1 if BRANCH_TYPES.include?(token.class)
end
end
end
|