carwow_rubocop 6.9.0 → 6.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/.circleci/config.yml +1 -1
- data/Gemfile.lock +2 -2
- data/config/rubocop-carwow.yml +7 -0
- data/lib/rubocop/carwow/version.rb +1 -1
- data/lib/rubocop/cop/carwow/jobs_queue_name_style.rb +39 -12
- data/lib/rubocop/cop/carwow/no_abort.rb +39 -0
- data/lib/rubocop/cop/carwow/no_stubbing_honeycomb_extra_data.rb +31 -0
- metadata +5 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 81c9278bdc99387df9c9a136d4a6048cf21435c6a760351b7c1be3a82a0df801
|
|
4
|
+
data.tar.gz: df963ba3013bb0fb3196a57580f06af6136eb7f89eea4f5966982da2a39ea2da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8546625ac8e9267800cd53cda4614787ebd99abc8aa446ba5e86cdde53b2dfb780523386172e1b16eb534289ed5f9d7d7287d9af6817878d0c2cecd867057275
|
|
7
|
+
data.tar.gz: bdb3822f28558aa5a062282b09f6ceadb327dfae8bce7fe3363d4124ff3f34f5977ff1f48657798b7732650edd77245236b5144e41f96f723f1a5f72d3e7d0bd
|
data/.circleci/config.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
carwow_rubocop (6.
|
|
4
|
+
carwow_rubocop (6.12.0)
|
|
5
5
|
rubocop (>= 1.75)
|
|
6
6
|
rubocop-factory_bot
|
|
7
7
|
rubocop-performance
|
|
@@ -17,7 +17,7 @@ GEM
|
|
|
17
17
|
language_server-protocol (3.17.0.6)
|
|
18
18
|
lint_roller (1.1.0)
|
|
19
19
|
method_source (1.1.0)
|
|
20
|
-
parallel (
|
|
20
|
+
parallel (1.28.0)
|
|
21
21
|
parser (3.3.12.0)
|
|
22
22
|
ast (~> 2.4.1)
|
|
23
23
|
racc
|
data/config/rubocop-carwow.yml
CHANGED
|
@@ -32,6 +32,10 @@ Carwow/NoStubbingBusinessEvent:
|
|
|
32
32
|
- "**/*_spec.rb"
|
|
33
33
|
- "**/spec/**/*"
|
|
34
34
|
|
|
35
|
+
Carwow/NoStubbingHoneycombExtraData:
|
|
36
|
+
Enabled: true
|
|
37
|
+
Include: *spec_only
|
|
38
|
+
|
|
35
39
|
Carwow/AddColumnWithComment:
|
|
36
40
|
Enabled: true
|
|
37
41
|
Include: &migrations_only
|
|
@@ -53,3 +57,6 @@ Carwow/ProductAreaRequired:
|
|
|
53
57
|
- "app/jobs/**/*.rb"
|
|
54
58
|
Exclude:
|
|
55
59
|
- "**/concerns/**/*.rb"
|
|
60
|
+
|
|
61
|
+
Carwow/NoAbort:
|
|
62
|
+
Enabled: true
|
|
@@ -24,6 +24,11 @@ module RuboCop
|
|
|
24
24
|
# queue_as :with_symbol
|
|
25
25
|
# end
|
|
26
26
|
#
|
|
27
|
+
# # bad - literals returned from a block are checked too
|
|
28
|
+
# class Bad < ApplicationJob
|
|
29
|
+
# queue_as { urgent? ? :with_symbol : "with_string" }
|
|
30
|
+
# end
|
|
31
|
+
#
|
|
27
32
|
#
|
|
28
33
|
class JobsQueueNameStyle < ::RuboCop::Cop::Base
|
|
29
34
|
extend AutoCorrector
|
|
@@ -42,27 +47,49 @@ module RuboCop
|
|
|
42
47
|
# optimization: don't call `on_send` unless the method name is in this list
|
|
43
48
|
RESTRICT_ON_SEND = %i[queue_as].freeze
|
|
44
49
|
def on_send(node)
|
|
45
|
-
|
|
50
|
+
queue_names(node).each do |queue_name|
|
|
51
|
+
next if preferred_style?(queue_name)
|
|
46
52
|
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
add_offense(queue_name, message: (prefer_symbol? ? MSG : MSG_STRING)) do |corrector|
|
|
54
|
+
content, _other = *queue_name
|
|
55
|
+
fix = prefer_symbol? ? ":#{content}" : content.to_s.inspect
|
|
49
56
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
fix = prefer_symbol? ? ":#{content}" : content.to_s.inspect
|
|
53
|
-
|
|
54
|
-
corrector.replace(queue_name, fix)
|
|
57
|
+
corrector.replace(queue_name, fix)
|
|
58
|
+
end
|
|
55
59
|
end
|
|
56
60
|
end
|
|
57
61
|
|
|
58
62
|
private
|
|
59
63
|
|
|
60
|
-
def
|
|
61
|
-
|
|
64
|
+
def queue_names(node)
|
|
65
|
+
return [node.first_argument].compact unless node.block_node
|
|
66
|
+
|
|
67
|
+
# The queue is computed at runtime, so only the literals the block can return are checked.
|
|
68
|
+
possible_return_values(node.block_node.body).select { |value| value&.type?(:sym, :str) }
|
|
62
69
|
end
|
|
63
70
|
|
|
64
|
-
def
|
|
65
|
-
|
|
71
|
+
def possible_return_values(node)
|
|
72
|
+
return [node] unless node
|
|
73
|
+
|
|
74
|
+
case node.type
|
|
75
|
+
when :begin then possible_return_values(node.children.last)
|
|
76
|
+
when :if then [node.if_branch, node.else_branch].flat_map { |branch| possible_return_values(branch) }
|
|
77
|
+
when :case then possible_case_return_values(node)
|
|
78
|
+
else [node]
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def possible_case_return_values(node)
|
|
83
|
+
branches = node.when_branches.map(&:body) + [node.else_branch]
|
|
84
|
+
branches.flat_map { |branch| possible_return_values(branch) }
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def preferred_style?(queue_name)
|
|
88
|
+
prefer_symbol? ? queue_name.sym_type? : queue_name.str_type?
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def prefer_symbol?
|
|
92
|
+
!cop_config.fetch('QueueNameAs', 'Symbol').casecmp('string').zero?
|
|
66
93
|
end
|
|
67
94
|
end
|
|
68
95
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rubocop'
|
|
4
|
+
|
|
5
|
+
module RuboCop
|
|
6
|
+
module Cop
|
|
7
|
+
module Carwow
|
|
8
|
+
# Don't call `abort`. It raises `SystemExit`, which RSpec does not rescue, so when it
|
|
9
|
+
# escapes an example the whole process exits. Under a parallel runner the worker dies
|
|
10
|
+
# and its remaining spec files silently never run, while the suite reports 0 failures.
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
# # bad
|
|
14
|
+
# abort 'Nothing to do' if dealers.empty?
|
|
15
|
+
#
|
|
16
|
+
# # good - in a rake task
|
|
17
|
+
# next puts('Nothing to do') if dealers.empty?
|
|
18
|
+
#
|
|
19
|
+
# # good
|
|
20
|
+
# raise ArgumentError, 'Nothing to do' if dealers.empty?
|
|
21
|
+
#
|
|
22
|
+
class NoAbort < ::RuboCop::Cop::Base
|
|
23
|
+
MSG = "Don't use `abort`. It raises `SystemExit`, which RSpec does not rescue, so a spec that " \
|
|
24
|
+
'reaches it kills the whole worker and its remaining spec files never run. Return early ' \
|
|
25
|
+
'(`next puts(...)` in a rake task) or raise an error instead.'
|
|
26
|
+
|
|
27
|
+
RESTRICT_ON_SEND = %i[abort].freeze
|
|
28
|
+
|
|
29
|
+
def_node_matcher :kernel_abort?, <<~PATTERN
|
|
30
|
+
(send {nil? (const {nil? cbase} :Kernel)} :abort ...)
|
|
31
|
+
PATTERN
|
|
32
|
+
|
|
33
|
+
def on_send(node)
|
|
34
|
+
add_offense(node) if kernel_abort?(node)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rubocop'
|
|
4
|
+
|
|
5
|
+
module RuboCop
|
|
6
|
+
module Cop
|
|
7
|
+
module Carwow
|
|
8
|
+
class NoStubbingHoneycombExtraData < ::RuboCop::Cop::Base
|
|
9
|
+
MSG = "Don't stub or spy on `append_extra_honeycomb_data`. Other code (ActiveSupport::Notifications " \
|
|
10
|
+
'subscribers, product area tagging, Faraday middleware) appends to the same store, so expectations ' \
|
|
11
|
+
'on individual calls break when calls are split, merged or reordered. Do the work, then assert ' \
|
|
12
|
+
"on the data instead: `expect('some.key' => value).to have_been_appended_to_honeycomb_event`, " \
|
|
13
|
+
"or `expect { perform }.to append_to_honeycomb_event('some.key' => value)` to only check what " \
|
|
14
|
+
'the block appended. Both come from `CarwowCore::Spec::HoneycombHelper` in `carwow_core/spec`.'
|
|
15
|
+
|
|
16
|
+
RESTRICT_ON_SEND = %i[receive have_received receive_messages].freeze
|
|
17
|
+
|
|
18
|
+
def_node_matcher :stubs_append?, <<~PATTERN
|
|
19
|
+
{
|
|
20
|
+
(send nil? {:receive :have_received} {(sym :append_extra_honeycomb_data) (str "append_extra_honeycomb_data")})
|
|
21
|
+
(send nil? :receive_messages (hash <(pair (sym :append_extra_honeycomb_data) _) ...>))
|
|
22
|
+
}
|
|
23
|
+
PATTERN
|
|
24
|
+
|
|
25
|
+
def on_send(node)
|
|
26
|
+
add_offense(node) if stubs_append?(node)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: carwow_rubocop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- carwow Developers
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bundler
|
|
@@ -163,8 +162,10 @@ files:
|
|
|
163
162
|
- lib/rubocop/cop/carwow/jobs.rb
|
|
164
163
|
- lib/rubocop/cop/carwow/jobs_must_define_queue.rb
|
|
165
164
|
- lib/rubocop/cop/carwow/jobs_queue_name_style.rb
|
|
165
|
+
- lib/rubocop/cop/carwow/no_abort.rb
|
|
166
166
|
- lib/rubocop/cop/carwow/no_change_matcher_with_browser_action.rb
|
|
167
167
|
- lib/rubocop/cop/carwow/no_stubbing_business_event.rb
|
|
168
|
+
- lib/rubocop/cop/carwow/no_stubbing_honeycomb_extra_data.rb
|
|
168
169
|
- lib/rubocop/cop/carwow/no_vehicle_brand_model_sideload.rb
|
|
169
170
|
- lib/rubocop/cop/carwow/product_area_required.rb
|
|
170
171
|
homepage: https://github.com/carwow/carwow_rubocop
|
|
@@ -173,7 +174,6 @@ licenses:
|
|
|
173
174
|
metadata:
|
|
174
175
|
allowed_push_host: https://rubygems.org
|
|
175
176
|
rubygems_mfa_required: 'true'
|
|
176
|
-
post_install_message:
|
|
177
177
|
rdoc_options: []
|
|
178
178
|
require_paths:
|
|
179
179
|
- lib
|
|
@@ -188,8 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
188
188
|
- !ruby/object:Gem::Version
|
|
189
189
|
version: '0'
|
|
190
190
|
requirements: []
|
|
191
|
-
rubygems_version: 3.
|
|
192
|
-
signing_key:
|
|
191
|
+
rubygems_version: 3.6.9
|
|
193
192
|
specification_version: 4
|
|
194
193
|
summary: carwow's rubocop configuration
|
|
195
194
|
test_files: []
|