Class: Cane::AbcCheck::RubyAst

Inherits:
Struct
  • Object
show all
Defined in:
lib/cane/abc_check.rb

Overview

Wrapper object around sexps returned from ripper.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RubyAst

Returns a new instance of RubyAst.



67
68
69
70
# File 'lib/cane/abc_check.rb', line 67

def initialize(*args)
  super
  self.anon_method_add = true
end

Instance Method Details

#violationsObject



72
73
74
75
76
77
78
79
80
81
# File 'lib/cane/abc_check.rb', line 72

def violations
  process_ast(sexps).
    select {|nesting, complexity| complexity > max_allowed_complexity }.
    map {|x| {
      file:        file_name,
      label:       x.first,
      value:       x.last,
      description: "Methods exceeded maximum allowed ABC complexity"
    }}
end