nucop 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nucop/cli.rb +18 -16
- data/lib/nucop/cops/release_toggles_use_symbols.rb +1 -1
- data/lib/nucop/helpers/cop_counter.rb +1 -1
- data/lib/nucop/helpers/rubocop_gem_dependencies.rb +24 -0
- data/lib/nucop/version.rb +1 -1
- data/lib/nucop.rb +3 -3
- metadata +32 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 957aed91fcda974f755014f939640d68c6a386b9c6a8df9ffb10a663302d3b6f
|
4
|
+
data.tar.gz: 532a3c3d3fd5b3814243fe9b71440e0ea37ba7e55b705f3c9dfe2a7a6190660b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 952c7cddb1ab8bfb14e9fc9fb7d99058d21c5e77fc95317c45bc593771b89fee3464a966d8eaec00c076f4dbf372eeab6d4cd79093de2a495b45ae25a9094a44
|
7
|
+
data.tar.gz: 875d3e24c5347da87979e8c92f6abf9e7b96323c61e2025b46df6cc3378530a690f4c6c951dbd841e274fa27ba42c26f71a918846655609d08befe34ef92dac3
|
data/lib/nucop/cli.rb
CHANGED
@@ -15,6 +15,7 @@ module Nucop
|
|
15
15
|
method_option "autocorrect-all", type: :boolean, default: false, desc: "runs RuboCop with autocorrect-all option"
|
16
16
|
method_option "junit_report", type: :string, default: nil, desc: "runs RuboCop with junit formatter option"
|
17
17
|
method_option "json", type: :string, default: nil, desc: "Output results as JSON format to the provided file"
|
18
|
+
|
18
19
|
def diff_enforced
|
19
20
|
invoke :diff, nil, options.merge(only: cops_to_enforce.join(","))
|
20
21
|
end
|
@@ -27,6 +28,7 @@ module Nucop
|
|
27
28
|
method_option "autocorrect-all", type: :boolean, default: false, desc: "runs RuboCop with autocorrect-all option"
|
28
29
|
method_option "junit_report", type: :string, default: nil, desc: "runs RuboCop with junit formatter option"
|
29
30
|
method_option "json", type: :string, default: nil, desc: "Output results as JSON format to the provided file"
|
31
|
+
|
30
32
|
def diff_enforced_github
|
31
33
|
invoke :diff_github, nil, options.merge(only: cops_to_enforce.join(","))
|
32
34
|
end
|
@@ -40,6 +42,7 @@ module Nucop
|
|
40
42
|
method_option "ignore", type: :boolean, default: true, desc: "ignores files specified in #{options[:diffignore_file]}"
|
41
43
|
method_option "added-only", type: :boolean, default: false, desc: "runs RuboCop only on files that have been added (not on files that have been modified)"
|
42
44
|
method_option "exit", type: :boolean, default: true, desc: "disable to prevent task from exiting. Used by other Thor tasks when invoking this task, to prevent parent task from exiting"
|
45
|
+
|
43
46
|
def diff
|
44
47
|
puts "Running on files changed relative to '#{options[:"commit-spec"]}' (specify using the 'commit-spec' option)"
|
45
48
|
diff_filter = options[:"added-only"] ? "A" : "d"
|
@@ -88,6 +91,7 @@ module Nucop
|
|
88
91
|
method_option "ignore", type: :boolean, default: true, desc: "ignores files specified in #{options[:diffignore_file]}"
|
89
92
|
method_option "added-only", type: :boolean, default: false, desc: "runs RuboCop only on files that have been added (not on files that have been modified)"
|
90
93
|
method_option "exit", type: :boolean, default: true, desc: "disable to prevent task from exiting. Used by other Thor tasks when invoking this task, to prevent parent task from exiting"
|
94
|
+
|
91
95
|
def diff_github
|
92
96
|
puts "Running on files changed relative to '#{options[:"commit-spec"]}' (specify using the 'commit-spec' option)"
|
93
97
|
diff_head = capture_std_out("git rev-parse HEAD").chomp
|
@@ -155,14 +159,10 @@ module Nucop
|
|
155
159
|
method_option "autocorrect", type: :boolean, default: false, desc: "runs RuboCop with autocorrect option"
|
156
160
|
method_option "autocorrect-all", type: :boolean, default: false, desc: "runs RuboCop with autocorrect-all option"
|
157
161
|
method_option "exclude-backlog", type: :boolean, default: false, desc: "when true, uses config which excludes violations in the RuboCop backlog"
|
162
|
+
|
158
163
|
def rubocop(files = nil)
|
159
164
|
print_cops_being_run(options[:only])
|
160
165
|
config_file = options[:"exclude-backlog"] ? RUBOCOP_DEFAULT_CONFIG_FILE : options[:rubocop_todo_config_file]
|
161
|
-
rubocop_requires = [
|
162
|
-
"--require rubocop-rspec",
|
163
|
-
"--require rubocop-performance",
|
164
|
-
"--require rubocop-rails"
|
165
|
-
]
|
166
166
|
|
167
167
|
formatters = []
|
168
168
|
formatters << "--format Nucop::Formatters::JUnitFormatter --out #{options[:junit_report]}" if options[:junit_report]
|
@@ -173,7 +173,7 @@ module Nucop
|
|
173
173
|
"bundle exec rubocop",
|
174
174
|
"--no-server",
|
175
175
|
"--parallel",
|
176
|
-
|
176
|
+
rubocop_gem_requires.join(" "),
|
177
177
|
formatters.join(" "),
|
178
178
|
"--force-exclusion",
|
179
179
|
"--config", config_file,
|
@@ -189,18 +189,21 @@ module Nucop
|
|
189
189
|
|
190
190
|
desc "regen_backlog", "update the RuboCop backlog, disabling offending files and excluding all cops with over 500 violating files."
|
191
191
|
method_option "exclude-limit", type: :numeric, default: 500, desc: "Limit files listed to this limit. Passed to RuboCop"
|
192
|
+
|
192
193
|
def regen_backlog
|
193
194
|
regenerate_rubocop_todos
|
194
195
|
update_enforced_cops
|
195
196
|
end
|
196
197
|
|
197
198
|
desc "update_enforced", "update the enforced cops list with file with cops that no longer have violations"
|
199
|
+
|
198
200
|
def update_enforced
|
199
201
|
update_enforced_cops
|
200
202
|
end
|
201
203
|
|
202
204
|
desc "modified_lines", "display RuboCop violations for ONLY modified lines"
|
203
205
|
method_option "commit-spec", default: "main", desc: "the commit used to determine the diff."
|
206
|
+
|
204
207
|
def modified_lines
|
205
208
|
diff_files, diff_status = Open3.capture2("git diff #{options[:"commit-spec"]} --diff-filter=d --name-only | grep \"\\.rb$\"")
|
206
209
|
|
@@ -220,6 +223,7 @@ module Nucop
|
|
220
223
|
|
221
224
|
desc "ready_for_promotion", "display the next n cops with the fewest offenses"
|
222
225
|
method_option "n", type: :numeric, default: 1, desc: "number of cops to display"
|
226
|
+
|
223
227
|
def ready_for_promotion
|
224
228
|
finder = Helpers::NextCopForPromotion.new(options[:rubocop_todo_file])
|
225
229
|
todo_config = YAML.load_file(options[:rubocop_todo_file])
|
@@ -303,17 +307,10 @@ module Nucop
|
|
303
307
|
rubocop_options = [
|
304
308
|
"--auto-gen-config",
|
305
309
|
"--config #{options[:rubocop_todo_config_file]}",
|
306
|
-
"--exclude-limit #{options[:"exclude-limit"]}"
|
307
|
-
"--require rubocop-graphql",
|
308
|
-
"--require rubocop-performance",
|
309
|
-
"--require rubocop-rails",
|
310
|
-
"--require rubocop-rake",
|
311
|
-
"--require rubocop-rspec",
|
312
|
-
"--require rubocop-rubycw",
|
313
|
-
"--require rubocop-thread_safety"
|
310
|
+
"--exclude-limit #{options[:"exclude-limit"]}"
|
314
311
|
]
|
315
312
|
|
316
|
-
rubocop_command = "DISABLE_SPRING=1 bundle exec rubocop #{rubocop_options.join(' ')}"
|
313
|
+
rubocop_command = "DISABLE_SPRING=1 bundle exec rubocop #{rubocop_options.join(' ')} #{rubocop_gem_requires.join(' ')}"
|
317
314
|
|
318
315
|
system(rubocop_command)
|
319
316
|
|
@@ -323,6 +320,10 @@ module Nucop
|
|
323
320
|
system("git checkout #{options[:rubocop_todo_config_file]}")
|
324
321
|
end
|
325
322
|
|
323
|
+
def rubocop_gem_requires
|
324
|
+
Nucop::Helpers::RubocopGemDependencies.rubocop_gems.map { |rubocop_gem| "--require #{rubocop_gem}" }
|
325
|
+
end
|
326
|
+
|
326
327
|
def update_enforced_cops
|
327
328
|
puts "Updating enforced cops list..."
|
328
329
|
|
@@ -346,7 +347,8 @@ module Nucop
|
|
346
347
|
end
|
347
348
|
|
348
349
|
def enabled_cops
|
349
|
-
YAML
|
350
|
+
YAML
|
351
|
+
.safe_load(`bundle exec rubocop --parallel --show-cops`, permitted_classes: [Regexp, Symbol])
|
350
352
|
.select { |_, config| config["Enabled"] }
|
351
353
|
.map(&:first)
|
352
354
|
end
|
@@ -17,7 +17,7 @@ module Nucop
|
|
17
17
|
# release_toggle_enabled?(:move_out_of_wip_autocomplete)
|
18
18
|
#
|
19
19
|
class ReleaseTogglesUseSymbols < ::RuboCop::Cop::Cop
|
20
|
-
MSG = "Use a symbol when
|
20
|
+
MSG = "Use a symbol when referring to a Release Toggle's by name".freeze
|
21
21
|
|
22
22
|
def_node_matcher :test_helper?, <<~PATTERN
|
23
23
|
(send nil? {:release_toggle_enabled? :release_toggle_enabled_for_any_site?} (str _))
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Nucop
|
2
|
+
module Helpers
|
3
|
+
# Knows the list of gems the nucop makes available.
|
4
|
+
module RubocopGemDependencies
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def rubocop_gems
|
8
|
+
%w[
|
9
|
+
rubocop
|
10
|
+
rubocop-capybara
|
11
|
+
rubocop-factory_bot
|
12
|
+
rubocop-graphql
|
13
|
+
rubocop-performance
|
14
|
+
rubocop-rails
|
15
|
+
rubocop-rake
|
16
|
+
rubocop-rspec
|
17
|
+
rubocop-rspec_rails
|
18
|
+
rubocop-rubycw
|
19
|
+
rubocop-thread_safety
|
20
|
+
]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/nucop/version.rb
CHANGED
data/lib/nucop.rb
CHANGED
@@ -3,9 +3,9 @@ require "nucop/version"
|
|
3
3
|
require "rubocop"
|
4
4
|
require "git_diff_parser"
|
5
5
|
|
6
|
-
Dir[File.join(__dir__, "nucop/helpers/**/*.rb")].
|
7
|
-
Dir[File.join(__dir__, "nucop/formatters/**/*.rb")].
|
8
|
-
Dir[File.join(__dir__, "nucop/cops/**/*.rb")].
|
6
|
+
Dir[File.join(__dir__, "nucop/helpers/**/*.rb")].each { |f| require f }
|
7
|
+
Dir[File.join(__dir__, "nucop/formatters/**/*.rb")].each { |f| require f }
|
8
|
+
Dir[File.join(__dir__, "nucop/cops/**/*.rb")].each { |f| require f }
|
9
9
|
|
10
10
|
module Nucop
|
11
11
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nucop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Schweier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: git_diff_parser
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '4.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '4.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rubocop
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +122,20 @@ dependencies:
|
|
136
122
|
- - "~>"
|
137
123
|
- !ruby/object:Gem::Version
|
138
124
|
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-rspec_rails
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.30'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.30'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rubocop-rubycw
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0.5'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: git_diff_parser
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '4.0'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '4.0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: ruby-progressbar
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,6 +244,7 @@ files:
|
|
230
244
|
- lib/nucop/helpers/factory_bot_helper.rb
|
231
245
|
- lib/nucop/helpers/file_path_helper.rb
|
232
246
|
- lib/nucop/helpers/next_cop_for_promotion.rb
|
247
|
+
- lib/nucop/helpers/rubocop_gem_dependencies.rb
|
233
248
|
- lib/nucop/version.rb
|
234
249
|
homepage: https://rubygems.org/gems/nucop
|
235
250
|
licenses:
|
@@ -237,7 +252,6 @@ licenses:
|
|
237
252
|
metadata:
|
238
253
|
homepage_uri: https://github.com/nulogy/nucop
|
239
254
|
changelog_uri: https://github.com/nulogy/nucop/blob/master/CHANGELOG.md
|
240
|
-
source_code_uri: https://github.com/nulogy/nucop
|
241
255
|
bug_tracker_uri: https://github.com/nulogy/nucop/issues
|
242
256
|
rubygems_mfa_required: 'true'
|
243
257
|
post_install_message:
|
@@ -248,7 +262,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
248
262
|
requirements:
|
249
263
|
- - ">="
|
250
264
|
- !ruby/object:Gem::Version
|
251
|
-
version: '
|
265
|
+
version: '3.1'
|
252
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
253
267
|
requirements:
|
254
268
|
- - ">="
|