gl_rubocop 0.2.10 → 0.2.12
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/default.yml +139 -132
- data/lib/gl_rubocop/gl_cops/interactor_inherits_from_interactor_base.rb +2 -2
- data/lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb +59 -0
- data/lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb +2 -2
- data/lib/gl_rubocop/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55107732ab588f104a0a8047cd22d55634bf9f237785b6198ea7e7e74b7d0683
|
4
|
+
data.tar.gz: 9ca9496cea775139741b2d3dfe50c886b423481ed9ef74adf830f829db70d80e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fdc8bf1a8612adcda9a5d98edf5a26d4c99936e4e388c961bff0b5dd092bb86a6b8087be567e451cde9dfc1aa0de49d043ed73445e48920f2f98da6a16c54e2
|
7
|
+
data.tar.gz: 9803a8d9a9122090726be40f0a66dca0d69b9a5424e29776cdf719020bc3d701cf79fb3f17ce13a07b98e99b78f2df79a08ea5fb2fc949814f7ac3f7f89bde8c
|
data/default.yml
CHANGED
@@ -5,8 +5,9 @@ require:
|
|
5
5
|
- rubocop-magic_numbers
|
6
6
|
- rubocop-haml
|
7
7
|
- rubocop-rake
|
8
|
-
- ./lib/gl_rubocop/gl_cops/interactor_inherits_from_interactor_base.rb
|
9
8
|
- ./lib/gl_rubocop/gl_cops/callback_method_names.rb
|
9
|
+
- ./lib/gl_rubocop/gl_cops/interactor_inherits_from_interactor_base.rb
|
10
|
+
- ./lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb
|
10
11
|
- ./lib/gl_rubocop/gl_cops/prevent_erb_files.rb
|
11
12
|
- ./lib/gl_rubocop/gl_cops/rails_cache.rb
|
12
13
|
- ./lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
|
@@ -27,12 +28,21 @@ AllCops:
|
|
27
28
|
- "vendor/**/*"
|
28
29
|
- "bin/**/*"
|
29
30
|
|
31
|
+
Capybara/ClickLinkOrButtonStyle:
|
32
|
+
EnforcedStyle: link_or_button
|
33
|
+
|
34
|
+
Capybara/NegationMatcher:
|
35
|
+
EnforcedStyle: not_to
|
36
|
+
|
37
|
+
GLCops/CallbackMethodNames:
|
38
|
+
Enabled: true
|
39
|
+
|
30
40
|
GLCops/InteractorInheritsFromInteractorBase:
|
31
41
|
Enabled: true
|
32
42
|
Include:
|
33
43
|
- "app/interactors/**/*"
|
34
44
|
|
35
|
-
GLCops/
|
45
|
+
GLCops/NoStubbingPerformAsync:
|
36
46
|
Enabled: true
|
37
47
|
|
38
48
|
GLCops/PreventErbFiles:
|
@@ -51,67 +61,62 @@ GLCops/UniqueIdentifier:
|
|
51
61
|
Include:
|
52
62
|
- "app/components/**/*.haml"
|
53
63
|
|
64
|
+
Layout/ClassStructure:
|
65
|
+
Enabled: true
|
66
|
+
|
54
67
|
Layout/LineLength:
|
55
|
-
Max: 100
|
56
68
|
AllowedPatterns:
|
57
69
|
- "^ *#" # Ignores full lines starting with any indentation and a comment (#)
|
70
|
+
Max: 100
|
58
71
|
|
59
72
|
Lint/MissingSuper:
|
60
73
|
Exclude:
|
61
74
|
- "app/components/**/*"
|
62
75
|
|
63
|
-
MagicNumbers/
|
76
|
+
MagicNumbers/NoArgument:
|
77
|
+
Enabled: true
|
64
78
|
Exclude:
|
65
79
|
- "spec/**/*"
|
66
80
|
- "**/spec/**/*"
|
67
|
-
|
81
|
+
PermittedValues:
|
82
|
+
- 0
|
83
|
+
- 1
|
84
|
+
|
85
|
+
MagicNumbers/NoAssignment:
|
68
86
|
AllowedAssignments:
|
69
87
|
- instance_variables
|
70
88
|
- class_variables
|
71
89
|
- global_variables
|
72
|
-
|
73
|
-
MagicNumbers/NoArgument:
|
90
|
+
Enabled: false
|
74
91
|
Exclude:
|
75
92
|
- "spec/**/*"
|
76
93
|
- "**/spec/**/*"
|
77
|
-
Enabled: true
|
78
|
-
PermittedValues:
|
79
|
-
- 0
|
80
|
-
- 1
|
81
94
|
|
82
95
|
MagicNumbers/NoDefault:
|
96
|
+
Enabled: true
|
83
97
|
Exclude:
|
84
98
|
- "spec/**/*"
|
85
99
|
- "**/spec/**/*"
|
86
|
-
Enabled: true
|
87
100
|
PermittedValues:
|
88
101
|
- 0
|
89
102
|
- 1
|
90
103
|
|
91
104
|
MagicNumbers/NoReturn:
|
105
|
+
Enabled: true
|
92
106
|
Exclude:
|
93
107
|
- "spec/**/*"
|
94
108
|
- "**/spec/**/*"
|
95
|
-
Enabled: true
|
96
109
|
PermittedReturnValues:
|
97
110
|
- 0
|
98
111
|
- 1
|
99
112
|
|
100
113
|
Metrics/AbcSize:
|
101
|
-
Max: 17
|
102
114
|
Exclude:
|
103
115
|
- "db/**/*"
|
104
116
|
- "spec/**/*"
|
105
117
|
- "config/routes.rb"
|
106
118
|
- "config/routes/*"
|
107
|
-
|
108
|
-
Metrics/MethodLength:
|
109
|
-
Max: 15
|
110
|
-
Exclude:
|
111
|
-
- "app/mailers/**/*"
|
112
|
-
- "config/routes/**/*"
|
113
|
-
- "db/**/*"
|
114
|
-
- "lib/tasks/**/*"
|
119
|
+
Max: 17
|
115
120
|
|
116
121
|
Metrics/BlockLength:
|
117
122
|
Exclude:
|
@@ -122,134 +127,157 @@ Metrics/BlockLength:
|
|
122
127
|
- "spec/**/*"
|
123
128
|
|
124
129
|
Metrics/ClassLength:
|
125
|
-
Max: 150
|
126
130
|
Exclude:
|
127
131
|
- "db/seeds/**/*"
|
132
|
+
Max: 150
|
128
133
|
|
129
134
|
Metrics/CyclomaticComplexity:
|
130
135
|
Exclude:
|
131
136
|
- "db/seeds/**/*"
|
132
137
|
|
133
|
-
Metrics/
|
138
|
+
Metrics/MethodLength:
|
134
139
|
Exclude:
|
135
|
-
- "
|
140
|
+
- "app/mailers/**/*"
|
141
|
+
- "config/routes/**/*"
|
142
|
+
- "db/**/*"
|
143
|
+
- "lib/tasks/**/*"
|
144
|
+
Max: 15
|
136
145
|
|
137
146
|
Metrics/ParameterLists:
|
138
147
|
Exclude:
|
139
148
|
- "db/seeds/**/*"
|
140
149
|
|
150
|
+
Metrics/PerceivedComplexity:
|
151
|
+
Exclude:
|
152
|
+
- "db/seeds/**/*"
|
153
|
+
|
154
|
+
Naming/MethodParameterName:
|
155
|
+
MinNameLength: 1
|
156
|
+
|
157
|
+
Naming/VariableNumber:
|
158
|
+
AllowedIdentifiers:
|
159
|
+
- is_501c3
|
160
|
+
- last4
|
161
|
+
- line1
|
162
|
+
- line2
|
163
|
+
- address_line1
|
164
|
+
- address_line2
|
165
|
+
- google_oauth2
|
166
|
+
- s3
|
167
|
+
- shift4
|
168
|
+
- Shift4
|
169
|
+
EnforcedStyle: "snake_case"
|
170
|
+
|
141
171
|
Performance/MapCompact:
|
142
172
|
Enabled: false
|
143
173
|
|
144
|
-
|
145
|
-
EnforcedStyle: prefer_alias_method
|
146
|
-
|
147
|
-
Style/AsciiComments:
|
174
|
+
RSpec/AnyInstance:
|
148
175
|
Enabled: false
|
149
176
|
|
150
|
-
|
151
|
-
|
177
|
+
RSpec/DescribeClass:
|
178
|
+
Exclude:
|
179
|
+
- "spec/api/**/*"
|
180
|
+
- "spec/views/**/*"
|
181
|
+
- "spec/lib/tasks/**/*"
|
152
182
|
|
153
|
-
|
183
|
+
RSpec/EmptyExampleGroup:
|
154
184
|
Exclude:
|
155
|
-
- "
|
185
|
+
- "spec/api/**/*"
|
156
186
|
|
157
|
-
|
158
|
-
|
187
|
+
RSpec/ExampleLength:
|
188
|
+
Exclude:
|
189
|
+
- "spec/lib/props_module_spec.rb"
|
190
|
+
- "spec/system/**/*"
|
191
|
+
- "spec/serializers/**/*"
|
192
|
+
Max: 30
|
159
193
|
|
160
|
-
|
161
|
-
Enabled:
|
194
|
+
RSpec/FilePath:
|
195
|
+
Enabled: true
|
196
|
+
Exclude:
|
197
|
+
- "packs/*/spec/**/*" # Because of automatic namespacing
|
162
198
|
|
163
|
-
|
164
|
-
|
199
|
+
RSpec/HookArgument:
|
200
|
+
Exclude:
|
201
|
+
- "spec/support/**/*"
|
165
202
|
|
166
|
-
|
203
|
+
RSpec/IndexedLet:
|
167
204
|
Enabled: false
|
168
205
|
|
169
|
-
|
206
|
+
RSpec/InstanceVariable:
|
207
|
+
Exclude:
|
208
|
+
- "spec/workers/salesforce/**/*"
|
209
|
+
- "spec/views/**/*"
|
210
|
+
- "spec/services/salesforce/**/*"
|
211
|
+
- "spec/controllers/salesforce_controller_spec.rb"
|
212
|
+
- "spec/controllers/v1/**/*"
|
213
|
+
|
214
|
+
RSpec/LetSetup:
|
170
215
|
Enabled: false
|
171
216
|
|
172
|
-
|
173
|
-
# This rule is incompatible with our split schema for datawarehouse models
|
174
|
-
# It is disabled by default in rubocop-rails
|
217
|
+
RSpec/MessageSpies:
|
175
218
|
Enabled: false
|
176
219
|
|
177
|
-
|
220
|
+
RSpec/MultipleExpectations:
|
178
221
|
Exclude:
|
179
|
-
- "spec/**/*"
|
222
|
+
- "spec/system/**/*"
|
223
|
+
Max: 5
|
224
|
+
|
225
|
+
RSpec/MultipleMemoizedHelpers:
|
226
|
+
Enabled: false
|
180
227
|
|
181
228
|
RSpec/NestedGroups:
|
182
|
-
Max: 6
|
183
229
|
Exclude:
|
184
230
|
- "spec/controllers/**/*"
|
185
231
|
- "spec/requests/**/*"
|
232
|
+
Max: 6
|
186
233
|
|
187
|
-
RSpec/
|
188
|
-
Max: 5
|
189
|
-
Exclude:
|
190
|
-
- "spec/system/**/*"
|
191
|
-
|
192
|
-
RSpec/ExampleLength:
|
193
|
-
Max: 30
|
194
|
-
Exclude:
|
195
|
-
- "spec/lib/props_module_spec.rb"
|
196
|
-
- "spec/system/**/*"
|
197
|
-
- "spec/serializers/**/*"
|
198
|
-
|
199
|
-
RSpec/AnyInstance:
|
234
|
+
RSpec/ReceiveMessages:
|
200
235
|
Enabled: false
|
201
236
|
|
202
|
-
RSpec/
|
237
|
+
RSpec/SortMetadata:
|
203
238
|
Enabled: false
|
204
239
|
|
240
|
+
RSpec/SpecFilePathFormat:
|
241
|
+
Enabled: true
|
242
|
+
Exclude:
|
243
|
+
- "packs/*/spec/**/*" # Because of automatic namespacing
|
244
|
+
|
245
|
+
RSpec/VariableName:
|
246
|
+
AllowedPatterns:
|
247
|
+
- "Authorization" # used in RSwag specs
|
248
|
+
|
205
249
|
RSpec/VerifiedDoubles:
|
206
250
|
IgnoreSymbolicNames: true
|
207
251
|
|
208
|
-
|
252
|
+
RSpecRails/InferredSpecType:
|
253
|
+
Enabled: false
|
254
|
+
|
255
|
+
Rails/ApplicationRecord:
|
209
256
|
Exclude:
|
210
|
-
- "
|
211
|
-
- "db/**/*"
|
257
|
+
- "db/migrate/*"
|
212
258
|
|
213
|
-
|
259
|
+
Rails/BulkChangeTable:
|
214
260
|
Enabled: false
|
215
261
|
|
216
|
-
|
262
|
+
Rails/CreateTableWithTimestamps:
|
217
263
|
Enabled: false
|
218
264
|
|
219
|
-
Rails/
|
220
|
-
|
221
|
-
- "db/seeds/**/*"
|
222
|
-
|
223
|
-
RSpec/EmptyExampleGroup:
|
224
|
-
Exclude:
|
225
|
-
- "spec/api/**/*"
|
226
|
-
|
227
|
-
RSpec/DescribeClass:
|
228
|
-
Exclude:
|
229
|
-
- "spec/api/**/*"
|
230
|
-
- "spec/views/**/*"
|
231
|
-
- "spec/lib/tasks/**/*"
|
265
|
+
Rails/FindEach:
|
266
|
+
Enabled: false
|
232
267
|
|
233
|
-
Rails/
|
234
|
-
|
235
|
-
- "db/migrate/*"
|
268
|
+
Rails/I18nLocaleTexts:
|
269
|
+
Enabled: false
|
236
270
|
|
237
|
-
|
271
|
+
Rails/Output:
|
238
272
|
Exclude:
|
239
|
-
- "
|
273
|
+
- "db/seeds/**/*"
|
240
274
|
|
241
|
-
|
275
|
+
Rails/SkipsModelValidations:
|
242
276
|
Exclude:
|
243
|
-
- "spec
|
244
|
-
- "
|
245
|
-
- "spec/services/salesforce/**/*"
|
246
|
-
- "spec/controllers/salesforce_controller_spec.rb"
|
247
|
-
- "spec/controllers/v1/**/*"
|
248
|
-
|
249
|
-
Rails/BulkChangeTable:
|
250
|
-
Enabled: false
|
277
|
+
- "spec/**/*"
|
278
|
+
- "db/**/*"
|
251
279
|
|
252
|
-
Rails/
|
280
|
+
Rails/TimeZone:
|
253
281
|
Enabled: false
|
254
282
|
|
255
283
|
Rails/UnknownEnv:
|
@@ -261,54 +289,33 @@ Rails/UnknownEnv:
|
|
261
289
|
- production
|
262
290
|
- test
|
263
291
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
Style/MultilineBlockChain:
|
292
|
+
Rails/UnusedIgnoredColumns:
|
293
|
+
# This rule is incompatible with our split schema for datawarehouse models
|
294
|
+
# It is disabled by default in rubocop-rails
|
268
295
|
Enabled: false
|
269
296
|
|
270
|
-
|
271
|
-
EnforcedStyle:
|
272
|
-
AllowedIdentifiers:
|
273
|
-
- is_501c3
|
274
|
-
- last4
|
275
|
-
- line1
|
276
|
-
- line2
|
277
|
-
- address_line1
|
278
|
-
- address_line2
|
279
|
-
- google_oauth2
|
280
|
-
- s3
|
281
|
-
- shift4
|
282
|
-
- Shift4
|
297
|
+
Style/Alias:
|
298
|
+
EnforcedStyle: prefer_alias_method
|
283
299
|
|
284
|
-
|
300
|
+
Style/AsciiComments:
|
285
301
|
Enabled: false
|
286
302
|
|
287
|
-
|
288
|
-
|
303
|
+
Style/ClassAndModuleChildren:
|
304
|
+
Exclude:
|
305
|
+
- "app/controllers/smart_donations_legacy/**/*"
|
289
306
|
|
290
|
-
|
307
|
+
Style/Documentation:
|
291
308
|
Enabled: false
|
292
309
|
|
293
|
-
|
310
|
+
Style/FrozenStringLiteralComment:
|
294
311
|
Enabled: false
|
295
312
|
|
296
|
-
|
297
|
-
Enabled: true
|
298
|
-
Exclude:
|
299
|
-
- "packs/*/spec/**/*" # Because of automatic namespacing
|
300
|
-
|
301
|
-
RSpec/SpecFilePathFormat:
|
302
|
-
Enabled: true
|
313
|
+
Style/GlobalVars:
|
303
314
|
Exclude:
|
304
|
-
- "
|
305
|
-
|
306
|
-
RSpec/VariableName:
|
307
|
-
AllowedPatterns:
|
308
|
-
- "Authorization" # used in RSwag specs
|
315
|
+
- "spec/**/*"
|
309
316
|
|
310
|
-
|
311
|
-
|
317
|
+
Style/HashAsLastArrayItem:
|
318
|
+
Enabled: false
|
312
319
|
|
313
|
-
|
314
|
-
|
320
|
+
Style/MultilineBlockChain:
|
321
|
+
Enabled: false
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module GLRubocop
|
2
2
|
module GLCops
|
3
3
|
class InteractorInheritsFromInteractorBase < RuboCop::Cop::Cop
|
4
|
+
MSG = 'Interactor should inherit from InteractorBase'.freeze
|
5
|
+
|
4
6
|
def on_class(klass)
|
5
7
|
return unless klass.instance_of?(RuboCop::AST::ClassNode)
|
6
8
|
return unless klass.parent_class.nil?
|
7
9
|
|
8
10
|
add_offense(klass)
|
9
11
|
end
|
10
|
-
|
11
|
-
MSG = 'Interactor should inherit from InteractorBase'.freeze
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module GLRubocop
|
2
|
+
module GLCops
|
3
|
+
# This cop ensures that you don't stub perform_async. Stubbing prevents seeing errors from
|
4
|
+
# invalid argumens - because sidekiq arguments have to be valid JSON data types:
|
5
|
+
# github.com/sidekiq/sidekiq/wiki/Best-Practices#1-make-your-job-parameters-small-and-simple
|
6
|
+
#
|
7
|
+
# Good:
|
8
|
+
# expect(ExampleWorker).to have_enqueued_sidekiq_job
|
9
|
+
|
10
|
+
#
|
11
|
+
# Bad:
|
12
|
+
# allow(ExampleWorker).to receive(:perform_async)
|
13
|
+
# expect(ExampleWorker).to receive(:perform_async)
|
14
|
+
# expect(SomeWorker).not_to have_received(:perform_in)
|
15
|
+
class NoStubbingPerformAsync < RuboCop::Cop::Cop
|
16
|
+
MSG = "Don't stub perform async. Use the rspec-sidekick matchers instead: " \
|
17
|
+
'expect(JobClass).to have_enqueued_sidekiq_job'.freeze
|
18
|
+
|
19
|
+
# This pattern captures expectations for perform_async and perform_in
|
20
|
+
# expect(SomeWorker).not_to have_received(:perform_async)
|
21
|
+
# expect(SomeWorker).to have_received(:perform_async)
|
22
|
+
# expect(SomeWorker).to have_received(:perform_in)
|
23
|
+
def_node_matcher :perform_method_expectation?, <<~PATTERN
|
24
|
+
(send#{' '}
|
25
|
+
(send nil? :expect $_)#{' '}
|
26
|
+
{:not_to :to_not :to}#{' '}
|
27
|
+
(send nil? :have_received (sym {:perform_async :perform_in}) ...))
|
28
|
+
PATTERN
|
29
|
+
|
30
|
+
# This pattern captures allow statements for perform_async and perform_in
|
31
|
+
# allow(SomeWorker).to receive(:perform_async)
|
32
|
+
# allow(SomeWorker).to receive(:perform_in)
|
33
|
+
def_node_matcher :perform_method_allow?, <<~PATTERN
|
34
|
+
(send
|
35
|
+
(send nil? :allow $_)
|
36
|
+
:to
|
37
|
+
(send nil? :receive (sym {:perform_async :perform_in}) ...))
|
38
|
+
PATTERN
|
39
|
+
|
40
|
+
def on_send(node)
|
41
|
+
check_expectation(node) || check_allow(node)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def check_expectation(node)
|
47
|
+
perform_method_expectation?(node) { return add_offense(node) }
|
48
|
+
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
def check_allow(node)
|
53
|
+
perform_method_allow?(node) { return add_offense(node) }
|
54
|
+
|
55
|
+
false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module GLRubocop
|
2
2
|
module GLCops
|
3
3
|
class SidekiqInheritsFromSidekiqJob < RuboCop::Cop::Cop
|
4
|
+
MSG = 'All Sidekiq workers and jobs should inherit from SidekiqJob'.freeze
|
5
|
+
|
4
6
|
def on_class(klass)
|
5
7
|
return unless klass.instance_of?(RuboCop::AST::ClassNode)
|
6
8
|
return if klass.parent_class.present? || klass.identifier.short_name == :SidekiqJob
|
7
9
|
|
8
10
|
add_offense(klass)
|
9
11
|
end
|
10
|
-
|
11
|
-
MSG = 'All Sidekiq workers and jobs should inherit from SidekiqJob'.freeze
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/gl_rubocop/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gl_rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Give Lively
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/gl_rubocop.rb
|
123
123
|
- lib/gl_rubocop/gl_cops/callback_method_names.rb
|
124
124
|
- lib/gl_rubocop/gl_cops/interactor_inherits_from_interactor_base.rb
|
125
|
+
- lib/gl_rubocop/gl_cops/no_stubbing_perform_async.rb
|
125
126
|
- lib/gl_rubocop/gl_cops/prevent_erb_files.rb
|
126
127
|
- lib/gl_rubocop/gl_cops/rails_cache.rb
|
127
128
|
- lib/gl_rubocop/gl_cops/sidekiq_inherits_from_sidekiq_job.rb
|