quality 32.1.1 → 33.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97fb1d516d0fa1f9ac832b8e0f182c657859aacd
4
- data.tar.gz: c7f2a0b8dba7bf0e542c673d0c4d2f74516505e2
3
+ metadata.gz: 10dac3c7d14e1b7bd6b80d0be27a38a866bd530f
4
+ data.tar.gz: ff3db34f37978b984cbc11a8e2926e560772c308
5
5
  SHA512:
6
- metadata.gz: 55cd00ea83680403565c7c502bb6ef292bd57d68f8e0c6ec8662cc71c367a5fa3d89b35f3029910608422bd784e2acf2f5ad44bb6a1c1456913907a762acd72f
7
- data.tar.gz: d65a2514278daa066bb463c56831b9a63b89729650d4f70d575d9efde0a07287ebbd01ba69b70afdaccc127030827f35657afae616bd5684985cf606cd8a1aa1
6
+ metadata.gz: 259852863887d7f1c648b5a0a39e1298fa14815eef88fe2af0cdece1570ac135c3ef7da09f65d654d487cbb0dd671bd18fedd679c50218b8c6679b2ea6e72f17
7
+ data.tar.gz: 30f27ce1ae72211730beff23b102af4d659c05b888a4eb3719eb6a015fe8457ef540181d40708b38784534d04d62a4d998576b82abd6746a20b981991896ea10
data/README.md CHANGED
@@ -41,8 +41,8 @@ See [DOCKER.md](DOCKER.md) for info.
41
41
  ## How to use - as part of a Ruby-based Rakefile
42
42
 
43
43
  ```bash
44
- pip install 'pycodestyle<2.4.0' flake8
45
- brew install cmake icu4c shellcheck scalastyle # OS X
44
+ pip install flake8
45
+ brew install cmake icu4c shellcheck scalastyle # macOS
46
46
  gem install quality
47
47
  ```
48
48
 
@@ -4,6 +4,7 @@ require 'active_support/inflector'
4
4
  require 'forwardable'
5
5
  require_relative 'which'
6
6
  require_relative 'directory_of_classes'
7
+ require_relative 'tool'
7
8
 
8
9
  # Quality is a tool that runs quality checks on Ruby code using cane,
9
10
  # reek, flog, flay and rubocop and makes sure your numbers don't get
@@ -18,8 +19,6 @@ module Quality
18
19
  # Knows how to run different quality tools based on a configuration
19
20
  # already determined.
20
21
  class Runner
21
- TOOL_CLASSES.symbols_and_classes.each { |_symbol, clazz| include clazz }
22
-
23
22
  extend ::Forwardable
24
23
 
25
24
  def initialize(config, gem_spec: Gem::Specification,
@@ -36,18 +35,18 @@ module Quality
36
35
  end
37
36
 
38
37
  def run_quality
39
- tools.each do |tool_name, tool_exe|
40
- run_quality_with_tool(tool_name, tool_exe)
38
+ tools.each do |tool_name, tool_exe, clazz|
39
+ run_quality_with_tool(tool_name, tool_exe, clazz)
41
40
  end
42
41
  end
43
42
 
44
- def run_quality_with_tool(tool_name, tool_exe)
43
+ def run_quality_with_tool(tool_name, tool_exe, clazz)
45
44
  suppressed = @config.skip_tools.include? tool_name
46
45
  installed = @gem_spec.find_all_by_name(tool_name).any? ||
47
46
  !@which.which(tool_exe).nil?
48
47
 
49
48
  if installed && !suppressed
50
- method("quality_#{tool_name}".to_sym).call
49
+ clazz.new(self).method("quality_#{tool_name}".to_sym).call
51
50
  elsif !installed
52
51
  puts "#{tool_name} not installed"
53
52
  end
@@ -73,23 +72,25 @@ module Quality
73
72
  def count_existing_violations(filename)
74
73
  existing_violations = @count_io.read(filename).to_i
75
74
  raise("Problem with file #{filename}") if existing_violations < 0
75
+
76
76
  existing_violations
77
77
  end
78
78
 
79
- def command_name(ancestor, name)
80
- if ancestor.respond_to? :command_name
81
- ancestor.command_name
79
+ def command_name(clazz, name)
80
+ if clazz.respond_to? :command_name
81
+ clazz.command_name
82
82
  else
83
83
  name
84
84
  end
85
85
  end
86
86
 
87
87
  def tools
88
- self.class.ancestors.map do |ancestor|
89
- ancestor_name = ancestor.to_s
90
- next unless ancestor_name.start_with?('Quality::Tools::')
91
- name = ancestor.to_s.split('::').last.underscore
92
- [name, command_name(ancestor, name)]
88
+ TOOL_CLASSES.symbols_and_classes.map do |_symbol, clazz|
89
+ clazz_name = clazz.to_s
90
+ raise unless clazz_name.start_with?('Quality::Tools::')
91
+
92
+ name = clazz_name.split('::').last.underscore
93
+ [name, command_name(clazz, name), clazz]
93
94
  end.compact
94
95
  end
95
96
 
@@ -0,0 +1,27 @@
1
+ module Quality
2
+ module Tools
3
+ # represents a code quality tool which can be run on source files
4
+ class Tool
5
+ extend ::Forwardable
6
+
7
+ def initialize(runner)
8
+ @runner = runner
9
+ end
10
+
11
+ def_delegators(:@runner,
12
+ :source_and_doc_files_glob,
13
+ :source_files_exclude_glob,
14
+ :ratchet_quality_cmd,
15
+ :js_files,
16
+ :python_files,
17
+ :ruby_files,
18
+ :exclude_files,
19
+ :markdown_files,
20
+ :punchlist_regexp,
21
+ :scalastyle_config,
22
+ :scalastyle_exclude,
23
+ :scala_files,
24
+ :shell_files)
25
+ end
26
+ end
27
+ end
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'bigfiles' tool support to quality gem
6
- module Bigfiles
7
- private
8
-
6
+ class Bigfiles < Tool
9
7
  def bigfiles_args
10
8
  args = ['--glob', "'#{source_and_doc_files_glob}'"]
11
9
  unless source_files_exclude_glob == '{}'
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'rubocop' tool support to quality gem
6
- module Brakeman
7
- private
8
-
6
+ class Brakeman < Tool
9
7
  def quality_brakeman
10
8
  ratchet_quality_cmd('brakeman',
11
9
  args: '-q --summary -f csv 2>/dev/null',
@@ -3,13 +3,11 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'bundler_audit' tool support to quality gem
6
- module BundleAudit
6
+ class BundleAudit < Tool
7
7
  def self.command_name
8
8
  'bundle-audit'
9
9
  end
10
10
 
11
- private
12
-
13
11
  def quality_bundle_audit
14
12
  ratchet_quality_cmd('bundle-audit',
15
13
  args: '',
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'cane' tool support to quality gem
6
- module Cane
7
- private
8
-
6
+ class Cane < Tool
9
7
  def cane_exclude_args
10
8
  [
11
9
  "--abc-exclude '#{source_files_exclude_glob}'",
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'bigfiles' tool support to quality gem
6
- module Eslint
7
- private
8
-
6
+ class Eslint < Tool
9
7
  def eslint_args
10
8
  '-f unix ' + js_files.join(' ')
11
9
  end
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'flake8' tool support to quality gem
6
- module Flake8
7
- private
8
-
6
+ class Flake8 < Tool
9
7
  def flake8_args
10
8
  python_files.join(' ')
11
9
  end
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'flay' tool support to quality gem
6
- module Flay
7
- private
8
-
6
+ class Flay < Tool
9
7
  def flay_args
10
8
  "--mass 75 --timeout 99999 #{ruby_files.join(' ')}"
11
9
  end
@@ -3,13 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'flog' tool support to quality gem
6
- module Flog
7
- def self.included(base)
8
- base.extend ClassMethods
9
- end
10
-
11
- private
12
-
6
+ class Flog < Tool
13
7
  def quality_flog
14
8
  args = "--all --continue --methods-only #{ruby_files.join(' ')}"
15
9
  ratchet_quality_cmd('flog', args: args, emacs_format: true) do |line|
@@ -17,19 +11,16 @@ module Quality
17
11
  end
18
12
  end
19
13
 
20
- # See Flog.included
21
- module ClassMethods
22
- def count_violations_in_flog_output(line, threshold = 50)
23
- return 0 if line =~ /^ *([0-9.]*): flog total$/
14
+ def self.count_violations_in_flog_output(line, threshold = 50)
15
+ return 0 if line =~ /^ *([0-9.]*): flog total$/
24
16
 
25
- return 0 unless line =~ /^ *([0-9.]*): (.*) .*.rb:[0-9]*$/
17
+ return 0 unless line =~ /^ *([0-9.]*): (.*) .*.rb:[0-9]*$/
26
18
 
27
- score = Regexp.last_match[1].to_i
19
+ score = Regexp.last_match[1].to_i
28
20
 
29
- return 1 if score > threshold
21
+ return 1 if score > threshold
30
22
 
31
- 0
32
- end
23
+ 0
33
24
  end
34
25
  end
35
26
  end
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'bigfiles' tool support to quality gem
6
- module Jscs
7
- private
8
-
6
+ class Jscs < Tool
9
7
  def jscs_args
10
8
  '-r unix ' + js_files.join(' ')
11
9
  end
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'bigfiles' tool support to quality gem
6
- module Mdl
7
- private
8
-
6
+ class Mdl < Tool
9
7
  def mdl_args
10
8
  markdown_files.join(' ')
11
9
  end
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'punchlist' tool support to quality gem
6
- module Punchlist
7
- private
8
-
6
+ class Punchlist < Tool
9
7
  def punchlist_args
10
8
  glob = "--glob '#{source_and_doc_files_glob}'"
11
9
  regexp = " --regexp '#{punchlist_regexp}'" if punchlist_regexp
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'pycodestyle' tool support to quality gem
6
- module Pycodestyle
7
- private
8
-
6
+ class Pycodestyle < Tool
9
7
  def pycodestyle_args
10
8
  python_files.join(' ')
11
9
  end
@@ -3,13 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'rubocop' tool support to quality gem
6
- module RailsBestPractices
7
- def self.included(base)
8
- base.extend ClassMethods
9
- end
10
-
11
- private
12
-
6
+ class RailsBestPractices < Tool
13
7
  def quality_rails_best_practices
14
8
  ratchet_quality_cmd('rails_best_practices',
15
9
  gives_error_code_on_violations: true) do |line|
@@ -18,13 +12,11 @@ module Quality
18
12
  end
19
13
 
20
14
  # See Rubocop.included
21
- module ClassMethods
22
- def count_rails_best_practices_violations(line)
23
- if line =~ /.*:[0-9]* - /
24
- 1
25
- else
26
- 0
27
- end
15
+ def self.count_rails_best_practices_violations(line)
16
+ if line =~ /.*:[0-9]* - /
17
+ 1
18
+ else
19
+ 0
28
20
  end
29
21
  end
30
22
  end
@@ -3,13 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'reek' tool support to quality gem
6
- module Reek
7
- def self.included(base)
8
- base.extend ClassMethods
9
- end
10
-
11
- private
12
-
6
+ class Reek < Tool
13
7
  def quality_reek
14
8
  args = "--single-line #{ruby_files.join(' ')}"
15
9
  ratchet_quality_cmd('reek',
@@ -20,14 +14,11 @@ module Quality
20
14
  end
21
15
  end
22
16
 
23
- # See Reek.included
24
- module ClassMethods
25
- def count_reek_violations(line)
26
- if line =~ /^ .* (.*)$/
27
- 1
28
- else
29
- 0
30
- end
17
+ def self.count_reek_violations(line)
18
+ if line =~ /^ .* (.*)$/
19
+ 1
20
+ else
21
+ 0
31
22
  end
32
23
  end
33
24
  end
@@ -3,13 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'rubocop' tool support to quality gem
6
- module Rubocop
7
- def self.included(base)
8
- base.extend ClassMethods
9
- end
10
-
11
- private
12
-
6
+ class Rubocop < Tool
13
7
  def rubocop_args
14
8
  [
15
9
  '--force-exclusion',
@@ -27,17 +21,14 @@ module Quality
27
21
  end
28
22
  end
29
23
 
30
- # See Rubocop.included
31
- module ClassMethods
32
- def count_rubocop_violations(line)
33
- if line =~ /^.* file[s|] inspected, (.*) offence[s|] detected$/
34
- 0
35
- elsif line =~ /^warning: .*/
36
- # don't count internal rubocop errors/warnings
37
- 0
38
- else
39
- 1
40
- end
24
+ def self.count_rubocop_violations(line)
25
+ if line =~ /^.* file[s|] inspected, (.*) offence[s|] detected$/
26
+ 0
27
+ elsif line =~ /^warning: .*/
28
+ # don't count internal rubocop errors/warnings
29
+ 0
30
+ else
31
+ 1
41
32
  end
42
33
  end
43
34
  end
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'scalastyle' tool support to quality gem
6
- module Scalastyle
7
- private
8
-
6
+ class Scalastyle < Tool
9
7
  def scalastyle_args
10
8
  c = " -c '#{scalastyle_config}' " if scalastyle_config
11
9
  x = " -x '#{scalastyle_exclude}' " if scalastyle_exclude
@@ -3,9 +3,7 @@
3
3
  module Quality
4
4
  module Tools
5
5
  # Adds 'ShellCheck' tool support to quality gem
6
- module Shellcheck
7
- private
8
-
6
+ class Shellcheck < Tool
9
7
  def shellcheck_args
10
8
  "-fgcc -sbash #{shell_files.join(' ')}"
11
9
  end
@@ -4,5 +4,5 @@
4
4
  # reek, flog, flay and rubocop and makes sure your numbers don't get
5
5
  # any worse over time.
6
6
  module Quality
7
- VERSION = '32.1.1'.freeze
7
+ VERSION = '33.0.0'.freeze
8
8
  end
@@ -48,7 +48,7 @@ Gem::Specification.new do |s|
48
48
  #
49
49
  # https://github.com/bbatsov/rubocop#installation
50
50
  s.add_runtime_dependency('mdl')
51
- s.add_runtime_dependency('rubocop', '~> 0.58.2')
51
+ s.add_runtime_dependency('rubocop', '~> 0.60.0')
52
52
  # 1.19.0 was a RuboCop 0.51.0 compatibility release
53
53
  s.add_runtime_dependency('bigfiles', ['>= 0.1'])
54
54
  s.add_runtime_dependency('brakeman')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quality
3
3
  version: !ruby/object:Gem::Version
4
- version: 32.1.1
4
+ version: 33.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-19 00:00:00.000000000 Z
11
+ date: 2018-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -148,14 +148,14 @@ dependencies:
148
148
  requirements:
149
149
  - - "~>"
150
150
  - !ruby/object:Gem::Version
151
- version: 0.58.2
151
+ version: 0.60.0
152
152
  type: :runtime
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
- version: 0.58.2
158
+ version: 0.60.0
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: bigfiles
161
161
  requirement: !ruby/object:Gem::Requirement
@@ -392,6 +392,7 @@ files:
392
392
  - lib/quality/rake/task.rb
393
393
  - lib/quality/ruby_spawn.rb
394
394
  - lib/quality/runner.rb
395
+ - lib/quality/tool.rb
395
396
  - lib/quality/tools/bigfiles.rb
396
397
  - lib/quality/tools/brakeman.rb
397
398
  - lib/quality/tools/bundle_audit.rb