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 +4 -4
- data/README.md +2 -2
- data/lib/quality/runner.rb +15 -14
- data/lib/quality/tool.rb +27 -0
- data/lib/quality/tools/bigfiles.rb +1 -3
- data/lib/quality/tools/brakeman.rb +1 -3
- data/lib/quality/tools/bundle_audit.rb +1 -3
- data/lib/quality/tools/cane.rb +1 -3
- data/lib/quality/tools/eslint.rb +1 -3
- data/lib/quality/tools/flake8.rb +1 -3
- data/lib/quality/tools/flay.rb +1 -3
- data/lib/quality/tools/flog.rb +7 -16
- data/lib/quality/tools/jscs.rb +1 -3
- data/lib/quality/tools/mdl.rb +1 -3
- data/lib/quality/tools/punchlist.rb +1 -3
- data/lib/quality/tools/pycodestyle.rb +1 -3
- data/lib/quality/tools/rails_best_practices.rb +6 -14
- data/lib/quality/tools/reek.rb +6 -15
- data/lib/quality/tools/rubocop.rb +9 -18
- data/lib/quality/tools/scalastyle.rb +1 -3
- data/lib/quality/tools/shellcheck.rb +1 -3
- data/lib/quality/version.rb +1 -1
- data/quality.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10dac3c7d14e1b7bd6b80d0be27a38a866bd530f
|
4
|
+
data.tar.gz: ff3db34f37978b984cbc11a8e2926e560772c308
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
45
|
-
brew install cmake icu4c shellcheck scalastyle #
|
44
|
+
pip install flake8
|
45
|
+
brew install cmake icu4c shellcheck scalastyle # macOS
|
46
46
|
gem install quality
|
47
47
|
```
|
48
48
|
|
data/lib/quality/runner.rb
CHANGED
@@ -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(
|
80
|
-
if
|
81
|
-
|
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
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|
|
data/lib/quality/tool.rb
ADDED
@@ -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,13 +3,11 @@
|
|
3
3
|
module Quality
|
4
4
|
module Tools
|
5
5
|
# Adds 'bundler_audit' tool support to quality gem
|
6
|
-
|
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: '',
|
data/lib/quality/tools/cane.rb
CHANGED
data/lib/quality/tools/eslint.rb
CHANGED
data/lib/quality/tools/flake8.rb
CHANGED
data/lib/quality/tools/flay.rb
CHANGED
data/lib/quality/tools/flog.rb
CHANGED
@@ -3,13 +3,7 @@
|
|
3
3
|
module Quality
|
4
4
|
module Tools
|
5
5
|
# Adds 'flog' tool support to quality gem
|
6
|
-
|
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
|
-
|
21
|
-
|
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
|
-
|
17
|
+
return 0 unless line =~ /^ *([0-9.]*): (.*) .*.rb:[0-9]*$/
|
26
18
|
|
27
|
-
|
19
|
+
score = Regexp.last_match[1].to_i
|
28
20
|
|
29
|
-
|
21
|
+
return 1 if score > threshold
|
30
22
|
|
31
|
-
|
32
|
-
end
|
23
|
+
0
|
33
24
|
end
|
34
25
|
end
|
35
26
|
end
|
data/lib/quality/tools/jscs.rb
CHANGED
data/lib/quality/tools/mdl.rb
CHANGED
@@ -3,9 +3,7 @@
|
|
3
3
|
module Quality
|
4
4
|
module Tools
|
5
5
|
# Adds 'punchlist' tool support to quality gem
|
6
|
-
|
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,13 +3,7 @@
|
|
3
3
|
module Quality
|
4
4
|
module Tools
|
5
5
|
# Adds 'rubocop' tool support to quality gem
|
6
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
data/lib/quality/tools/reek.rb
CHANGED
@@ -3,13 +3,7 @@
|
|
3
3
|
module Quality
|
4
4
|
module Tools
|
5
5
|
# Adds 'reek' tool support to quality gem
|
6
|
-
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
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
|
data/lib/quality/version.rb
CHANGED
data/quality.gemspec
CHANGED
@@ -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.
|
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:
|
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-
|
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.
|
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.
|
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
|