rubocop-sidekiq_plus 0.1.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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +322 -0
- data/config/default.yml +396 -0
- data/lib/rubocop/cop/sidekiq/active_record_argument.rb +77 -0
- data/lib/rubocop/cop/sidekiq/async_in_test.rb +42 -0
- data/lib/rubocop/cop/sidekiq/base.rb +14 -0
- data/lib/rubocop/cop/sidekiq/consistent_job_suffix.rb +44 -0
- data/lib/rubocop/cop/sidekiq/constant_job_class_name.rb +53 -0
- data/lib/rubocop/cop/sidekiq/database_connection_leak.rb +33 -0
- data/lib/rubocop/cop/sidekiq/date_time_argument.rb +80 -0
- data/lib/rubocop/cop/sidekiq/deprecated_default_worker_options.rb +44 -0
- data/lib/rubocop/cop/sidekiq/deprecated_delay_extension.rb +29 -0
- data/lib/rubocop/cop/sidekiq/deprecated_worker_module.rb +40 -0
- data/lib/rubocop/cop/sidekiq/enqueue_inefficiency.rb +75 -0
- data/lib/rubocop/cop/sidekiq/excessive_retry.rb +52 -0
- data/lib/rubocop/cop/sidekiq/find_each_in_job.rb +58 -0
- data/lib/rubocop/cop/sidekiq/huge_job_arguments.rb +73 -0
- data/lib/rubocop/cop/sidekiq/job_dependency.rb +30 -0
- data/lib/rubocop/cop/sidekiq/job_file_location.rb +52 -0
- data/lib/rubocop/cop/sidekiq/job_file_naming.rb +38 -0
- data/lib/rubocop/cop/sidekiq/job_include.rb +67 -0
- data/lib/rubocop/cop/sidekiq/missing_logging.rb +49 -0
- data/lib/rubocop/cop/sidekiq/missing_timeout.rb +65 -0
- data/lib/rubocop/cop/sidekiq/mixed_retry_strategies.rb +55 -0
- data/lib/rubocop/cop/sidekiq/mixin/argument_traversal.rb +28 -0
- data/lib/rubocop/cop/sidekiq/mixin/class_name_helper.rb +23 -0
- data/lib/rubocop/cop/sidekiq/mixin/processed_source_path.rb +19 -0
- data/lib/rubocop/cop/sidekiq/no_rescue_all.rb +70 -0
- data/lib/rubocop/cop/sidekiq/perform_inline_usage.rb +53 -0
- data/lib/rubocop/cop/sidekiq/perform_method_parameters.rb +53 -0
- data/lib/rubocop/cop/sidekiq/pii_in_arguments.rb +90 -0
- data/lib/rubocop/cop/sidekiq/puts_or_print_usage.rb +37 -0
- data/lib/rubocop/cop/sidekiq/queue_specified.rb +74 -0
- data/lib/rubocop/cop/sidekiq/redis_in_job.rb +32 -0
- data/lib/rubocop/cop/sidekiq/retry_specified.rb +81 -0
- data/lib/rubocop/cop/sidekiq/retry_zero.rb +48 -0
- data/lib/rubocop/cop/sidekiq/self_scheduling_job.rb +54 -0
- data/lib/rubocop/cop/sidekiq/sensitive_data_in_arguments.rb +92 -0
- data/lib/rubocop/cop/sidekiq/sidekiq_over_active_job.rb +30 -0
- data/lib/rubocop/cop/sidekiq/silent_rescue.rb +63 -0
- data/lib/rubocop/cop/sidekiq/sleep_in_jobs.rb +46 -0
- data/lib/rubocop/cop/sidekiq/symbol_argument.rb +69 -0
- data/lib/rubocop/cop/sidekiq/thread_in_job.rb +53 -0
- data/lib/rubocop/cop/sidekiq/transaction_leak.rb +72 -0
- data/lib/rubocop/cop/sidekiq/unknown_sidekiq_option.rb +52 -0
- data/lib/rubocop/cop/sidekiq_cops.rb +71 -0
- data/lib/rubocop/cop/sidekiq_ent/base.rb +43 -0
- data/lib/rubocop/cop/sidekiq_ent/encryption_with_many_arguments.rb +71 -0
- data/lib/rubocop/cop/sidekiq_ent/encryption_without_secret_bag.rb +83 -0
- data/lib/rubocop/cop/sidekiq_ent/leader_election_without_block.rb +75 -0
- data/lib/rubocop/cop/sidekiq_ent/limiter_not_reused.rb +79 -0
- data/lib/rubocop/cop/sidekiq_ent/limiter_without_lock_timeout.rb +46 -0
- data/lib/rubocop/cop/sidekiq_ent/limiter_without_wait_timeout.rb +49 -0
- data/lib/rubocop/cop/sidekiq_ent/periodic_job_invalid_cron.rb +108 -0
- data/lib/rubocop/cop/sidekiq_ent/periodic_job_with_arguments.rb +94 -0
- data/lib/rubocop/cop/sidekiq_ent/unique_job_too_short_ttl.rb +80 -0
- data/lib/rubocop/cop/sidekiq_ent/unique_job_without_ttl.rb +52 -0
- data/lib/rubocop/cop/sidekiq_ent/unique_until_mismatch.rb +59 -0
- data/lib/rubocop/cop/sidekiq_pro/base.rb +39 -0
- data/lib/rubocop/cop/sidekiq_pro/batch_callback_method.rb +66 -0
- data/lib/rubocop/cop/sidekiq_pro/batch_retry_in_callback.rb +54 -0
- data/lib/rubocop/cop/sidekiq_pro/batch_status_polling.rb +68 -0
- data/lib/rubocop/cop/sidekiq_pro/batch_without_callback.rb +92 -0
- data/lib/rubocop/cop/sidekiq_pro/empty_batch.rb +108 -0
- data/lib/rubocop/cop/sidekiq_pro/expiring_job_without_ttl.rb +101 -0
- data/lib/rubocop/cop/sidekiq_pro/large_argument_in_batch.rb +93 -0
- data/lib/rubocop/cop/sidekiq_pro/nested_batch_without_parent.rb +55 -0
- data/lib/rubocop/cop/sidekiq_pro/reliability_not_enabled.rb +67 -0
- data/lib/rubocop/sidekiq/config_formatter.rb +60 -0
- data/lib/rubocop/sidekiq/description_extractor.rb +70 -0
- data/lib/rubocop/sidekiq/language.rb +79 -0
- data/lib/rubocop/sidekiq/plugin.rb +30 -0
- data/lib/rubocop/sidekiq/version.rb +7 -0
- data/lib/rubocop/sidekiq.rb +10 -0
- data/lib/rubocop-sidekiq.rb +5 -0
- data/lib/rubocop-sidekiq_plus.rb +9 -0
- metadata +150 -0
data/config/default.yml
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
---
|
|
2
|
+
Sidekiq:
|
|
3
|
+
Enabled: true
|
|
4
|
+
DocumentationBaseURL: https://github.com/ydah/rubocop-sidekiq/blob/main/docs/modules/ROOT/pages
|
|
5
|
+
|
|
6
|
+
Sidekiq/ActiveRecordArgument:
|
|
7
|
+
Description: Do not pass ActiveRecord objects to Sidekiq jobs.
|
|
8
|
+
Enabled: true
|
|
9
|
+
VersionAdded: '0.1'
|
|
10
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/ActiveRecordArgument
|
|
11
|
+
|
|
12
|
+
Sidekiq/AsyncInTest:
|
|
13
|
+
Description: Prefer perform_inline over perform_async in tests.
|
|
14
|
+
Enabled: false
|
|
15
|
+
VersionAdded: '0.1'
|
|
16
|
+
Include:
|
|
17
|
+
- spec/**/*_spec.rb
|
|
18
|
+
- test/**/*_test.rb
|
|
19
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/AsyncInTest
|
|
20
|
+
|
|
21
|
+
Sidekiq/ConsistentJobSuffix:
|
|
22
|
+
Description: Enforce consistent job class name suffix.
|
|
23
|
+
Enabled: false
|
|
24
|
+
VersionAdded: '0.1'
|
|
25
|
+
EnforcedSuffix: Job
|
|
26
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/ConsistentJobSuffix
|
|
27
|
+
|
|
28
|
+
Sidekiq/ConstantJobClassName:
|
|
29
|
+
Description: Ensure job class names are constant.
|
|
30
|
+
Enabled: true
|
|
31
|
+
VersionAdded: '0.1'
|
|
32
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/ConstantJobClassName
|
|
33
|
+
|
|
34
|
+
Sidekiq/DatabaseConnectionLeak:
|
|
35
|
+
Description: Ensure database connections are properly released.
|
|
36
|
+
Enabled: true
|
|
37
|
+
VersionAdded: '0.1'
|
|
38
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/DatabaseConnectionLeak
|
|
39
|
+
|
|
40
|
+
Sidekiq/DateTimeArgument:
|
|
41
|
+
Description: Do not pass Date/Time objects to Sidekiq jobs.
|
|
42
|
+
Enabled: true
|
|
43
|
+
VersionAdded: '0.1'
|
|
44
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/DateTimeArgument
|
|
45
|
+
|
|
46
|
+
Sidekiq/DeprecatedDefaultWorkerOptions:
|
|
47
|
+
Description: Detect deprecated Sidekiq.default_worker_options usage.
|
|
48
|
+
Enabled: true
|
|
49
|
+
VersionAdded: '0.1'
|
|
50
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/DeprecatedDefaultWorkerOptions
|
|
51
|
+
|
|
52
|
+
Sidekiq/DeprecatedDelayExtension:
|
|
53
|
+
Description: Detect deprecated delay extension usage.
|
|
54
|
+
Enabled: true
|
|
55
|
+
VersionAdded: '0.1'
|
|
56
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/DeprecatedDelayExtension
|
|
57
|
+
|
|
58
|
+
Sidekiq/DeprecatedWorkerModule:
|
|
59
|
+
Description: Detect Sidekiq::Worker usage and prefer Sidekiq::Job.
|
|
60
|
+
Enabled: true
|
|
61
|
+
VersionAdded: '0.1'
|
|
62
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/DeprecatedWorkerModule
|
|
63
|
+
|
|
64
|
+
Sidekiq/EnqueueInefficiency:
|
|
65
|
+
Description: Prefer perform_bulk over perform_async inside loops.
|
|
66
|
+
Enabled: true
|
|
67
|
+
VersionAdded: '0.1'
|
|
68
|
+
AllowedMethods:
|
|
69
|
+
- each
|
|
70
|
+
- find_each
|
|
71
|
+
- find_in_batches
|
|
72
|
+
MinimumIterations: ~
|
|
73
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/EnqueueInefficiency
|
|
74
|
+
|
|
75
|
+
Sidekiq/ExcessiveRetry:
|
|
76
|
+
Description: Detect excessive retry counts.
|
|
77
|
+
Enabled: false
|
|
78
|
+
VersionAdded: '0.1'
|
|
79
|
+
MaxRetries: 25
|
|
80
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/ExcessiveRetry
|
|
81
|
+
|
|
82
|
+
Sidekiq/FindEachInJob:
|
|
83
|
+
Description: Avoid processing large datasets inside a single Sidekiq job.
|
|
84
|
+
Enabled: true
|
|
85
|
+
VersionAdded: '0.1'
|
|
86
|
+
AllowedMethods: []
|
|
87
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/FindEachInJob
|
|
88
|
+
|
|
89
|
+
Sidekiq/HugeJobArguments:
|
|
90
|
+
Description: Avoid passing potentially huge arguments to Sidekiq jobs.
|
|
91
|
+
Enabled: true
|
|
92
|
+
VersionAdded: '0.1'
|
|
93
|
+
MaxArraySize: 10
|
|
94
|
+
MaxHashSize: 10
|
|
95
|
+
MaxPluckColumns: 3
|
|
96
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/HugeJobArguments
|
|
97
|
+
|
|
98
|
+
Sidekiq/JobDependency:
|
|
99
|
+
Description: Detect implicit job dependencies, suggest Batches.
|
|
100
|
+
Enabled: false
|
|
101
|
+
VersionAdded: '0.1'
|
|
102
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/JobDependency
|
|
103
|
+
|
|
104
|
+
Sidekiq/JobFileLocation:
|
|
105
|
+
Description: Ensure job classes are in app/jobs or app/workers.
|
|
106
|
+
Enabled: false
|
|
107
|
+
VersionAdded: '0.1'
|
|
108
|
+
AllowedDirectories:
|
|
109
|
+
- app/jobs
|
|
110
|
+
- app/workers
|
|
111
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/JobFileLocation
|
|
112
|
+
|
|
113
|
+
Sidekiq/JobFileNaming:
|
|
114
|
+
Description: Ensure job file names match class names.
|
|
115
|
+
Enabled: false
|
|
116
|
+
VersionAdded: '0.1'
|
|
117
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/JobFileNaming
|
|
118
|
+
|
|
119
|
+
Sidekiq/JobInclude:
|
|
120
|
+
Description: Prefer including Sidekiq::Job over Sidekiq::Worker.
|
|
121
|
+
Enabled: true
|
|
122
|
+
VersionAdded: '0.1'
|
|
123
|
+
PreferredModule: Job
|
|
124
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/JobInclude
|
|
125
|
+
|
|
126
|
+
Sidekiq/MissingLogging:
|
|
127
|
+
Description: Encourage logging in jobs.
|
|
128
|
+
Enabled: false
|
|
129
|
+
VersionAdded: '0.1'
|
|
130
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/MissingLogging
|
|
131
|
+
|
|
132
|
+
Sidekiq/MissingTimeout:
|
|
133
|
+
Description: Ensure network operations have timeouts configured.
|
|
134
|
+
Enabled: true
|
|
135
|
+
VersionAdded: '0.1'
|
|
136
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/MissingTimeout
|
|
137
|
+
|
|
138
|
+
Sidekiq/MixedRetryStrategies:
|
|
139
|
+
Description: Avoid mixing ActiveJob retry_on with Sidekiq retries.
|
|
140
|
+
Enabled: true
|
|
141
|
+
VersionAdded: '0.1'
|
|
142
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/MixedRetryStrategies
|
|
143
|
+
|
|
144
|
+
Sidekiq/NoRescueAll:
|
|
145
|
+
Description: Avoid rescuing all exceptions in Sidekiq jobs.
|
|
146
|
+
Enabled: true
|
|
147
|
+
VersionAdded: '0.1'
|
|
148
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/NoRescueAll
|
|
149
|
+
|
|
150
|
+
Sidekiq/PerformInlineUsage:
|
|
151
|
+
Description: Avoid using perform_inline in production code.
|
|
152
|
+
Enabled: true
|
|
153
|
+
VersionAdded: '0.1'
|
|
154
|
+
AllowedInTests: true
|
|
155
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/PerformInlineUsage
|
|
156
|
+
|
|
157
|
+
Sidekiq/PerformMethodParameters:
|
|
158
|
+
Description: Do not use keyword arguments in perform method.
|
|
159
|
+
Enabled: true
|
|
160
|
+
VersionAdded: '0.1'
|
|
161
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/PerformMethodParameters
|
|
162
|
+
|
|
163
|
+
Sidekiq/PiiInArguments:
|
|
164
|
+
Description: Avoid passing PII in job arguments.
|
|
165
|
+
Enabled: false
|
|
166
|
+
VersionAdded: '0.1'
|
|
167
|
+
PiiPatterns:
|
|
168
|
+
- email
|
|
169
|
+
- phone
|
|
170
|
+
- address
|
|
171
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/PiiInArguments
|
|
172
|
+
|
|
173
|
+
Sidekiq/PutsOrPrintUsage:
|
|
174
|
+
Description: Use logger instead of puts/print in jobs.
|
|
175
|
+
Enabled: true
|
|
176
|
+
VersionAdded: '0.1'
|
|
177
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/PutsOrPrintUsage
|
|
178
|
+
|
|
179
|
+
Sidekiq/QueueSpecified:
|
|
180
|
+
Description: Require explicit queue specification for jobs.
|
|
181
|
+
Enabled: false
|
|
182
|
+
VersionAdded: '0.1'
|
|
183
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/QueueSpecified
|
|
184
|
+
|
|
185
|
+
Sidekiq/RedisInJob:
|
|
186
|
+
Description: Use Sidekiq.redis instead of creating new Redis connections.
|
|
187
|
+
Enabled: true
|
|
188
|
+
VersionAdded: '0.1'
|
|
189
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/RedisInJob
|
|
190
|
+
|
|
191
|
+
Sidekiq/RetrySpecified:
|
|
192
|
+
Description: Require explicit retry configuration for jobs.
|
|
193
|
+
Enabled: false
|
|
194
|
+
VersionAdded: '0.1'
|
|
195
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/RetrySpecified
|
|
196
|
+
|
|
197
|
+
Sidekiq/RetryZero:
|
|
198
|
+
Description: 'Prefer retry: false over retry: 0 for clarity.'
|
|
199
|
+
Enabled: false
|
|
200
|
+
VersionAdded: '0.1'
|
|
201
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/RetryZero
|
|
202
|
+
|
|
203
|
+
Sidekiq/SelfSchedulingJob:
|
|
204
|
+
Description: Detect jobs that reschedule themselves.
|
|
205
|
+
Enabled: false
|
|
206
|
+
VersionAdded: '0.1'
|
|
207
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/SelfSchedulingJob
|
|
208
|
+
|
|
209
|
+
Sidekiq/SensitiveDataInArguments:
|
|
210
|
+
Description: Avoid passing sensitive data in job arguments.
|
|
211
|
+
Enabled: true
|
|
212
|
+
VersionAdded: '0.1'
|
|
213
|
+
SensitivePatterns:
|
|
214
|
+
- password
|
|
215
|
+
- passwd
|
|
216
|
+
- pwd
|
|
217
|
+
- token
|
|
218
|
+
- api_key
|
|
219
|
+
- secret
|
|
220
|
+
- credit_card
|
|
221
|
+
- card_number
|
|
222
|
+
- cvv
|
|
223
|
+
- ssn
|
|
224
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/SensitiveDataInArguments
|
|
225
|
+
|
|
226
|
+
Sidekiq/SidekiqOverActiveJob:
|
|
227
|
+
Description: Recommend using Sidekiq directly instead of ActiveJob.
|
|
228
|
+
Enabled: false
|
|
229
|
+
VersionAdded: '0.1'
|
|
230
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/SidekiqOverActiveJob
|
|
231
|
+
|
|
232
|
+
Sidekiq/SilentRescue:
|
|
233
|
+
Description: Avoid silently swallowing exceptions in jobs.
|
|
234
|
+
Enabled: true
|
|
235
|
+
VersionAdded: '0.1'
|
|
236
|
+
AllowedExceptions:
|
|
237
|
+
- ActiveRecord::RecordNotFound
|
|
238
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/SilentRescue
|
|
239
|
+
|
|
240
|
+
Sidekiq/SleepInJobs:
|
|
241
|
+
Description: Do not use sleep in Sidekiq jobs.
|
|
242
|
+
Enabled: true
|
|
243
|
+
VersionAdded: '0.1'
|
|
244
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/SleepInJobs
|
|
245
|
+
|
|
246
|
+
Sidekiq/SymbolArgument:
|
|
247
|
+
Description: Do not pass symbols to Sidekiq jobs.
|
|
248
|
+
Enabled: true
|
|
249
|
+
VersionAdded: '0.1'
|
|
250
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/SymbolArgument
|
|
251
|
+
|
|
252
|
+
Sidekiq/ThreadInJob:
|
|
253
|
+
Description: Do not create threads inside Sidekiq jobs.
|
|
254
|
+
Enabled: true
|
|
255
|
+
VersionAdded: '0.1'
|
|
256
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/ThreadInJob
|
|
257
|
+
|
|
258
|
+
Sidekiq/TransactionLeak:
|
|
259
|
+
Description: Do not enqueue jobs inside database transactions.
|
|
260
|
+
Enabled: true
|
|
261
|
+
VersionAdded: '0.1'
|
|
262
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/TransactionLeak
|
|
263
|
+
|
|
264
|
+
Sidekiq/UnknownSidekiqOption:
|
|
265
|
+
Description: Check sidekiq_options for unknown or unsupported keys.
|
|
266
|
+
Enabled: true
|
|
267
|
+
VersionAdded: '0.1'
|
|
268
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/Sidekiq/UnknownSidekiqOption
|
|
269
|
+
|
|
270
|
+
SidekiqPro:
|
|
271
|
+
Enabled: false
|
|
272
|
+
DocumentationBaseURL: https://github.com/ydah/rubocop-sidekiq/blob/main/docs/modules/ROOT/pages
|
|
273
|
+
|
|
274
|
+
SidekiqPro/BatchCallbackMethod:
|
|
275
|
+
Description: Ensure batch callback methods are named correctly.
|
|
276
|
+
Enabled: false
|
|
277
|
+
VersionAdded: '0.1'
|
|
278
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqPro/BatchCallbackMethod
|
|
279
|
+
|
|
280
|
+
SidekiqPro/BatchStatusPolling:
|
|
281
|
+
Description: Discourage polling batch status, prefer callbacks.
|
|
282
|
+
Enabled: false
|
|
283
|
+
VersionAdded: '0.1'
|
|
284
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqPro/BatchStatusPolling
|
|
285
|
+
|
|
286
|
+
SidekiqPro/BatchWithoutCallback:
|
|
287
|
+
Description: Recommend registering callbacks for batches.
|
|
288
|
+
Enabled: false
|
|
289
|
+
VersionAdded: '0.1'
|
|
290
|
+
Severity: warning
|
|
291
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqPro/BatchWithoutCallback
|
|
292
|
+
|
|
293
|
+
SidekiqPro/EmptyBatch:
|
|
294
|
+
Description: Detect batch.jobs blocks that may be empty.
|
|
295
|
+
Enabled: false
|
|
296
|
+
VersionAdded: '0.1'
|
|
297
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqPro/EmptyBatch
|
|
298
|
+
|
|
299
|
+
SidekiqPro/ExpiringJobWithoutTTL:
|
|
300
|
+
Description: Validate TTL range for expiring jobs.
|
|
301
|
+
Enabled: false
|
|
302
|
+
VersionAdded: '0.1'
|
|
303
|
+
MinimumTTL: 300
|
|
304
|
+
MaximumTTL: 604800
|
|
305
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqPro/ExpiringJobWithoutTTL
|
|
306
|
+
|
|
307
|
+
SidekiqPro/LargeArgumentInBatch:
|
|
308
|
+
Description: Avoid passing large arguments to jobs within a batch.
|
|
309
|
+
Enabled: false
|
|
310
|
+
VersionAdded: '0.1'
|
|
311
|
+
MaxArraySize: 10
|
|
312
|
+
MaxHashSize: 10
|
|
313
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqPro/LargeArgumentInBatch
|
|
314
|
+
|
|
315
|
+
SidekiqPro/ReliabilityNotEnabled:
|
|
316
|
+
Description: Recommend enabling super_fetch and reliable_push.
|
|
317
|
+
Enabled: false
|
|
318
|
+
VersionAdded: '0.1'
|
|
319
|
+
Include:
|
|
320
|
+
- config/initializers/sidekiq.rb
|
|
321
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqPro/ReliabilityNotEnabled
|
|
322
|
+
|
|
323
|
+
SidekiqEnt:
|
|
324
|
+
Enabled: false
|
|
325
|
+
DocumentationBaseURL: https://github.com/ydah/rubocop-sidekiq/blob/main/docs/modules/ROOT/pages
|
|
326
|
+
|
|
327
|
+
SidekiqEnt/EncryptionWithManyArguments:
|
|
328
|
+
Description: Ensure sensitive data is in the last argument for encryption.
|
|
329
|
+
Enabled: false
|
|
330
|
+
VersionAdded: '0.1'
|
|
331
|
+
MaxArguments: 2
|
|
332
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqEnt/EncryptionWithManyArguments
|
|
333
|
+
|
|
334
|
+
SidekiqEnt/EncryptionWithoutSecretBag:
|
|
335
|
+
Description: Recommend proper secret bag usage with encryption.
|
|
336
|
+
Enabled: false
|
|
337
|
+
VersionAdded: '0.1'
|
|
338
|
+
Severity: info
|
|
339
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqEnt/EncryptionWithoutSecretBag
|
|
340
|
+
|
|
341
|
+
SidekiqEnt/LeaderElectionWithoutBlock:
|
|
342
|
+
Description: Warn about long-running operations in leader checks.
|
|
343
|
+
Enabled: false
|
|
344
|
+
VersionAdded: '0.1'
|
|
345
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqEnt/LeaderElectionWithoutBlock
|
|
346
|
+
|
|
347
|
+
SidekiqEnt/LimiterNotReused:
|
|
348
|
+
Description: Create rate limiters as class constants for reuse.
|
|
349
|
+
Enabled: false
|
|
350
|
+
VersionAdded: '0.1'
|
|
351
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqEnt/LimiterNotReused
|
|
352
|
+
|
|
353
|
+
SidekiqEnt/LimiterWithoutLockTimeout:
|
|
354
|
+
Description: Recommend setting lock_timeout for concurrent limiters.
|
|
355
|
+
Enabled: false
|
|
356
|
+
VersionAdded: '0.1'
|
|
357
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqEnt/LimiterWithoutLockTimeout
|
|
358
|
+
|
|
359
|
+
SidekiqEnt/LimiterWithoutWaitTimeout:
|
|
360
|
+
Description: Specify wait_timeout option for rate limiters.
|
|
361
|
+
Enabled: false
|
|
362
|
+
VersionAdded: '0.1'
|
|
363
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqEnt/LimiterWithoutWaitTimeout
|
|
364
|
+
|
|
365
|
+
SidekiqEnt/PeriodicJobInvalidCron:
|
|
366
|
+
Description: Validate cron expressions for periodic jobs.
|
|
367
|
+
Enabled: false
|
|
368
|
+
VersionAdded: '0.1'
|
|
369
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqEnt/PeriodicJobInvalidCron
|
|
370
|
+
|
|
371
|
+
SidekiqEnt/PeriodicJobWithArguments:
|
|
372
|
+
Description: Periodic jobs should not require arguments.
|
|
373
|
+
Enabled: false
|
|
374
|
+
VersionAdded: '0.1'
|
|
375
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqEnt/PeriodicJobWithArguments
|
|
376
|
+
|
|
377
|
+
SidekiqEnt/UniqueJobTooShortTTL:
|
|
378
|
+
Description: Warn about unique jobs with too short TTL.
|
|
379
|
+
Enabled: false
|
|
380
|
+
VersionAdded: '0.1'
|
|
381
|
+
MinimumTTL: 60
|
|
382
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqEnt/UniqueJobTooShortTTL
|
|
383
|
+
|
|
384
|
+
SidekiqEnt/UniqueJobWithoutTTL:
|
|
385
|
+
Description: Require unique_for when using unique_until option.
|
|
386
|
+
Enabled: false
|
|
387
|
+
VersionAdded: '0.1'
|
|
388
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqEnt/UniqueJobWithoutTTL
|
|
389
|
+
|
|
390
|
+
SidekiqEnt/UniqueUntilMismatch:
|
|
391
|
+
Description: Validate unique_until option values.
|
|
392
|
+
Enabled: false
|
|
393
|
+
VersionAdded: '0.1'
|
|
394
|
+
AllowedValues:
|
|
395
|
+
- success
|
|
396
|
+
Reference: https://www.rubydoc.info/gems/rubocop-sidekiq_plus/RuboCop/Cop/SidekiqEnt/UniqueUntilMismatch
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Sidekiq
|
|
6
|
+
# Checks for ActiveRecord objects passed to Sidekiq job methods.
|
|
7
|
+
#
|
|
8
|
+
# Passing ActiveRecord objects to Sidekiq jobs is problematic because:
|
|
9
|
+
# - Objects cannot be properly serialized to JSON
|
|
10
|
+
# - The object may change or be deleted before the job runs
|
|
11
|
+
# - It increases Redis memory usage
|
|
12
|
+
#
|
|
13
|
+
# Instead, pass the record's ID and reload it in the job.
|
|
14
|
+
#
|
|
15
|
+
# @example
|
|
16
|
+
# # bad
|
|
17
|
+
# MyJob.perform_async(user)
|
|
18
|
+
# MyJob.perform_async(User.find(1))
|
|
19
|
+
# MyJob.perform_async(User.first)
|
|
20
|
+
#
|
|
21
|
+
# # good
|
|
22
|
+
# MyJob.perform_async(user.id)
|
|
23
|
+
# MyJob.perform_async(user_id)
|
|
24
|
+
#
|
|
25
|
+
class ActiveRecordArgument < Base
|
|
26
|
+
include ArgumentTraversal
|
|
27
|
+
|
|
28
|
+
MSG = 'Do not pass ActiveRecord objects to Sidekiq jobs. ' \
|
|
29
|
+
'Pass the id and fetch the record in the job instead.'
|
|
30
|
+
|
|
31
|
+
RESTRICT_ON_SEND = PerformMethods.all
|
|
32
|
+
|
|
33
|
+
FINDER_METHODS = %i[find find_by find_by! first last take where].freeze
|
|
34
|
+
|
|
35
|
+
# @!method sidekiq_perform_call?(node)
|
|
36
|
+
def_node_matcher :sidekiq_perform_call?, <<~PATTERN
|
|
37
|
+
(send _ {#{PerformMethods.all.map(&:inspect).join(' ')}} $...)
|
|
38
|
+
PATTERN
|
|
39
|
+
|
|
40
|
+
# @!method active_record_finder?(node)
|
|
41
|
+
def_node_matcher :active_record_finder?, <<~PATTERN
|
|
42
|
+
(send (const ...) {#{FINDER_METHODS.map(&:inspect).join(' ')}} ...)
|
|
43
|
+
PATTERN
|
|
44
|
+
|
|
45
|
+
# @!method chained_finder?(node)
|
|
46
|
+
def_node_matcher :chained_finder?, <<~PATTERN
|
|
47
|
+
(send (send (const ...) ...) {#{FINDER_METHODS.map(&:inspect).join(' ')}} ...)
|
|
48
|
+
PATTERN
|
|
49
|
+
|
|
50
|
+
def on_send(node)
|
|
51
|
+
sidekiq_perform_call?(node) do |args|
|
|
52
|
+
check_arguments(args)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
alias on_csend on_send
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
def check_argument(arg)
|
|
60
|
+
if active_record_object?(arg)
|
|
61
|
+
add_offense(arg)
|
|
62
|
+
elsif arg.hash_type?
|
|
63
|
+
check_hash_values(arg)
|
|
64
|
+
elsif arg.array_type?
|
|
65
|
+
check_array_elements(arg)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def active_record_object?(node)
|
|
70
|
+
return false unless node.send_type?
|
|
71
|
+
|
|
72
|
+
active_record_finder?(node) || chained_finder?(node)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Sidekiq
|
|
6
|
+
# Checks for perform_async usage in test files.
|
|
7
|
+
#
|
|
8
|
+
# @example
|
|
9
|
+
# # bad
|
|
10
|
+
# MyJob.perform_async(user.id)
|
|
11
|
+
#
|
|
12
|
+
# # good
|
|
13
|
+
# MyJob.perform_inline(user.id)
|
|
14
|
+
#
|
|
15
|
+
class AsyncInTest < Base
|
|
16
|
+
MSG = 'Avoid perform_async in tests. Use perform_inline or call perform directly.'
|
|
17
|
+
|
|
18
|
+
RESTRICT_ON_SEND = %i[perform_async].freeze
|
|
19
|
+
|
|
20
|
+
def on_send(node)
|
|
21
|
+
return unless in_test_file?
|
|
22
|
+
|
|
23
|
+
add_offense(node)
|
|
24
|
+
end
|
|
25
|
+
alias on_csend on_send
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def in_test_file?
|
|
30
|
+
file_path = processed_source.file_path
|
|
31
|
+
return false unless file_path
|
|
32
|
+
|
|
33
|
+
test_patterns.any? { |pattern| File.fnmatch?(pattern, file_path) }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_patterns
|
|
37
|
+
cop_config.fetch('Include', ['spec/**/*_spec.rb', 'test/**/*_test.rb'])
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Sidekiq
|
|
6
|
+
# @abstract
|
|
7
|
+
# Base class for Sidekiq cops.
|
|
8
|
+
class Base < ::RuboCop::Cop::Base
|
|
9
|
+
abstract! if respond_to?(:abstract!)
|
|
10
|
+
include RuboCop::Sidekiq::Language
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Sidekiq
|
|
6
|
+
# Enforces consistent job class name suffix (Job or Worker).
|
|
7
|
+
#
|
|
8
|
+
# @example EnforcedSuffix: Job (default)
|
|
9
|
+
# # bad
|
|
10
|
+
# class ProcessPaymentWorker
|
|
11
|
+
# include Sidekiq::Job
|
|
12
|
+
# end
|
|
13
|
+
#
|
|
14
|
+
# # good
|
|
15
|
+
# class ProcessPaymentJob
|
|
16
|
+
# include Sidekiq::Job
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
class ConsistentJobSuffix < Base
|
|
20
|
+
include ClassNameHelper
|
|
21
|
+
|
|
22
|
+
MSG = 'Use `%<suffix>s` suffix for Sidekiq job class names.'
|
|
23
|
+
|
|
24
|
+
def on_class(node)
|
|
25
|
+
return unless sidekiq_job_class?(node)
|
|
26
|
+
|
|
27
|
+
class_name = class_name(node)
|
|
28
|
+
return unless class_name
|
|
29
|
+
|
|
30
|
+
suffix = enforced_suffix
|
|
31
|
+
return if class_name.end_with?(suffix)
|
|
32
|
+
|
|
33
|
+
add_offense(node.loc.keyword, message: format(MSG, suffix: suffix))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def enforced_suffix
|
|
39
|
+
cop_config.fetch('EnforcedSuffix', 'Job')
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Sidekiq
|
|
6
|
+
# Checks that job class names are constants.
|
|
7
|
+
#
|
|
8
|
+
# Using dynamic class names for jobs can lead to:
|
|
9
|
+
# - Security vulnerabilities (arbitrary code execution)
|
|
10
|
+
# - Difficult to trace job execution
|
|
11
|
+
# - Harder static analysis
|
|
12
|
+
#
|
|
13
|
+
# @example
|
|
14
|
+
# # bad
|
|
15
|
+
# job_class.perform_async(args)
|
|
16
|
+
# "#{prefix}Job".constantize.perform_async(args)
|
|
17
|
+
#
|
|
18
|
+
# # good
|
|
19
|
+
# MyJob.perform_async(args)
|
|
20
|
+
# MyModule::MyJob.perform_async(args)
|
|
21
|
+
#
|
|
22
|
+
class ConstantJobClassName < Base
|
|
23
|
+
MSG = 'Use a constant class name for Sidekiq jobs. ' \
|
|
24
|
+
'Dynamic job class names are harder to trace and may be insecure.'
|
|
25
|
+
|
|
26
|
+
RESTRICT_ON_SEND = PerformMethods.all
|
|
27
|
+
|
|
28
|
+
def on_send(node)
|
|
29
|
+
return unless RESTRICT_ON_SEND.include?(node.method_name)
|
|
30
|
+
return if constant_receiver?(node)
|
|
31
|
+
|
|
32
|
+
add_offense(node.receiver)
|
|
33
|
+
end
|
|
34
|
+
alias on_csend on_send
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def constant_receiver?(node)
|
|
39
|
+
receiver = node.receiver
|
|
40
|
+
return false unless receiver
|
|
41
|
+
|
|
42
|
+
receiver.const_type? || (receiver.send_type? && nested_const?(receiver))
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def nested_const?(node)
|
|
46
|
+
return true if node.const_type?
|
|
47
|
+
|
|
48
|
+
node.send_type? && node.receiver && nested_const?(node.receiver)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Sidekiq
|
|
6
|
+
# Checks for explicit ActiveRecord connection usage in Sidekiq jobs.
|
|
7
|
+
#
|
|
8
|
+
# @example
|
|
9
|
+
# # bad
|
|
10
|
+
# ActiveRecord::Base.connection.execute('SELECT 1')
|
|
11
|
+
#
|
|
12
|
+
# # good
|
|
13
|
+
# ActiveRecord::Base.connection_pool.with_connection { |conn| conn.execute('SELECT 1') }
|
|
14
|
+
#
|
|
15
|
+
class DatabaseConnectionLeak < Base
|
|
16
|
+
MSG = 'Avoid using ActiveRecord::Base.connection directly in jobs. Use connection_pool.with_connection.'
|
|
17
|
+
|
|
18
|
+
def on_def(node)
|
|
19
|
+
return unless node.method?(:perform)
|
|
20
|
+
return unless in_sidekiq_job?(node)
|
|
21
|
+
|
|
22
|
+
node.each_descendant(:send) do |send|
|
|
23
|
+
receiver = send.receiver
|
|
24
|
+
next unless receiver&.const_name == 'ActiveRecord::Base'
|
|
25
|
+
next unless send.method?(:connection)
|
|
26
|
+
|
|
27
|
+
add_offense(send)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|