reviewer 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.flayignore +1 -0
  3. data/.github/workflows/main.yml +11 -3
  4. data/.gitignore +5 -0
  5. data/.reviewer.example.yml +27 -23
  6. data/.reviewer.yml +58 -5
  7. data/.rubocop.yml +2 -0
  8. data/.ruby-version +1 -1
  9. data/CHANGELOG.md +14 -0
  10. data/Gemfile +0 -3
  11. data/Gemfile.lock +54 -29
  12. data/README.md +5 -50
  13. data/exe/fmt +1 -1
  14. data/exe/rvw +1 -1
  15. data/lib/reviewer.rb +39 -26
  16. data/lib/reviewer/arguments.rb +25 -9
  17. data/lib/reviewer/arguments/files.rb +37 -5
  18. data/lib/reviewer/arguments/keywords.rb +23 -9
  19. data/lib/reviewer/arguments/tags.rb +26 -3
  20. data/lib/reviewer/batch.rb +64 -0
  21. data/lib/reviewer/command.rb +100 -0
  22. data/lib/reviewer/command/string.rb +72 -0
  23. data/lib/reviewer/command/string/env.rb +40 -0
  24. data/lib/reviewer/command/string/flags.rb +40 -0
  25. data/lib/reviewer/command/string/verbosity.rb +51 -0
  26. data/lib/reviewer/command/verbosity.rb +65 -0
  27. data/lib/reviewer/configuration.rb +24 -4
  28. data/lib/reviewer/conversions.rb +27 -0
  29. data/lib/reviewer/guidance.rb +73 -0
  30. data/lib/reviewer/history.rb +38 -0
  31. data/lib/reviewer/keywords.rb +9 -0
  32. data/lib/reviewer/keywords/git.rb +14 -0
  33. data/lib/reviewer/keywords/git/staged.rb +48 -0
  34. data/lib/reviewer/loader.rb +2 -3
  35. data/lib/reviewer/output.rb +92 -0
  36. data/lib/reviewer/printer.rb +25 -0
  37. data/lib/reviewer/runner.rb +43 -72
  38. data/lib/reviewer/runner/strategies/quiet.rb +90 -0
  39. data/lib/reviewer/runner/strategies/verbose.rb +63 -0
  40. data/lib/reviewer/shell.rb +58 -0
  41. data/lib/reviewer/shell/result.rb +69 -0
  42. data/lib/reviewer/shell/timer.rb +57 -0
  43. data/lib/reviewer/tool.rb +109 -40
  44. data/lib/reviewer/tool/settings.rb +18 -32
  45. data/lib/reviewer/tools.rb +38 -3
  46. data/lib/reviewer/version.rb +1 -1
  47. data/reviewer.gemspec +10 -2
  48. metadata +143 -16
  49. data/lib/reviewer/arguments/keywords/git.rb +0 -16
  50. data/lib/reviewer/arguments/keywords/git/staged.rb +0 -64
  51. data/lib/reviewer/logger.rb +0 -62
  52. data/lib/reviewer/tool/command.rb +0 -80
  53. data/lib/reviewer/tool/env.rb +0 -38
  54. data/lib/reviewer/tool/flags.rb +0 -38
  55. data/lib/reviewer/tool/verbosity.rb +0 -39
@@ -2,20 +2,26 @@
2
2
 
3
3
  module Reviewer
4
4
  class Tool
5
- # Converts/casts tool configuration values and provides default values if not set
5
+ # Converts/casts tool configuration values and provides default values if not set.
6
6
  class Settings
7
- attr_reader :tool
7
+ attr_reader :tool_key, :config
8
8
 
9
- def initialize(tool, config: nil)
10
- @tool = tool
11
- @config = config
9
+ alias key tool_key
10
+
11
+ def initialize(tool_key, config: nil)
12
+ @tool_key = tool_key.to_sym
13
+ @config = config || load_config
14
+ end
15
+
16
+ def hash
17
+ state.hash
12
18
  end
13
19
 
14
- def ==(other)
20
+ def eql?(other)
15
21
  self.class == other.class &&
16
22
  state == other.state
17
23
  end
18
- alias eql? ==
24
+ alias :== eql?
19
25
 
20
26
  def disabled?
21
27
  config.fetch(:disabled, false)
@@ -25,28 +31,8 @@ module Reviewer
25
31
  !disabled?
26
32
  end
27
33
 
28
- def prepare_command?
29
- commands.key?(:prepare) && commands[:prepare].present?
30
- end
31
-
32
- def install_command?
33
- commands.key?(:install) && commands[:install].present?
34
- end
35
-
36
- def format_command?
37
- commands.key?(:format) && commands[:format].present?
38
- end
39
-
40
- def install_link?
41
- links.key?(:install) && links[:install].present?
42
- end
43
-
44
- def key
45
- tool.to_sym
46
- end
47
-
48
34
  def name
49
- config.fetch(:name) { tool.to_s.titleize }
35
+ config.fetch(:name) { tool_key.to_s.capitalize }
50
36
  end
51
37
 
52
38
  def description
@@ -83,13 +69,13 @@ module Reviewer
83
69
 
84
70
  protected
85
71
 
86
- def config
87
- @config || Reviewer.tools.to_h.fetch(tool.to_sym) { {} }
88
- end
89
-
90
72
  def state
91
73
  config.to_hash
92
74
  end
75
+
76
+ def load_config
77
+ Reviewer.tools.to_h.fetch(key) { {} }
78
+ end
93
79
  end
94
80
  end
95
81
  end
@@ -1,40 +1,75 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Reviewer
4
- # Provides convenient access to subsets of configured tools
4
+ # Provides convenient access to subsets of configured tools based on provided arguments,
5
+ # configured tools, their enabled/disabled status, and more.
5
6
  class Tools
7
+ include Enumerable
8
+
9
+ # Provides an instance to work with for knowing which tools to run in a given context.
10
+ # @param tags: nil [Array] the tags to use to filter tools for a run
11
+ # @param tool_names: nil [type] the explicitly provided tool names to filter tools for a run
12
+ #
13
+ # @return [Reviewer::Tools] collection of tools based on the current run context
6
14
  def initialize(tags: nil, tool_names: nil)
7
15
  @tags = tags
8
16
  @tool_names = tool_names
9
17
  end
10
18
 
19
+ # The current state of all available configured tools regardless of whether they are disabled
20
+ #
21
+ # @return [Hash] hash representing all of the configured tools
11
22
  def to_h
12
23
  configured
13
24
  end
25
+ alias inspect to_h
14
26
 
27
+ # Provides a collection of all configured tools instantiated as Tool instances
28
+ #
29
+ # @return [Array<Tool>] the full collection of all Tool instances
15
30
  def all
16
31
  configured.keys.map { |tool_name| Tool.new(tool_name) }
17
32
  end
18
33
  alias to_a all
19
34
 
35
+ # Provides a collection of all enabled tools instantiated as Tool instances
36
+ #
37
+ # @return [Array<Tool>] the full collection of all enabled Tool instances
20
38
  def enabled
21
39
  @enabled ||= all.keep_if(&:enabled?)
22
40
  end
23
41
 
42
+ # Provides a collection of all explicitly-specified-via-command-line tools as Tool instances
43
+ #
44
+ # @return [Array<Tool>] the full collection of explicitly-specified tools for a run
24
45
  def specified
25
46
  all.keep_if { |tool| named?(tool) }
26
47
  end
27
48
 
49
+ # Provides a collection of all tagged-via-command-line tools as Tool instances
50
+ #
51
+ # @return [Array<Tool>] the full collection of tagged-via-command-line tools for a run
28
52
  def tagged
29
53
  enabled.keep_if { |tool| tagged?(tool) }
30
54
  end
31
55
 
56
+ # Uses the full context of a run to provide the filtered subset of tools to use. It takes into
57
+ # consideration: tagged tools, explicitly-specified tools, configuration (enabled/disabled), and
58
+ # any other relevant details that should influence whether a specific tool should be run as part
59
+ # of the current batch being executed.
60
+ #
61
+ # @return [Array<Tool>] the full collection of should-be-used-for-this-run tools
32
62
  def current
33
63
  subset? ? (specified + tagged).uniq : enabled
34
64
  end
35
65
 
36
66
  private
37
67
 
68
+ # Determines if the current run should include a subset of a tools or the full suite of enabled
69
+ # tools by determining if any tool names or tags were provided that would reduce the full set to
70
+ # only a subset of relevant tools.
71
+ #
72
+ # @return [Boolean] true if any tool names or tags are provided via the command line
38
73
  def subset?
39
74
  tool_names.any? || tags.any?
40
75
  end
@@ -48,11 +83,11 @@ module Reviewer
48
83
  end
49
84
 
50
85
  def tool_names
51
- Array(@tool_names || Reviewer.arguments.tool_names)
86
+ Array(@tool_names || Reviewer.arguments.keywords.for_tool_names)
52
87
  end
53
88
 
54
89
  def tagged?(tool)
55
- tool.enabled? && tags.intersection(tool.tags).any?
90
+ tool.enabled? && (tags & tool.tags).any?
56
91
  end
57
92
 
58
93
  def named?(tool)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Reviewer
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
data/reviewer.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Provides a unified approach to managing automated code quality tools.'
13
13
  spec.homepage = 'https://github.com/garrettdimon/reviewer'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.7.3')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.9')
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = 'https://github.com/garrettdimon/reviewer'
@@ -27,13 +27,21 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ['lib']
29
29
 
30
- spec.add_dependency 'activesupport'
31
30
  spec.add_dependency 'colorize'
32
31
  spec.add_dependency 'slop'
33
32
 
34
33
  spec.add_development_dependency 'bundler-audit'
34
+ spec.add_development_dependency 'codecov'
35
+ spec.add_development_dependency 'dead_end'
36
+ spec.add_development_dependency 'flay'
37
+ spec.add_development_dependency 'flog'
35
38
  spec.add_development_dependency 'inch'
39
+ spec.add_development_dependency 'minitest'
40
+ spec.add_development_dependency 'minitest-color'
41
+ spec.add_development_dependency 'psych', '~> 3.3.2'
42
+ spec.add_development_dependency 'reek'
36
43
  spec.add_development_dependency 'rubocop'
37
44
  spec.add_development_dependency 'rubocop-minitest'
38
45
  spec.add_development_dependency 'rubocop-rake'
46
+ spec.add_development_dependency 'simplecov'
39
47
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reviewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garrett Dimon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-08 00:00:00.000000000 Z
11
+ date: 2021-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activesupport
14
+ name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: colorize
28
+ name: slop
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,13 +39,13 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: slop
42
+ name: bundler-audit
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- type: :runtime
48
+ type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
@@ -53,7 +53,49 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: bundler-audit
56
+ name: codecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dead_end
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: flay
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: flog
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
101
  - - ">="
@@ -80,6 +122,62 @@ dependencies:
80
122
  - - ">="
81
123
  - !ruby/object:Gem::Version
82
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: minitest
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: minitest-color
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: psych
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 3.3.2
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 3.3.2
167
+ - !ruby/object:Gem::Dependency
168
+ name: reek
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
83
181
  - !ruby/object:Gem::Dependency
84
182
  name: rubocop
85
183
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +220,20 @@ dependencies:
122
220
  - - ">="
123
221
  - !ruby/object:Gem::Version
124
222
  version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: simplecov
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
125
237
  description: Provides a unified approach to managing automated code quality tools.
126
238
  email:
127
239
  - email@garrettdimon.com
@@ -131,6 +243,7 @@ executables:
131
243
  extensions: []
132
244
  extra_rdoc_files: []
133
245
  files:
246
+ - ".flayignore"
134
247
  - ".github/workflows/main.yml"
135
248
  - ".gitignore"
136
249
  - ".inch.yml"
@@ -153,19 +266,32 @@ files:
153
266
  - lib/reviewer/arguments.rb
154
267
  - lib/reviewer/arguments/files.rb
155
268
  - lib/reviewer/arguments/keywords.rb
156
- - lib/reviewer/arguments/keywords/git.rb
157
- - lib/reviewer/arguments/keywords/git/staged.rb
158
269
  - lib/reviewer/arguments/tags.rb
270
+ - lib/reviewer/batch.rb
271
+ - lib/reviewer/command.rb
272
+ - lib/reviewer/command/string.rb
273
+ - lib/reviewer/command/string/env.rb
274
+ - lib/reviewer/command/string/flags.rb
275
+ - lib/reviewer/command/string/verbosity.rb
276
+ - lib/reviewer/command/verbosity.rb
159
277
  - lib/reviewer/configuration.rb
278
+ - lib/reviewer/conversions.rb
279
+ - lib/reviewer/guidance.rb
280
+ - lib/reviewer/history.rb
281
+ - lib/reviewer/keywords.rb
282
+ - lib/reviewer/keywords/git.rb
283
+ - lib/reviewer/keywords/git/staged.rb
160
284
  - lib/reviewer/loader.rb
161
- - lib/reviewer/logger.rb
285
+ - lib/reviewer/output.rb
286
+ - lib/reviewer/printer.rb
162
287
  - lib/reviewer/runner.rb
288
+ - lib/reviewer/runner/strategies/quiet.rb
289
+ - lib/reviewer/runner/strategies/verbose.rb
290
+ - lib/reviewer/shell.rb
291
+ - lib/reviewer/shell/result.rb
292
+ - lib/reviewer/shell/timer.rb
163
293
  - lib/reviewer/tool.rb
164
- - lib/reviewer/tool/command.rb
165
- - lib/reviewer/tool/env.rb
166
- - lib/reviewer/tool/flags.rb
167
294
  - lib/reviewer/tool/settings.rb
168
- - lib/reviewer/tool/verbosity.rb
169
295
  - lib/reviewer/tools.rb
170
296
  - lib/reviewer/version.rb
171
297
  - reviewer.gemspec
@@ -184,14 +310,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
310
  requirements:
185
311
  - - ">="
186
312
  - !ruby/object:Gem::Version
187
- version: 2.7.3
313
+ version: 2.5.9
188
314
  required_rubygems_version: !ruby/object:Gem::Requirement
189
315
  requirements:
190
316
  - - ">="
191
317
  - !ruby/object:Gem::Version
192
318
  version: '0'
193
319
  requirements: []
194
- rubygems_version: 3.1.6
320
+ rubyforge_project:
321
+ rubygems_version: 2.7.6.3
195
322
  signing_key:
196
323
  specification_version: 4
197
324
  summary: Provides a unified approach to managing automated code quality tools.