Class: Cane::AbcCheck
- Inherits:
-
Struct
- Object
- Struct
- Cane::AbcCheck
- Defined in:
- lib/cane/abc_check.rb
Overview
Creates violations for methods that are too complicated using a simple algorithm run against the parse tree of a file to count assignments, branches, and conditionals. Borrows heavily from metric_abc.
Defined Under Namespace
Classes: InvalidAst, RubyAst
Instance Attribute Summary collapse
-
#opts ⇒ Object
Returns the value of attribute opts.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#opts ⇒ Object
Returns the value of attribute opts
12 13 14 |
# File 'lib/cane/abc_check.rb', line 12 def opts @opts end |
Class Method Details
.key ⇒ Object
14 |
# File 'lib/cane/abc_check.rb', line 14 def self.key; :abc; end |
.name ⇒ Object
15 |
# File 'lib/cane/abc_check.rb', line 15 def self.name; "ABC check"; end |
.options ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cane/abc_check.rb', line 16 def self. { abc_glob: ['Glob to run ABC metrics over', default: '{app,lib}/**/*.rb', variable: 'GLOB', clobber: :no_abc], abc_max: ['Ignore methods under this complexity', default: 15, cast: :to_i, clobber: :no_abc], abc_exclude: ['Exclude method from analysis (eg. Foo::Bar#method)', variable: 'METHOD', type: Array, default: [], clobber: :no_abc], no_abc: ['Disable ABC checking', cast: ->(x) { !x }] } end |
Instance Method Details
#violations ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/cane/abc_check.rb', line 36 def violations return [] if opts[:no_abc] order worker.map(file_names) {|file_name| find_violations(file_name) }.flatten end |