Class: SugarCane::AbcCheck::RubyAst
- Inherits:
-
Struct
- Object
- Struct
- SugarCane::AbcCheck::RubyAst
- Defined in:
- lib/sugarcane/abc_check.rb
Overview
Wrapper object around sexps returned from ripper.
Instance Method Summary collapse
-
#initialize(*args) ⇒ RubyAst
constructor
A new instance of RubyAst.
- #violations ⇒ Object
Constructor Details
#initialize(*args) ⇒ RubyAst
Returns a new instance of RubyAst.
70 71 72 73 |
# File 'lib/sugarcane/abc_check.rb', line 70 def initialize(*args) super self.anon_method_add = true end |
Instance Method Details
#violations ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/sugarcane/abc_check.rb', line 75 def violations process_ast(sexps). select do |nesting, complexity| complexity[:value] > max_allowed_complexity end. map do |violation| { # Here, a violation is an array, like: # ["Class#method", {:value => xx, :line => xx}] file: file_name, line: violation.last[:line], label: violation.first, value: violation.last[:value], description: "Methods exceeded maximum allowed ABC complexity", menu_description: "#{violation.first} exceeded maximum "\ "ABC complexity" } end end |