Class: Cane::StyleCheck
- Inherits:
-
Struct
- Object
- Struct
- Cane::StyleCheck
- Defined in:
- lib/cane/style_check.rb
Overview
Creates violations for files that do not meet style conventions. Only highly obvious, probable, and non-controversial checks are performed here. It is not the goal of the tool to provide an extensive style report, but only to prevent stupid mistakes.
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/style_check.rb', line 12 def opts @opts end |
Class Method Details
.key ⇒ Object
14 |
# File 'lib/cane/style_check.rb', line 14 def self.key; :style; end |
.name ⇒ Object
15 |
# File 'lib/cane/style_check.rb', line 15 def self.name; "style checking"; end |
.options ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cane/style_check.rb', line 16 def self. { style_glob: ['Glob to run style checks over', default: '{app,lib,spec}/**/*.rb', variable: 'GLOB', clobber: :no_style], style_measure: ['Max line length', default: 80, cast: :to_i, clobber: :no_style], style_exclude: ['Exclude file or glob from style checking', variable: 'GLOB', type: Array, default: [], clobber: :no_style], no_style: ['Disable style checking', cast: ->(x) { !x }] } end |
Instance Method Details
#violations ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cane/style_check.rb', line 35 def violations return [] if opts[:no_style] worker.map(file_list) do |file_path| map_lines(file_path) do |line, line_number| violations_for_line(line.chomp).map {|| { file: file_path, line: line_number + 1, label: , description: "Lines violated style requirements" }} end end.flatten end |