nucop 0.11.2 → 0.12.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/lib/nucop/cli.rb +29 -28
- data/lib/nucop/cops/explicit_factory_bot_usage.rb +5 -8
- data/lib/nucop/cops/no_core_method_overrides.rb +1 -1
- data/lib/nucop/cops/no_wip_specs.rb +1 -1
- data/lib/nucop/cops/ordered_hash.rb +6 -12
- data/lib/nucop/cops/release_toggles_use_symbols.rb +8 -8
- data/lib/nucop/cops/shadowing_factory_bot_creation_methods.rb +1 -1
- data/lib/nucop/helpers/cop_set.rb +0 -2
- data/lib/nucop/version.rb +1 -1
- metadata +26 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75e14093d66eefb64ddcab42c17e132a0ffedb4038dfdb13b3f3530efb2b8ce4
|
4
|
+
data.tar.gz: 7f9301976fb9e2f6faeea1c554600c475b652658b9650c21ce2485a83aa45f45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc89dae160e8633cc9d227c2e204e49411a29fa184d5dd33f005d68950445d78abdd43b8b419dafcf0d3f28d2e235812fce4fe7f2270813a31a4473532ab07b5
|
7
|
+
data.tar.gz: 4965b8c0304655c314ea4aa945809449c4a7ab85d43db419845ec832791a3dc9465b75e986d6463c0dfb0eeebf723b88a049b074e8503cdbdae22af63ce8444e
|
data/lib/nucop/cli.rb
CHANGED
@@ -8,6 +8,34 @@ CONFIGURATION_FILEPATH = ".nucop.yml"
|
|
8
8
|
|
9
9
|
module Nucop
|
10
10
|
class Cli < Thor
|
11
|
+
class << self
|
12
|
+
private
|
13
|
+
|
14
|
+
def load_custom_options
|
15
|
+
@_load_custom_options ||= begin
|
16
|
+
if File.exist?(CONFIGURATION_FILEPATH)
|
17
|
+
default_configuration.merge(YAML.load_file(CONFIGURATION_FILEPATH))
|
18
|
+
else
|
19
|
+
default_configuration
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_configuration
|
25
|
+
{
|
26
|
+
enforced_cops_file: ".rubocop.enforced.yml",
|
27
|
+
rubocop_todo_file: ".rubocop_todo.yml",
|
28
|
+
rubocop_todo_config_file: ".rubocop.backlog.yml",
|
29
|
+
diffignore_file: ".nucop_diffignore"
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class_option :diffignore_file, default: load_custom_options[:diffignore_file]
|
35
|
+
class_option :enforced_cops_file, default: load_custom_options[:enforced_cops_file]
|
36
|
+
class_option :rubocop_todo_config_file, default: load_custom_options[:rubocop_todo_config_file]
|
37
|
+
class_option :rubocop_todo_file, default: load_custom_options[:rubocop_todo_file]
|
38
|
+
|
11
39
|
desc "diff_enforced", "run RuboCop on the current diff using only the enforced cops"
|
12
40
|
method_option "commit-spec", default: "origin/main", desc: "the commit used to determine the diff."
|
13
41
|
method_option "auto-correct", type: :boolean, default: false, desc: "runs RuboCop with auto-correct option (deprecated)"
|
@@ -347,37 +375,10 @@ module Nucop
|
|
347
375
|
end
|
348
376
|
|
349
377
|
def enabled_cops
|
350
|
-
YAML
|
378
|
+
@_enabled_cops ||= YAML
|
351
379
|
.safe_load(`bundle exec rubocop --parallel --show-cops`, permitted_classes: [Regexp, Symbol])
|
352
380
|
.select { |_, config| config["Enabled"] }
|
353
381
|
.map(&:first)
|
354
382
|
end
|
355
|
-
|
356
|
-
# Override Thor's options method to include Nucop's options
|
357
|
-
def options
|
358
|
-
return @_options if defined?(@_options)
|
359
|
-
|
360
|
-
original_options = super
|
361
|
-
@_options = Thor::CoreExt::HashWithIndifferentAccess.new(
|
362
|
-
configuration_options.merge(original_options)
|
363
|
-
)
|
364
|
-
end
|
365
|
-
|
366
|
-
def configuration_options
|
367
|
-
if File.exist?(CONFIGURATION_FILEPATH)
|
368
|
-
default_configuration.merge(YAML.load_file(CONFIGURATION_FILEPATH))
|
369
|
-
else
|
370
|
-
default_configuration
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
|
-
def default_configuration
|
375
|
-
{
|
376
|
-
enforced_cops_file: ".rubocop.enforced.yml",
|
377
|
-
rubocop_todo_file: ".rubocop_todo.yml",
|
378
|
-
rubocop_todo_config_file: ".rubocop.backlog.yml",
|
379
|
-
diffignore_file: ".nucop_diffignore"
|
380
|
-
}
|
381
|
-
end
|
382
383
|
end
|
383
384
|
end
|
@@ -15,7 +15,8 @@ module Nucop
|
|
15
15
|
#
|
16
16
|
# job = create(:job, project: project)
|
17
17
|
# build(:project, code: "Super Project")
|
18
|
-
class ExplicitFactoryBotUsage < ::RuboCop::Cop::
|
18
|
+
class ExplicitFactoryBotUsage < ::RuboCop::Cop::Base
|
19
|
+
extend RuboCop::Cop::AutoCorrector
|
19
20
|
include Helpers::FilePathHelper
|
20
21
|
|
21
22
|
MSG = "Do not explicitly use `%<constant>s` to build objects. The factory method `%<method>s` is globally available."
|
@@ -26,18 +27,14 @@ module Nucop
|
|
26
27
|
|
27
28
|
def on_send(node)
|
28
29
|
explicit_factory_bot_usage(node) do
|
29
|
-
add_offense(node, location: :expression, message: format(MSG, constant: node.receiver.const_name, method: node.method_name))
|
30
|
+
add_offense(node, location: :expression, message: format(MSG, constant: node.receiver.const_name, method: node.method_name)) do |corrector|
|
31
|
+
corrector.replace(node.source_range, node.source.sub(/(?:FactoryGirl|FactoryBot)[.]/, ""))
|
32
|
+
end
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
def relevant_file?(file)
|
34
37
|
acceptance_or_spec_file?(file) && super
|
35
38
|
end
|
36
|
-
|
37
|
-
def autocorrect(node)
|
38
|
-
->(corrector) do
|
39
|
-
corrector.replace(node.source_range, node.source.sub(/(?:FactoryGirl|FactoryBot)[.]/, ""))
|
40
|
-
end
|
41
|
-
end
|
42
39
|
end
|
43
40
|
end
|
@@ -16,7 +16,9 @@ module Nucop
|
|
16
16
|
# # good
|
17
17
|
#
|
18
18
|
# hash = {}
|
19
|
-
class OrderedHash < ::RuboCop::Cop::
|
19
|
+
class OrderedHash < ::RuboCop::Cop::Base
|
20
|
+
extend RuboCop::Cop::AutoCorrector
|
21
|
+
|
20
22
|
MSG = "Ruby hashes after 1.9 enumerate keys in order of insertion"
|
21
23
|
|
22
24
|
def_node_matcher :ordered_hash_usage, <<~PATTERN
|
@@ -25,17 +27,9 @@ module Nucop
|
|
25
27
|
|
26
28
|
def on_send(node)
|
27
29
|
ordered_hash_usage(node) do
|
28
|
-
add_offense(
|
29
|
-
node,
|
30
|
-
|
31
|
-
message: MSG
|
32
|
-
)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def autocorrect(node)
|
37
|
-
->(corrector) do
|
38
|
-
corrector.replace(node.source_range, "{}")
|
30
|
+
add_offense(node, location: :expression, message: MSG) do |corrector|
|
31
|
+
corrector.replace(node.source_range, "{}")
|
32
|
+
end
|
39
33
|
end
|
40
34
|
end
|
41
35
|
end
|
@@ -16,7 +16,9 @@ module Nucop
|
|
16
16
|
#
|
17
17
|
# release_toggle_enabled?(:move_out_of_wip_autocomplete)
|
18
18
|
#
|
19
|
-
class ReleaseTogglesUseSymbols < ::RuboCop::Cop::
|
19
|
+
class ReleaseTogglesUseSymbols < ::RuboCop::Cop::Base
|
20
|
+
extend RuboCop::Cop::AutoCorrector
|
21
|
+
|
20
22
|
MSG = "Use a symbol when referring to a Release Toggle's by name".freeze
|
21
23
|
|
22
24
|
def_node_matcher :test_helper?, <<~PATTERN
|
@@ -29,14 +31,12 @@ module Nucop
|
|
29
31
|
|
30
32
|
def on_send(node)
|
31
33
|
test_helper?(node) { add_offense(node, message: MSG, location: node.children[2].loc.expression) }
|
32
|
-
release_toggles_public_api_method?(node)
|
33
|
-
|
34
|
-
|
35
|
-
def autocorrect(node)
|
36
|
-
->(corrector) do
|
37
|
-
toggle_name = node.children[2].value
|
34
|
+
release_toggles_public_api_method?(node) do
|
35
|
+
add_offense(node, message: MSG, location: node.children[2].loc.expression) do |corrector|
|
36
|
+
toggle_name = node.children[2].value
|
38
37
|
|
39
|
-
|
38
|
+
corrector.replace(node.children[2].source_range, ":#{toggle_name}")
|
39
|
+
end
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -15,7 +15,7 @@ module Nucop
|
|
15
15
|
# def create_transfer_pallet(args)
|
16
16
|
# ...
|
17
17
|
# end
|
18
|
-
class ShadowingFactoryBotCreationMethods < ::RuboCop::Cop::
|
18
|
+
class ShadowingFactoryBotCreationMethods < ::RuboCop::Cop::Base
|
19
19
|
include Helpers::FilePathHelper
|
20
20
|
|
21
21
|
MSG = "Method `%<method>s` shadows a FactoryBot method. Please rename it to be more specific."
|
data/lib/nucop/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nucop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
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-
|
11
|
+
date: 2024-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.67'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.67'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop-capybara
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.22'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.22'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop-rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '2.
|
89
|
+
version: '2.26'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '2.
|
96
|
+
version: '2.26'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rubocop-rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '3.
|
117
|
+
version: '3.1'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '3.
|
124
|
+
version: '3.1'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rubocop-rspec_rails
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +178,20 @@ dependencies:
|
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '4.0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rexml
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '3.3'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '3.3'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: ruby-progressbar
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,14 +276,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
262
276
|
requirements:
|
263
277
|
- - ">="
|
264
278
|
- !ruby/object:Gem::Version
|
265
|
-
version: '3.
|
279
|
+
version: '3.2'
|
266
280
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
267
281
|
requirements:
|
268
282
|
- - ">="
|
269
283
|
- !ruby/object:Gem::Version
|
270
284
|
version: '0'
|
271
285
|
requirements: []
|
272
|
-
rubygems_version: 3.5.
|
286
|
+
rubygems_version: 3.5.21
|
273
287
|
signing_key:
|
274
288
|
specification_version: 4
|
275
289
|
summary: Nulogy's implementation of RuboCop, including custom cops and additional
|