Class: Quality::Tools::Flake8

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

Overview

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

#flake8_argsObject



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

def flake8_args
  python_files.join(' ')
end

#flake8_count_errors(line) ⇒ Object



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

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

#quality_flake8Object



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

def quality_flake8
  ratchet_quality_cmd('flake8',
                      args: flake8_args,
                      gives_error_code_on_no_relevant_code:
                        true) do |line|
    flake8_count_errors(line)
  end
end