quality 4.0.2 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc9ac9a66a049701f688e34860794a3b50eead97
4
- data.tar.gz: 981585327da8999e4b97d155825ea206a7b7b895
3
+ metadata.gz: 3cfeb910fecf24038686535a2e904d6703149134
4
+ data.tar.gz: 9c2dc4563465bddb667151c887c9037c3659d522
5
5
  SHA512:
6
- metadata.gz: 154994861e087e231e8366b322e83298a79625a802ffa9cb631a8666a8a48521f87109f7dda86105c6f42aa03b4cc283d1d4cc75bba0b96772ada877fcff825f
7
- data.tar.gz: 1a21d689dc0277680d2bd96f75ab28b099a2eaad245caee143f9d88632d71e36b4b1fc50e701043bf462e00e59a87bb4f3a61005370114bc3d848f44fc4a14b8
6
+ metadata.gz: 6ffc41976904af90fd21b40aa104814e83e2672f7514d85dfc225a0e5a5ef11ca224b2f7e9422f97435095cb07f61a040652cb64dc0ef71e9722b2e42758b785
7
+ data.tar.gz: c66f3f646781f5aa60996e4f3f6c776331a7340ce2fd894eef7c7af0fe9c0712eff076ae97b89e0c11ea460e0c200f1bcd7154c95d17f7ca12100429803f2b27
data/README.md CHANGED
@@ -94,7 +94,7 @@ See [this post for more information](http://blog.apiology.cc/2014/06/scalable-qu
94
94
 
95
95
  ## Maturity
96
96
 
97
- Quality is rapidly evolving, but uses [semantic versioning](http://semver.org/)--any incompatible changes will come out as major number updates.
97
+ Quality uses [semantic versioning](http://semver.org/)--any incompatible changes will come out as major number updates.
98
98
 
99
99
  ## Supported Ruby Versions
100
100
 
@@ -117,6 +117,8 @@ Quality makes use of the following other gems, which do the actual checking:
117
117
  * [flog](https://github.com/seattlerb/flog)
118
118
  * [flay](https://github.com/seattlerb/flay)
119
119
  * [rubocop](https://github.com/bbatsov/rubocop)
120
+ * [bigfiles](https://github.com/apiology/bigfiles)
121
+ * [punchlist](https://github.com/apiology/punchlist)
120
122
 
121
123
  ### Learn More
122
124
 
@@ -1,23 +1,25 @@
1
1
  require_relative 'command_output_processor'
2
2
  require_relative 'process_runner'
3
3
 
4
+ # XXX: Should add *.gemspec to glob
4
5
  module Quality
5
6
  # Runs a quality-checking, command, checks it agaist the existing
6
7
  # number of violations for that command, and decreases that number
7
8
  # if possible, or outputs data if the number of violations increased.
8
9
  class QualityChecker
9
- def initialize(cmd, command_options, output_dir, verbose, dependencies = {})
10
- @count_file = dependencies[:count_file] || File
11
- @count_io = dependencies[:count_io] || IO
12
- @command_output_processor_class =
13
- dependencies[:command_output_processor_class] ||
14
- Quality::CommandOutputProcessor
10
+ def initialize(cmd, command_options, output_dir, verbose,
11
+ count_file: File,
12
+ count_io: IO,
13
+ command_output_processor_class:
14
+ Quality::CommandOutputProcessor,
15
+ count_dir: Dir,
16
+ process_runner_class: ProcessRunner)
17
+ @count_file, @count_io, @command_output_processor_class, @count_dir =
18
+ count_file, count_io, command_output_processor_class, count_dir
15
19
  @cmd, @command_options, @verbose = cmd, command_options, verbose
16
- @count_dir = dependencies[:count_dir] || Dir
17
20
  @count_dir.mkdir(output_dir) unless @count_file.exists?(output_dir)
18
21
  @filename = File.join(output_dir, "#{cmd}_high_water_mark")
19
- @process_runner_class =
20
- dependencies[:process_runner_class] || ProcessRunner
22
+ @process_runner_class = process_runner_class
21
23
  end
22
24
 
23
25
  def execute(&count_violations_on_line)
@@ -0,0 +1,73 @@
1
+ # XXX: This should be moved out of rake directory
2
+ module Quality
3
+ # Configuration for running quality tool
4
+ class Config
5
+ # Name of quality task.
6
+ # Defaults to :quality.
7
+ attr_accessor :quality_name
8
+
9
+ # Name of ratchet task.
10
+ # Defaults to :ratchet.
11
+ attr_accessor :ratchet_name
12
+
13
+ # Array of strings describing tools to be skipped--e.g., ["cane"]
14
+ #
15
+ # Defaults to []
16
+ attr_accessor :skip_tools
17
+
18
+ # Log command executation
19
+ #
20
+ # Defaults to false
21
+ attr_accessor :verbose
22
+
23
+ # Array of directory names which contain ruby files to analyze.
24
+ #
25
+ # Defaults to %w(app lib test spec feature), which translates to *.rb in
26
+ # the base directory, as well as those directories.
27
+ attr_writer :ruby_dirs
28
+
29
+ # Array of directory names which contain any type of source
30
+ # files to analyze.
31
+ #
32
+ # Defaults to the same as ruby_dirs
33
+ attr_writer :source_dirs
34
+
35
+ # Relative path to output directory where *_high_water_mark
36
+ # files will be read/written
37
+ #
38
+ # Defaults to .
39
+ attr_accessor :output_dir
40
+
41
+ def ruby_dirs
42
+ @ruby_dirs ||= %w(app lib test spec feature)
43
+ end
44
+
45
+ def source_dirs
46
+ @source_dirs ||= ruby_dirs.clone
47
+ end
48
+
49
+ def source_files_glob(dirs = source_dirs,
50
+ extensions = 'rb,swift,cpp,c,java,py')
51
+ File.join("{#{dirs.join(',')}}", '**', "*.{#{extensions}}")
52
+ end
53
+
54
+ def ruby_files_glob
55
+ source_files_glob(ruby_dirs, 'rb')
56
+ end
57
+
58
+ def ruby_files
59
+ @globber.glob('{*.rb,Rakefile}')
60
+ .concat(@globber.glob(ruby_files_glob)).join(' ')
61
+ end
62
+
63
+ def initialize(quality_name: 'quality',
64
+ ratchet_name: 'ratchet',
65
+ globber: fail)
66
+ @quality_name, @ratchet_name = quality_name, ratchet_name
67
+ @skip_tools = []
68
+ @output_dir = 'metrics'
69
+ @verbose = false
70
+ @globber = globber
71
+ end
72
+ end
73
+ end
@@ -5,6 +5,7 @@ require 'rake/tasklib'
5
5
  require 'rbconfig'
6
6
  require_relative '../runner'
7
7
  require_relative '../quality_checker'
8
+ require_relative 'config'
8
9
 
9
10
  module Quality
10
11
  #
@@ -25,42 +26,6 @@ module Quality
25
26
  #
26
27
  # rake quality
27
28
  class Task < ::Rake::TaskLib
28
- # Name of quality task.
29
- # Defaults to :quality.
30
- attr_accessor :quality_name
31
-
32
- # Name of ratchet task.
33
- # Defaults to :ratchet.
34
- attr_accessor :ratchet_name
35
-
36
- # Array of strings describing tools to be skipped--e.g., ["cane"]
37
- #
38
- # Defaults to []
39
- attr_accessor :skip_tools
40
-
41
- # Log command executation
42
- #
43
- # Defaults to false
44
- attr_accessor :verbose
45
-
46
- # Array of directory names which contain ruby files to analyze.
47
- #
48
- # Defaults to %w(app lib test spec feature), which translates to *.rb in
49
- # the base directory, as well as those directories.
50
- attr_writer :ruby_dirs
51
-
52
- # Array of directory names which contain any type of source
53
- # files to analyze.
54
- #
55
- # Defaults to the same as ruby_dirs
56
- attr_writer :source_dirs
57
-
58
- # Relative path to output directory where *_high_water_mark
59
- # files will be read/written
60
- #
61
- # Defaults to .
62
- attr_accessor :output_dir
63
-
64
29
  # Defines a new task, using the name +name+.
65
30
  def initialize(dsl: ::Rake::Task,
66
31
  cmd_runner: Kernel,
@@ -68,59 +33,35 @@ module Quality
68
33
  count_io: IO,
69
34
  globber: Dir,
70
35
  gem_spec: Gem::Specification,
71
- configuration_writer: File,
72
36
  quality_checker_class:
73
- Quality::QualityChecker,
74
- quality_name: 'quality',
75
- ratchet_name: 'ratchet')
37
+ Quality::QualityChecker)
76
38
  @dsl, @cmd_runner = dsl, cmd_runner
77
39
  @globber = globber
78
- @quality_name, @ratchet_name = quality_name, ratchet_name
79
-
80
- @skip_tools = []
81
-
82
- @verbose = false
83
-
84
- @output_dir = 'metrics'
85
-
86
- yield self if block_given?
87
-
88
- @runner = Quality::Runner.new(self,
40
+ @config = Quality::Config.new(globber: globber)
41
+ yield @config if block_given?
42
+ @runner = Quality::Runner.new(@config,
89
43
  gem_spec: gem_spec,
90
44
  quality_checker_class:
91
45
  quality_checker_class,
92
46
  count_io: count_io,
93
- count_file: count_file)
47
+ count_file: count_file,
48
+ globber: globber)
94
49
  define
95
50
  end
96
51
 
97
- attr_reader :globber
98
-
99
- def ruby_dirs
100
- @ruby_dirs ||= %w(app lib test spec feature)
101
- end
102
-
103
- def source_dirs
104
- @source_dirs ||= ruby_dirs.clone
105
- end
52
+ attr_reader :globber, :config
106
53
 
107
- def source_files_glob(dirs = source_dirs,
108
- extensions = 'rb,swift,cpp,c,java,py')
109
- File.join("{#{dirs.join(',')}}", '**', "*.{#{extensions}}")
110
- end
54
+ private
111
55
 
112
- def ruby_files_glob
113
- source_files_glob(ruby_dirs, 'rb')
56
+ def quality_name
57
+ config.quality_name
114
58
  end
115
59
 
116
- def ruby_files
117
- @globber.glob('{*.rb,Rakefile}')
118
- .concat(@globber.glob(ruby_files_glob)).join(' ')
60
+ def ratchet_name
61
+ config.ratchet_name
119
62
  end
120
63
 
121
- private
122
-
123
- def define # :nodoc:
64
+ def define
124
65
  desc 'Verify quality has increased or stayed ' \
125
66
  'the same' unless ::Rake.application.last_comment
126
67
  @dsl.define_task(quality_name) { @runner.run_quality }
@@ -4,6 +4,9 @@ require_relative 'tools/flog'
4
4
  require_relative 'tools/reek'
5
5
  require_relative 'tools/rubocop'
6
6
  require_relative 'tools/bigfiles'
7
+ require_relative 'tools/punchlist'
8
+
9
+ # XXX: This name is too similar to process_runner
7
10
 
8
11
  module Quality
9
12
  # Knows how to run different quality tools based on a configuration
@@ -15,17 +18,20 @@ module Quality
15
18
  include Tools::Reek
16
19
  include Tools::Rubocop
17
20
  include Tools::BigFiles
21
+ include Tools::Punchlist
18
22
 
19
23
  def initialize(config,
20
24
  gem_spec: Gem::Specification,
21
25
  quality_checker_class: Quality::QualityChecker,
22
26
  count_io: IO,
23
- count_file: File)
27
+ count_file: File,
28
+ globber: Dir)
24
29
  @config = config
25
30
  @gem_spec = gem_spec
26
31
  @quality_checker_class = quality_checker_class
27
32
  @count_io = count_io
28
33
  @count_file = count_file
34
+ @globber = globber
29
35
  end
30
36
 
31
37
  def run_quality
@@ -43,12 +49,10 @@ module Quality
43
49
  end
44
50
  end
45
51
 
46
- def globber
47
- @config.globber
48
- end
49
-
50
52
  def run_ratchet
51
- globber.glob("#{@config.output_dir}/*_high_water_mark").each do |filename|
53
+ # XXX: a lot of things know about globbing--isn't this config's job?
54
+ @globber.glob("#{@config.output_dir}/*_high_water_mark")
55
+ .each do |filename|
52
56
  run_ratchet_on_file(filename)
53
57
  end
54
58
  end
@@ -0,0 +1,15 @@
1
+ module Quality
2
+ module Tools
3
+ # Adds 'punchlist' tool support to quality gem
4
+ module Punchlist
5
+ private
6
+
7
+ def quality_punchlist
8
+ ratchet_quality_cmd('punchlist',
9
+ args: "--glob '#{source_files_glob}'") do |_line|
10
+ 1
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -2,5 +2,5 @@
2
2
  # reek, flog, flay and rubocop and makes sure your numbers don't get
3
3
  # any worse over time.
4
4
  module Quality
5
- VERSION = '4.0.2'
5
+ VERSION = '5.0.0'
6
6
  end
@@ -37,6 +37,7 @@ your numbers don't get any worse over time.
37
37
  s.add_runtime_dependency(%q(flay), ['>= 2.4', '!= 2.6.0'])
38
38
  s.add_runtime_dependency(%q(rubocop))
39
39
  s.add_runtime_dependency(%q(bigfiles))
40
+ s.add_runtime_dependency(%q(punchlist))
40
41
 
41
42
  # need above this version to support Ruby 2.0 syntax
42
43
  s.add_runtime_dependency(%q(ruby_parser), ['>= 3.2.2'])
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.0.2
4
+ version: 5.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: 2015-04-07 00:00:00.000000000 Z
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cane
@@ -100,6 +100,20 @@ dependencies:
100
100
  - - '>='
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: punchlist
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: ruby_parser
105
119
  requirement: !ruby/object:Gem::Requirement
@@ -201,12 +215,14 @@ files:
201
215
  - lib/quality/command_output_processor.rb
202
216
  - lib/quality/process_runner.rb
203
217
  - lib/quality/quality_checker.rb
218
+ - lib/quality/rake/config.rb
204
219
  - lib/quality/rake/task.rb
205
220
  - lib/quality/runner.rb
206
221
  - lib/quality/tools/bigfiles.rb
207
222
  - lib/quality/tools/cane.rb
208
223
  - lib/quality/tools/flay.rb
209
224
  - lib/quality/tools/flog.rb
225
+ - lib/quality/tools/punchlist.rb
210
226
  - lib/quality/tools/reek.rb
211
227
  - lib/quality/tools/rubocop.rb
212
228
  - lib/quality/version.rb