Class: Quality::Tools::Pycodestyle

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

Overview

Adds ‘pycodestyle’ 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

#pycodestyle_argsObject



7
8
9
# File 'lib/quality/tools/pycodestyle.rb', line 7

def pycodestyle_args
  python_files.join(' ')
end

#pycodestyle_count_errors(line) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/quality/tools/pycodestyle.rb', line 11

def pycodestyle_count_errors(line)
  if line =~ /^Usage:/
    # no files specified
    0
  elsif line =~ /^pycodestyle: /
    # no files specified
    0
  elsif line =~ /^$/
    # no files specified
    0
  else
    1
  end
end

#quality_pycodestyleObject



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

def quality_pycodestyle
  ratchet_quality_cmd('pycodestyle',
                      args: pycodestyle_args,
                      gives_error_code_on_no_relevant_code:
                        true) do |line|
    pycodestyle_count_errors(line)
  end
end