Class: Quality::Tools::Rubocop

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

Overview

Adds ‘rubocop’ tool support to quality gem

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tool

#initialize

Constructor Details

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

Class Method Details

.count_rubocop_violations(line) ⇒ Object



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

def self.count_rubocop_violations(line)
  if line =~ /^.* file[s|] inspected, (.*) offence[s|] detected$/
    0
  elsif line =~ /^warning: .*/
    # don't count internal rubocop errors/warnings
    0
  else
    1
  end
end

Instance Method Details

#quality_rubocopObject



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

def quality_rubocop
  ratchet_quality_cmd('rubocop',
                      gives_error_code_on_violations: true,
                      args: rubocop_args) do |line|
    self.class.count_rubocop_violations(line)
  end
end

#rubocop_argsObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/quality/tools/rubocop.rb', line 7

def rubocop_args
  [
    '--force-exclusion',
    '--require rubocop-minitest',
    '--require rubocop-rake',
    '--require rubocop-rspec',
    '--format emacs',
    *ruby_files,
  ].join(' ')
end