Class: Quality::Tools::Cane

Inherits:
Tool
  • Object
show all
Defined in:
lib/quality/tools/cane.rb

Overview

Adds ‘cane’ tool support to quality gem

Instance Method Summary collapse

Methods inherited from Tool

#initialize

Constructor Details

This class inherits a constructor from Quality::Tools::Tool

Instance Method Details

#cane_argsObject



19
20
21
22
23
24
25
# File 'lib/quality/tools/cane.rb', line 19

def cane_args
  args = [
    "-f '#{ruby_files_glob}'",
  ]
  args += cane_exclude_args unless exclude_files.nil? || exclude_files.empty?
  args.join(' ')
end

#cane_exclude_argsObject



7
8
9
10
11
12
13
# File 'lib/quality/tools/cane.rb', line 7

def cane_exclude_args
  [
    "--abc-exclude '#{source_files_exclude_glob}'",
    "--style-exclude '#{source_files_exclude_glob}'",
    "--doc-exclude '#{source_files_exclude_glob}'",
  ]
end

#quality_caneObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/quality/tools/cane.rb', line 27

def quality_cane
  ratchet_quality_cmd('cane', gives_error_code_on_violations: true,
                              args: cane_args,
                              emacs_format: true) do |line|
    if line =~ /\(([0-9]*)\):$/
      Regexp.last_match[1].to_i
    else
      0
    end
  end
end

#ruby_files_globObject



15
16
17
# File 'lib/quality/tools/cane.rb', line 15

def ruby_files_glob
  "{#{ruby_files.join(',')}}"
end