carwow_rubocop 6.9.0 → 6.11.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 978ba9d52dc3a0f7c586dab02666847b3e7ac2bcc62990909b4ecab964e794d8
|
|
4
|
+
data.tar.gz: 35c9f5b58b396765fef73fa76e622ce28029843a96fc25f6f434897a9333cdcd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51ca0f3638fd002ef701414af166ff97f63ab65f28031e385130e3813721b534ef88e75ecb3b36988d303c040a0df710552d2e210b4b242387df97a10dae2f43
|
|
7
|
+
data.tar.gz: d4a8e1e9941469ac1a1a3f88a803ddcf38c2f8992f1aefd14a0ffdb97ceda74af045de2717c49e196c072fbedc162779014457ac14ecd0eb8374c04f575d924e
|
data/Gemfile.lock
CHANGED
data/config/rubocop-carwow.yml
CHANGED
|
@@ -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,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.11.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
|
|
@@ -165,6 +164,7 @@ files:
|
|
|
165
164
|
- lib/rubocop/cop/carwow/jobs_queue_name_style.rb
|
|
166
165
|
- lib/rubocop/cop/carwow/no_change_matcher_with_browser_action.rb
|
|
167
166
|
- lib/rubocop/cop/carwow/no_stubbing_business_event.rb
|
|
167
|
+
- lib/rubocop/cop/carwow/no_stubbing_honeycomb_extra_data.rb
|
|
168
168
|
- lib/rubocop/cop/carwow/no_vehicle_brand_model_sideload.rb
|
|
169
169
|
- lib/rubocop/cop/carwow/product_area_required.rb
|
|
170
170
|
homepage: https://github.com/carwow/carwow_rubocop
|
|
@@ -173,7 +173,6 @@ licenses:
|
|
|
173
173
|
metadata:
|
|
174
174
|
allowed_push_host: https://rubygems.org
|
|
175
175
|
rubygems_mfa_required: 'true'
|
|
176
|
-
post_install_message:
|
|
177
176
|
rdoc_options: []
|
|
178
177
|
require_paths:
|
|
179
178
|
- lib
|
|
@@ -188,8 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
188
187
|
- !ruby/object:Gem::Version
|
|
189
188
|
version: '0'
|
|
190
189
|
requirements: []
|
|
191
|
-
rubygems_version: 3.
|
|
192
|
-
signing_key:
|
|
190
|
+
rubygems_version: 3.6.9
|
|
193
191
|
specification_version: 4
|
|
194
192
|
summary: carwow's rubocop configuration
|
|
195
193
|
test_files: []
|