reviewer 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.alexignore +1 -0
- data/.github/workflows/main.yml +5 -3
- data/.reviewer.example.yml +20 -10
- data/.reviewer.future.yml +221 -0
- data/.reviewer.yml +45 -8
- data/.reviewer_stdout +0 -0
- data/.rubocop.yml +1 -0
- data/Gemfile.lock +29 -28
- data/LICENSE.txt +4 -20
- data/README.md +26 -7
- data/lib/reviewer/arguments/files.rb +14 -8
- data/lib/reviewer/arguments/keywords.rb +5 -2
- data/lib/reviewer/arguments/tags.rb +11 -4
- data/lib/reviewer/arguments.rb +11 -4
- data/lib/reviewer/batch.rb +41 -14
- data/lib/reviewer/command/string/env.rb +4 -0
- data/lib/reviewer/command/string/flags.rb +12 -1
- data/lib/reviewer/command/string.rb +12 -18
- data/lib/reviewer/command.rb +7 -32
- data/lib/reviewer/configuration.rb +8 -1
- data/lib/reviewer/conversions.rb +0 -11
- data/lib/reviewer/guidance.rb +9 -5
- data/lib/reviewer/history.rb +32 -1
- data/lib/reviewer/keywords/git/staged.rb +16 -0
- data/lib/reviewer/output/printer.rb +44 -0
- data/lib/reviewer/output/scrubber.rb +48 -0
- data/lib/reviewer/output/token.rb +85 -0
- data/lib/reviewer/output.rb +73 -43
- data/lib/reviewer/runner/strategies/captured.rb +157 -0
- data/lib/reviewer/runner/strategies/{verbose.rb → passthrough.rb} +13 -13
- data/lib/reviewer/runner.rb +71 -13
- data/lib/reviewer/shell/result.rb +22 -7
- data/lib/reviewer/shell/timer.rb +15 -0
- data/lib/reviewer/shell.rb +7 -11
- data/lib/reviewer/tool/settings.rb +12 -5
- data/lib/reviewer/tool.rb +25 -3
- data/lib/reviewer/version.rb +1 -1
- data/lib/reviewer.rb +11 -10
- data/reviewer.gemspec +9 -5
- data/structure.svg +1 -0
- metadata +34 -28
- data/.ruby-version +0 -1
- data/lib/reviewer/command/string/verbosity.rb +0 -51
- data/lib/reviewer/command/verbosity.rb +0 -65
- data/lib/reviewer/printer.rb +0 -25
- data/lib/reviewer/runner/strategies/quiet.rb +0 -90
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.
|
4
|
+
version: 0.1.5
|
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-
|
11
|
+
date: 2021-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rainbow
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: flay
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: flog
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: inch
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: minitest
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: minitest
|
126
|
+
name: minitest-heat
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: psych
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
@@ -151,21 +151,21 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: reek
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
159
|
+
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
166
|
+
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
168
|
+
name: rubocop
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - ">="
|
@@ -179,7 +179,7 @@ dependencies:
|
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
|
-
name: rubocop
|
182
|
+
name: rubocop-minitest
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
@@ -193,7 +193,7 @@ dependencies:
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
|
-
name: rubocop-
|
196
|
+
name: rubocop-rake
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
199
|
- - ">="
|
@@ -207,7 +207,7 @@ dependencies:
|
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
|
-
name:
|
210
|
+
name: simplecov
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
213
|
- - ">="
|
@@ -221,7 +221,7 @@ dependencies:
|
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: '0'
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
|
-
name:
|
224
|
+
name: yard
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
226
226
|
requirements:
|
227
227
|
- - ">="
|
@@ -243,14 +243,16 @@ executables:
|
|
243
243
|
extensions: []
|
244
244
|
extra_rdoc_files: []
|
245
245
|
files:
|
246
|
+
- ".alexignore"
|
246
247
|
- ".flayignore"
|
247
248
|
- ".github/workflows/main.yml"
|
248
249
|
- ".gitignore"
|
249
250
|
- ".inch.yml"
|
250
251
|
- ".reviewer.example.yml"
|
252
|
+
- ".reviewer.future.yml"
|
251
253
|
- ".reviewer.yml"
|
254
|
+
- ".reviewer_stdout"
|
252
255
|
- ".rubocop.yml"
|
253
|
-
- ".ruby-version"
|
254
256
|
- CHANGELOG.md
|
255
257
|
- CODE_OF_CONDUCT.md
|
256
258
|
- Gemfile
|
@@ -272,8 +274,6 @@ files:
|
|
272
274
|
- lib/reviewer/command/string.rb
|
273
275
|
- lib/reviewer/command/string/env.rb
|
274
276
|
- lib/reviewer/command/string/flags.rb
|
275
|
-
- lib/reviewer/command/string/verbosity.rb
|
276
|
-
- lib/reviewer/command/verbosity.rb
|
277
277
|
- lib/reviewer/configuration.rb
|
278
278
|
- lib/reviewer/conversions.rb
|
279
279
|
- lib/reviewer/guidance.rb
|
@@ -283,10 +283,12 @@ files:
|
|
283
283
|
- lib/reviewer/keywords/git/staged.rb
|
284
284
|
- lib/reviewer/loader.rb
|
285
285
|
- lib/reviewer/output.rb
|
286
|
-
- lib/reviewer/printer.rb
|
286
|
+
- lib/reviewer/output/printer.rb
|
287
|
+
- lib/reviewer/output/scrubber.rb
|
288
|
+
- lib/reviewer/output/token.rb
|
287
289
|
- lib/reviewer/runner.rb
|
288
|
-
- lib/reviewer/runner/strategies/
|
289
|
-
- lib/reviewer/runner/strategies/
|
290
|
+
- lib/reviewer/runner/strategies/captured.rb
|
291
|
+
- lib/reviewer/runner/strategies/passthrough.rb
|
290
292
|
- lib/reviewer/shell.rb
|
291
293
|
- lib/reviewer/shell/result.rb
|
292
294
|
- lib/reviewer/shell/timer.rb
|
@@ -295,13 +297,18 @@ files:
|
|
295
297
|
- lib/reviewer/tools.rb
|
296
298
|
- lib/reviewer/version.rb
|
297
299
|
- reviewer.gemspec
|
300
|
+
- structure.svg
|
298
301
|
homepage: https://github.com/garrettdimon/reviewer
|
299
302
|
licenses:
|
300
303
|
- MIT
|
301
304
|
metadata:
|
302
305
|
homepage_uri: https://github.com/garrettdimon/reviewer
|
303
|
-
|
306
|
+
bug_tracker_uri: https://github.com/garrettdimon/reviewer/issues
|
304
307
|
changelog_uri: https://github.com/garrettdimon/reviewer/CHANGELOG.md
|
308
|
+
documentation_uri: https://www.rubydoc.info/gems/reviewer
|
309
|
+
source_code_uri: https://github.com/garrettdimon/reviewer
|
310
|
+
wiki_uri: https://github.com/garrettdimon/reviewer/wiki
|
311
|
+
rubygems_mfa_required: 'true'
|
305
312
|
post_install_message:
|
306
313
|
rdoc_options: []
|
307
314
|
require_paths:
|
@@ -317,8 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
317
324
|
- !ruby/object:Gem::Version
|
318
325
|
version: '0'
|
319
326
|
requirements: []
|
320
|
-
|
321
|
-
rubygems_version: 2.7.6.3
|
327
|
+
rubygems_version: 3.2.32
|
322
328
|
signing_key:
|
323
329
|
specification_version: 4
|
324
330
|
summary: Provides a unified approach to managing automated code quality tools.
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.5.9
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Reviewer
|
4
|
-
class Command
|
5
|
-
class String
|
6
|
-
# Assembles tool settings and provided context for silencing output
|
7
|
-
class Verbosity
|
8
|
-
include ::Reviewer::Conversions
|
9
|
-
|
10
|
-
# Even when tools provide a quiet flag, not all treat it as complete silence. In order to
|
11
|
-
# ensure no extraneous noise is written to the console in some contexts, command output
|
12
|
-
# occasionally needs to be sent to dev null to ensure there's no clutter.
|
13
|
-
SEND_TO_DEV_NULL = '> /dev/null'
|
14
|
-
|
15
|
-
attr_reader :flag, :level
|
16
|
-
|
17
|
-
# A wrapper for translating a desired verbosity into the correct strings to append to the
|
18
|
-
# command so that any output is appropriately silenced for the context under which it's
|
19
|
-
# currently being executed.
|
20
|
-
# @param flag [String] the tool-level flag to be used for silencing output
|
21
|
-
# @param level: Reviewer::Command::Verbosity::TOOL_SILENCE [Symbol] the target level for
|
22
|
-
# silence for the the command
|
23
|
-
#
|
24
|
-
# @return [type] [description]
|
25
|
-
def initialize(flag, level: Reviewer::Command::Verbosity::TOOL_SILENCE)
|
26
|
-
@flag = String(flag)
|
27
|
-
@level = Verbosity(level)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Converts the verbosity to a string that can be appended to a command string
|
31
|
-
#
|
32
|
-
# @return [String] the string to be appended to commands to ensure the correct verbosity
|
33
|
-
def to_s
|
34
|
-
to_a.map(&:strip).join(' ').strip
|
35
|
-
end
|
36
|
-
|
37
|
-
# Collection of values to be joined to ensure the correct verbosity
|
38
|
-
#
|
39
|
-
# @return [Array<String>] the values that need to be joined to ensure the correct verbosity
|
40
|
-
# for the context
|
41
|
-
def to_a
|
42
|
-
case level.key
|
43
|
-
when Reviewer::Command::Verbosity::TOTAL_SILENCE then [flag, SEND_TO_DEV_NULL].compact
|
44
|
-
when Reviewer::Command::Verbosity::TOOL_SILENCE then [flag].compact
|
45
|
-
else []
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Reviewer
|
4
|
-
class Command
|
5
|
-
# Defines the possible verbosity options for running commands
|
6
|
-
class Verbosity
|
7
|
-
include Comparable
|
8
|
-
|
9
|
-
class InvalidLevelError < ArgumentError; end
|
10
|
-
|
11
|
-
# Use the quiet flag and send everything to dev/null.
|
12
|
-
# For some tools "quiet" means "less noisy" rather than truly silent.
|
13
|
-
# So in those cases, dev/null handles lingering noise.
|
14
|
-
TOTAL_SILENCE = :total_silence
|
15
|
-
|
16
|
-
# Just the quiet flag for the tool. Basically, let the tool determine the useful output.
|
17
|
-
TOOL_SILENCE = :tool_silence
|
18
|
-
|
19
|
-
# Let the output scroll for eternity
|
20
|
-
NO_SILENCE = :no_silence
|
21
|
-
|
22
|
-
# For validation and casting purposes
|
23
|
-
LEVELS = [
|
24
|
-
TOTAL_SILENCE,
|
25
|
-
TOOL_SILENCE,
|
26
|
-
NO_SILENCE
|
27
|
-
].freeze
|
28
|
-
|
29
|
-
attr_accessor :level
|
30
|
-
|
31
|
-
# Create an instance of verbosity
|
32
|
-
# @param level [Symbol] one of the values of verbosity defined by LEVELS
|
33
|
-
#
|
34
|
-
# @return [Command::Verbosity] an instance of verbosity
|
35
|
-
def initialize(level)
|
36
|
-
@level = level.to_sym
|
37
|
-
|
38
|
-
verify_level!
|
39
|
-
end
|
40
|
-
|
41
|
-
def <=>(other)
|
42
|
-
level <=> other.level
|
43
|
-
end
|
44
|
-
|
45
|
-
def to_s
|
46
|
-
level.to_s
|
47
|
-
end
|
48
|
-
|
49
|
-
def to_i
|
50
|
-
LEVELS.index(level)
|
51
|
-
end
|
52
|
-
|
53
|
-
def to_sym
|
54
|
-
level
|
55
|
-
end
|
56
|
-
alias key to_sym
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def verify_level!
|
61
|
-
raise InvalidLevelError, "Invalid Verbosity Level: '#{level}'" unless LEVELS.include?(level)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
data/lib/reviewer/printer.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Reviewer
|
4
|
-
# Clean formatter for logging to $stdout
|
5
|
-
class StandardOutFormatter < ::Logger::Formatter
|
6
|
-
# Overrides ::Logger::Formatter `call` to present output more concisely
|
7
|
-
# @param _severity [Logger::Severity] Unused - Logger severity for etnry
|
8
|
-
# @param _time [DateTime] Unused - Timestamp for entry
|
9
|
-
# @param _progname [String] Unused - Name of the current program for entry
|
10
|
-
# @param message [String] The string to print to $stdout
|
11
|
-
#
|
12
|
-
# @return [type] [description]
|
13
|
-
def call(_severity, _time, _progname, message)
|
14
|
-
"#{message}\n"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# Logger for $stdout
|
19
|
-
class Printer < ::Logger
|
20
|
-
def initialize(formatter = StandardOutFormatter.new)
|
21
|
-
super($stdout)
|
22
|
-
@formatter = formatter
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Reviewer
|
4
|
-
class Runner
|
5
|
-
module Strategies
|
6
|
-
# Execution strategy to run a command quietly
|
7
|
-
class Quiet
|
8
|
-
attr_accessor :runner
|
9
|
-
|
10
|
-
# Create an instance of the quiet strategy for a command runner so that any output is fully
|
11
|
-
# suppressed so as to not create too much noise when running multiple commands.
|
12
|
-
# @param runner [Runner] the instance of the runner to apply the strategy to
|
13
|
-
#
|
14
|
-
# @return [Runner::Strategies::Quiet] an instance of the relevant quiet strategy
|
15
|
-
def initialize(runner)
|
16
|
-
@runner = runner
|
17
|
-
@runner.command.verbosity = Reviewer::Command::Verbosity::TOTAL_SILENCE
|
18
|
-
end
|
19
|
-
|
20
|
-
# The prepare command strategy when running a command quietly
|
21
|
-
#
|
22
|
-
# @return [void]
|
23
|
-
def prepare
|
24
|
-
# Running the prepare command, so make sure the timestamp is updated
|
25
|
-
runner.update_last_prepared_at
|
26
|
-
|
27
|
-
# Run the prepare command, suppressing the output and capturing the realtime benchmark
|
28
|
-
runner.shell.capture_prep(runner.prepare_command)
|
29
|
-
end
|
30
|
-
|
31
|
-
# The run command strategy when running a command verbosely
|
32
|
-
#
|
33
|
-
# @return [void]
|
34
|
-
def run
|
35
|
-
# Run the primary command, suppressing the output and capturing the realtime benchmark
|
36
|
-
runner.shell.capture_main(runner.command)
|
37
|
-
|
38
|
-
# If it's successful, show that it was a success and how long it took to run, otherwise,
|
39
|
-
# it wasn't successful and we got some explaining to do...
|
40
|
-
runner.success? ? show_timing_result : show_command_output
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
# Prints "Success" and the resulting timing details before moving on to the next tool
|
46
|
-
#
|
47
|
-
# @return [void]
|
48
|
-
def show_timing_result
|
49
|
-
runner.output.success(runner.timer)
|
50
|
-
end
|
51
|
-
|
52
|
-
# Prints "Failure" and the resulting exit status. Shows the precise command that led to the
|
53
|
-
# failure for easier copy and paste or making it easier to see any incorrect syntax or
|
54
|
-
# options that could be corrected.
|
55
|
-
#
|
56
|
-
# @return [void]
|
57
|
-
def show_command_output
|
58
|
-
runner.output.failure("Exit Status #{runner.exit_status}", command: runner.command)
|
59
|
-
|
60
|
-
# If it can't be rerun, then don't try
|
61
|
-
return if runner.result.total_failure?
|
62
|
-
|
63
|
-
# If it can be rerun, set the strategy to verbose so the output will be visible, and then
|
64
|
-
# run it with the verbose strategy so the output isn't suppressed. Long-term, it makes
|
65
|
-
# sense to add an option for whether to focus on speed or rich output.
|
66
|
-
#
|
67
|
-
# For now, the simplest strategy is to re-run the exact same command without suppressing
|
68
|
-
# the output. However, running a command twice isn't exactly efficient. Since we've
|
69
|
-
# already run it once and captured the output, we could just display that output, but it
|
70
|
-
# would be filtered through as a dumb string. That would mean it strips out color and
|
71
|
-
# formatting. It would save time, but what's the threshold where the time savings is worth
|
72
|
-
# it?
|
73
|
-
#
|
74
|
-
# Ultimately, this will be a tradeoff between how much the tool's original formatting
|
75
|
-
# makes it easier to scan the results and take action. For example, if a command takes
|
76
|
-
# 60 seconds to run, it might be faster to show the low-fidelity output immediately rather
|
77
|
-
# than waiting another 60 seconds for higher-fidelity output.
|
78
|
-
#
|
79
|
-
# Most likely, this will be a tool-by-tool decision and need to be added as an option to
|
80
|
-
# the tool configuration, but that will create additional complexity/overhead when adding
|
81
|
-
# a new tool.
|
82
|
-
#
|
83
|
-
# So for now, we punt. And pay close attention.
|
84
|
-
runner.strategy = Strategies::Verbose
|
85
|
-
runner.run
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|