makandra-rubocop 5.4.0 → 7.0.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/CHANGELOG.md +73 -0
- data/Gemfile.lock +36 -33
- data/README.md +28 -13
- data/config/default.yml +1082 -144
- data/config/ext/rails.yml +331 -15
- data/config/ext/rspec.yml +169 -27
- data/lib/makandra_rubocop/support/rubocop_spec.rb +4 -4
- data/lib/makandra_rubocop/version.rb +1 -1
- data/makandra-rubocop.gemspec +4 -4
- metadata +10 -10
data/config/ext/rails.yml
CHANGED
@@ -23,6 +23,27 @@ AllCops:
|
|
23
23
|
# as the default.
|
24
24
|
TargetRailsVersion: ~
|
25
25
|
|
26
|
+
Lint/NumberConversion:
|
27
|
+
# Add Rails' duration methods to the ignore list for `Lint/NumberConversion`
|
28
|
+
# so that calling `to_i` on one of these does not register an offense.
|
29
|
+
# See: https://github.com/rubocop/rubocop/issues/8950
|
30
|
+
IgnoredMethods:
|
31
|
+
- ago
|
32
|
+
- from_now
|
33
|
+
- second
|
34
|
+
- seconds
|
35
|
+
- minute
|
36
|
+
- minutes
|
37
|
+
- hour
|
38
|
+
- hours
|
39
|
+
- day
|
40
|
+
- days
|
41
|
+
- week
|
42
|
+
- weeks
|
43
|
+
- fortnight
|
44
|
+
- fortnights
|
45
|
+
- in_milliseconds
|
46
|
+
|
26
47
|
Rails/ActionFilter:
|
27
48
|
Description: 'Enforces consistent use of action filter methods.'
|
28
49
|
Enabled: true
|
@@ -43,6 +64,14 @@ Rails/ActiveRecordAliases:
|
|
43
64
|
VersionAdded: '0.53'
|
44
65
|
SafeAutoCorrect: false
|
45
66
|
|
67
|
+
Rails/ActiveRecordCallbacksOrder:
|
68
|
+
Description: 'Order callback declarations in the order in which they will be executed.'
|
69
|
+
StyleGuide: 'https://rails.rubystyle.guide/#callbacks-order'
|
70
|
+
Enabled: true
|
71
|
+
VersionAdded: '2.7'
|
72
|
+
Include:
|
73
|
+
- app/models/**/*.rb
|
74
|
+
|
46
75
|
Rails/ActiveRecordOverride:
|
47
76
|
Description: >-
|
48
77
|
Check for overriding Active Record methods instead of using
|
@@ -60,6 +89,24 @@ Rails/ActiveSupportAliases:
|
|
60
89
|
Enabled: false
|
61
90
|
VersionAdded: '0.48'
|
62
91
|
|
92
|
+
Rails/AddColumnIndex:
|
93
|
+
Description: >-
|
94
|
+
Rails migrations don't make use of a given `index` key, but also
|
95
|
+
doesn't given an error when it's used, so it makes it seem like an
|
96
|
+
index might be used.
|
97
|
+
Enabled: true
|
98
|
+
VersionAdded: '2.11'
|
99
|
+
Include:
|
100
|
+
- db/migrate/*.rb
|
101
|
+
|
102
|
+
Rails/AfterCommitOverride:
|
103
|
+
Description: >-
|
104
|
+
This cop enforces that there is only one call to `after_commit`
|
105
|
+
(and its aliases - `after_create_commit`, `after_update_commit`,
|
106
|
+
and `after_destroy_commit`) with the same callback name per model.
|
107
|
+
Enabled: true
|
108
|
+
VersionAdded: '2.8'
|
109
|
+
|
63
110
|
Rails/ApplicationController:
|
64
111
|
Description: 'Check that controllers subclass ApplicationController.'
|
65
112
|
Enabled: false # We have Controllers like `/jasmine` which do not inherit from ApplicationController
|
@@ -88,6 +135,12 @@ Rails/ApplicationRecord:
|
|
88
135
|
VersionAdded: '0.49'
|
89
136
|
VersionChanged: '2.5'
|
90
137
|
|
138
|
+
Rails/ArelStar:
|
139
|
+
Description: 'Enforces `Arel.star` instead of `"*"` for expanded columns.'
|
140
|
+
Enabled: true
|
141
|
+
SafeAutoCorrect: false
|
142
|
+
VersionAdded: '2.9'
|
143
|
+
|
91
144
|
Rails/AssertNot:
|
92
145
|
Description: 'Use `assert_not` instead of `assert !`.'
|
93
146
|
Enabled: true
|
@@ -95,18 +148,26 @@ Rails/AssertNot:
|
|
95
148
|
Include:
|
96
149
|
- '**/test/**/*'
|
97
150
|
|
151
|
+
Rails/AttributeDefaultBlockValue:
|
152
|
+
Description: 'Pass method call in block for attribute option `default`.'
|
153
|
+
Enabled: true
|
154
|
+
VersionAdded: '2.9'
|
155
|
+
Include:
|
156
|
+
- 'models/**/*'
|
157
|
+
|
98
158
|
Rails/BelongsTo:
|
99
159
|
Description: >-
|
100
160
|
Use `optional: true` instead of `required: false` for
|
101
|
-
`belongs_to` relations
|
161
|
+
`belongs_to` relations.
|
102
162
|
Enabled: true
|
103
163
|
VersionAdded: '0.62'
|
104
164
|
|
105
165
|
Rails/Blank:
|
106
166
|
Description: 'Enforces use of `blank?`.'
|
107
167
|
Enabled: true
|
168
|
+
SafeAutoCorrect: false
|
108
169
|
VersionAdded: '0.48'
|
109
|
-
VersionChanged: '
|
170
|
+
VersionChanged: '2.10'
|
110
171
|
# Convert usages of `nil? || empty?` to `blank?`
|
111
172
|
NilOrEmpty: true
|
112
173
|
# Convert usages of `!present?` to `blank?`
|
@@ -125,6 +186,14 @@ Rails/BulkChangeTable:
|
|
125
186
|
Include:
|
126
187
|
- db/migrate/*.rb
|
127
188
|
|
189
|
+
Rails/ContentTag:
|
190
|
+
Description: 'Use `tag` instead of `content_tag`.'
|
191
|
+
Reference:
|
192
|
+
- 'https://github.com/rails/rails/issues/25195'
|
193
|
+
- 'https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-content_tag'
|
194
|
+
Enabled: false # We currently use content_tag in many applications. If content_tag should become deprecated in the future we'll have to change it anyway, but until then, we'll keep the content_tag syntax
|
195
|
+
VersionAdded: '2.6'
|
196
|
+
|
128
197
|
Rails/CreateTableWithTimestamps:
|
129
198
|
Description: >-
|
130
199
|
Checks the migration for which timestamps are not included
|
@@ -140,7 +209,7 @@ Rails/Date:
|
|
140
209
|
such as Date.today, Date.current etc.
|
141
210
|
Enabled: false # It's not that simple. Really.
|
142
211
|
VersionAdded: '0.30'
|
143
|
-
VersionChanged: '
|
212
|
+
VersionChanged: '2.11'
|
144
213
|
# The value `strict` disallows usage of `Date.today`, `Date.current`,
|
145
214
|
# `Date#to_time` etc.
|
146
215
|
# The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
|
@@ -150,6 +219,14 @@ Rails/Date:
|
|
150
219
|
SupportedStyles:
|
151
220
|
- strict
|
152
221
|
- flexible
|
222
|
+
AllowToTime: false # datetime.to_time can handle timezones, but this depends on a setting, which one may not be
|
223
|
+
# aware of, see https://api.rubyonrails.org/classes/DateTime.html#method-i-to_time,
|
224
|
+
|
225
|
+
Rails/DefaultScope:
|
226
|
+
Description: 'Avoid use of `default_scope`.'
|
227
|
+
StyleGuide: 'https://rails.rubystyle.guide#avoid-default-scope'
|
228
|
+
Enabled: false
|
229
|
+
VersionAdded: '2.7'
|
153
230
|
|
154
231
|
Rails/Delegate:
|
155
232
|
Description: 'Prefer delegate method for delegations.'
|
@@ -171,8 +248,20 @@ Rails/DynamicFindBy:
|
|
171
248
|
StyleGuide: 'https://rails.rubystyle.guide#find_by'
|
172
249
|
Enabled: false # We occasionally define custom find_by_* methods (e.g. `find_by_anything`) which don't work like ActiveRecord's methods.
|
173
250
|
VersionAdded: '0.44'
|
251
|
+
VersionChanged: '2.10'
|
252
|
+
# The `Whitelist` has been deprecated, Please use `AllowedMethods` instead.
|
174
253
|
Whitelist:
|
175
254
|
- find_by_sql
|
255
|
+
AllowedMethods:
|
256
|
+
- find_by_sql
|
257
|
+
AllowedReceivers:
|
258
|
+
- Gem::Specification
|
259
|
+
|
260
|
+
Rails/EagerEvaluationLogMessage:
|
261
|
+
Description: 'Checks that blocks are used for interpolated strings passed to `Rails.logger.debug`.'
|
262
|
+
Reference: 'https://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance'
|
263
|
+
Enabled: true
|
264
|
+
VersionAdded: '2.11'
|
176
265
|
|
177
266
|
Rails/EnumHash:
|
178
267
|
Description: 'Prefer hash syntax over array syntax when defining enums.'
|
@@ -190,10 +279,23 @@ Rails/EnumUniqueness:
|
|
190
279
|
- app/models/**/*.rb
|
191
280
|
|
192
281
|
Rails/EnvironmentComparison:
|
193
|
-
Description: "Favor `Rails.env.production?` over `Rails.env == 'production'
|
282
|
+
Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`."
|
194
283
|
Enabled: true
|
195
284
|
VersionAdded: '0.52'
|
196
285
|
|
286
|
+
Rails/EnvironmentVariableAccess:
|
287
|
+
Description: 'Do not access `ENV` directly after initialization.'
|
288
|
+
Enabled: false
|
289
|
+
VersionAdded: '2.10'
|
290
|
+
VersionChanged: '2.11'
|
291
|
+
Include:
|
292
|
+
- app/**/*.rb
|
293
|
+
- lib/**/*.rb
|
294
|
+
Exclude:
|
295
|
+
- lib/**/*.rake
|
296
|
+
AllowReads: false
|
297
|
+
AllowWrites: false
|
298
|
+
|
197
299
|
Rails/Exit:
|
198
300
|
Description: >-
|
199
301
|
Favor `fail`, `break`, `return`, etc. over `exit` in
|
@@ -208,6 +310,11 @@ Rails/Exit:
|
|
208
310
|
Exclude:
|
209
311
|
- lib/**/*.rake
|
210
312
|
|
313
|
+
Rails/ExpandedDateRange:
|
314
|
+
Description: 'Checks for expanded date range.'
|
315
|
+
Enabled: false # We think the range syntax is clearer than using #all_year for example
|
316
|
+
VersionAdded: '2.11'
|
317
|
+
|
211
318
|
Rails/FilePath:
|
212
319
|
Description: 'Use `Rails.root.join` for file path joining.'
|
213
320
|
Enabled: false
|
@@ -223,16 +330,33 @@ Rails/FindBy:
|
|
223
330
|
StyleGuide: 'https://rails.rubystyle.guide#find_by'
|
224
331
|
Enabled: false
|
225
332
|
VersionAdded: '0.30'
|
333
|
+
VersionChanged: '2.11'
|
334
|
+
IgnoreWhereFirst: true
|
226
335
|
Include:
|
227
336
|
- app/models/**/*.rb
|
228
337
|
|
338
|
+
Rails/FindById:
|
339
|
+
Description: >-
|
340
|
+
Favor the use of `find` over `where.take!`, `find_by!`, and `find_by_id!` when you
|
341
|
+
need to retrieve a single record by primary key when you expect it to be found.
|
342
|
+
StyleGuide: 'https://rails.rubystyle.guide/#find'
|
343
|
+
Enabled: true
|
344
|
+
VersionAdded: '2.7'
|
345
|
+
|
229
346
|
Rails/FindEach:
|
230
347
|
Description: 'Prefer all.find_each over all.find.'
|
231
348
|
StyleGuide: 'https://rails.rubystyle.guide#find-each'
|
232
349
|
Enabled: true
|
233
350
|
VersionAdded: '0.30'
|
351
|
+
VersionChanged: '2.9'
|
234
352
|
Include:
|
235
353
|
- app/models/**/*.rb
|
354
|
+
IgnoredMethods:
|
355
|
+
# Methods that don't work well with `find_each`.
|
356
|
+
- order
|
357
|
+
- limit
|
358
|
+
- select
|
359
|
+
- lock
|
236
360
|
|
237
361
|
Rails/HasAndBelongsToMany:
|
238
362
|
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
@@ -251,7 +375,7 @@ Rails/HasManyOrHasOneDependent:
|
|
251
375
|
- app/models/**/*.rb
|
252
376
|
|
253
377
|
Rails/HelperInstanceVariable:
|
254
|
-
Description: 'Do not use instance variables in helpers'
|
378
|
+
Description: 'Do not use instance variables in helpers.'
|
255
379
|
Enabled: false # https://github.com/makandra/makandra-rubocop/issues/12
|
256
380
|
VersionAdded: '2.0'
|
257
381
|
Include:
|
@@ -269,11 +393,20 @@ Rails/HttpStatus:
|
|
269
393
|
Description: 'Enforces use of symbolic or numeric value to define HTTP status.'
|
270
394
|
Enabled: false
|
271
395
|
VersionAdded: '0.54'
|
396
|
+
VersionChanged: '2.11'
|
272
397
|
EnforcedStyle: symbolic
|
273
398
|
SupportedStyles:
|
274
399
|
- numeric
|
275
400
|
- symbolic
|
276
401
|
|
402
|
+
Rails/I18nLocaleAssignment:
|
403
|
+
Description: 'Prefer the usage of `I18n.with_locale` instead of manually updating `I18n.locale` value.'
|
404
|
+
Enabled: false
|
405
|
+
VersionAdded: '2.11'
|
406
|
+
Include:
|
407
|
+
- spec/**/*.rb
|
408
|
+
- test/**/*.rb
|
409
|
+
|
277
410
|
Rails/IgnoredSkipActionFilterOption:
|
278
411
|
Description: 'Checks that `if` and `only` (or `except`) are not used together as options of `skip_*` action filter.'
|
279
412
|
Reference: 'https://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#method-i-_normalize_callback_options'
|
@@ -283,14 +416,22 @@ Rails/IgnoredSkipActionFilterOption:
|
|
283
416
|
- app/controllers/**/*.rb
|
284
417
|
|
285
418
|
Rails/IndexBy:
|
286
|
-
Description: 'Prefer `index_by` over `each_with_object` or `map`.'
|
419
|
+
Description: 'Prefer `index_by` over `each_with_object`, `to_h`, or `map`.'
|
287
420
|
Enabled: true
|
288
421
|
VersionAdded: '2.5'
|
422
|
+
VersionChanged: '2.8'
|
289
423
|
|
290
424
|
Rails/IndexWith:
|
291
|
-
Description: 'Prefer `index_with` over `each_with_object` or `map`.'
|
425
|
+
Description: 'Prefer `index_with` over `each_with_object`, `to_h`, or `map`.'
|
292
426
|
Enabled: true
|
293
427
|
VersionAdded: '2.5'
|
428
|
+
VersionChanged: '2.8'
|
429
|
+
|
430
|
+
Rails/Inquiry:
|
431
|
+
Description: "Prefer Ruby's comparison operators over Active Support's `Array#inquiry` and `String#inquiry`."
|
432
|
+
StyleGuide: 'https://rails.rubystyle.guide/#inquiry'
|
433
|
+
Enabled: false # Not clear why we want this
|
434
|
+
VersionAdded: '2.7'
|
294
435
|
|
295
436
|
Rails/InverseOf:
|
296
437
|
Description: 'Checks for associations where the inverse cannot be determined automatically.'
|
@@ -317,13 +458,49 @@ Rails/LinkToBlank:
|
|
317
458
|
Enabled: true
|
318
459
|
VersionAdded: '0.62'
|
319
460
|
|
461
|
+
Rails/MailerName:
|
462
|
+
Description: 'Mailer should end with `Mailer` suffix.'
|
463
|
+
StyleGuide: 'https://rails.rubystyle.guide/#mailer-name'
|
464
|
+
Enabled: true
|
465
|
+
SafeAutoCorrect: false
|
466
|
+
VersionAdded: '2.7'
|
467
|
+
Include:
|
468
|
+
- app/mailers/**/*.rb
|
469
|
+
|
470
|
+
Rails/MatchRoute:
|
471
|
+
Description: >-
|
472
|
+
Don't use `match` to define any routes unless there is a need to map multiple request types
|
473
|
+
among [:get, :post, :patch, :put, :delete] to a single action using the `:via` option.
|
474
|
+
StyleGuide: 'https://rails.rubystyle.guide/#no-match-routes'
|
475
|
+
Enabled: false # No need why we want to have a cop for this
|
476
|
+
VersionAdded: '2.7'
|
477
|
+
Include:
|
478
|
+
- config/routes.rb
|
479
|
+
- config/routes/**/*.rb
|
480
|
+
|
481
|
+
Rails/NegateInclude:
|
482
|
+
Description: 'Prefer `collection.exclude?(obj)` over `!collection.include?(obj)`.'
|
483
|
+
StyleGuide: 'https://rails.rubystyle.guide#exclude'
|
484
|
+
Enabled: true
|
485
|
+
Safe: false
|
486
|
+
VersionAdded: '2.7'
|
487
|
+
VersionChanged: '2.9'
|
488
|
+
|
320
489
|
Rails/NotNullColumn:
|
321
|
-
Description: 'Do not add a NOT NULL column without a default value'
|
490
|
+
Description: 'Do not add a NOT NULL column without a default value.'
|
322
491
|
Enabled: true
|
323
492
|
VersionAdded: '0.43'
|
324
493
|
Include:
|
325
494
|
- db/migrate/*.rb
|
326
495
|
|
496
|
+
Rails/OrderById:
|
497
|
+
Description: >-
|
498
|
+
Do not use the `id` column for ordering.
|
499
|
+
Use a timestamp column to order chronologically.
|
500
|
+
StyleGuide: 'https://rails.rubystyle.guide/#order-by-id'
|
501
|
+
Enabled: false
|
502
|
+
VersionAdded: '2.8'
|
503
|
+
|
327
504
|
Rails/Output:
|
328
505
|
Description: 'Checks for calls to puts, print, etc.'
|
329
506
|
Enabled: false
|
@@ -340,6 +517,37 @@ Rails/OutputSafety:
|
|
340
517
|
Enabled: true # We may need to review this. Unsure if the cop can always know which `html_safe` call is valid and which one is not.
|
341
518
|
VersionAdded: '0.41'
|
342
519
|
|
520
|
+
Rails/Pick:
|
521
|
+
Description: 'Prefer `pick` over `pluck(...).first`.'
|
522
|
+
StyleGuide: 'https://rails.rubystyle.guide#pick'
|
523
|
+
Enabled: true
|
524
|
+
Safe: false
|
525
|
+
VersionAdded: '2.6'
|
526
|
+
|
527
|
+
Rails/Pluck:
|
528
|
+
Description: 'Prefer `pluck` over `map { ... }`.'
|
529
|
+
StyleGuide: 'https://rails.rubystyle.guide#pluck'
|
530
|
+
Enabled: true
|
531
|
+
VersionAdded: '2.7'
|
532
|
+
|
533
|
+
Rails/PluckId:
|
534
|
+
Description: 'Use `ids` instead of `pluck(:id)` or `pluck(primary_key)`.'
|
535
|
+
StyleGuide: 'https://rails.rubystyle.guide/#ids'
|
536
|
+
Enabled: true
|
537
|
+
Safe: false
|
538
|
+
VersionAdded: '2.7'
|
539
|
+
|
540
|
+
Rails/PluckInWhere:
|
541
|
+
Description: 'Use `select` instead of `pluck` in `where` query methods.'
|
542
|
+
Enabled: false
|
543
|
+
Safe: false
|
544
|
+
VersionAdded: '2.7'
|
545
|
+
VersionChanged: '2.8'
|
546
|
+
EnforcedStyle: conservative
|
547
|
+
SupportedStyles:
|
548
|
+
- conservative
|
549
|
+
- aggressive
|
550
|
+
|
343
551
|
Rails/PluralizationGrammar:
|
344
552
|
Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
|
345
553
|
Enabled: true
|
@@ -367,6 +575,7 @@ Rails/RakeEnvironment:
|
|
367
575
|
Enabled: false
|
368
576
|
Safe: false
|
369
577
|
VersionAdded: '2.4'
|
578
|
+
VersionChanged: '2.6'
|
370
579
|
Include:
|
371
580
|
- '**/Rakefile'
|
372
581
|
- '**/*.rake'
|
@@ -393,6 +602,11 @@ Rails/RedundantAllowNil:
|
|
393
602
|
Include:
|
394
603
|
- app/models/**/*.rb
|
395
604
|
|
605
|
+
Rails/RedundantForeignKey:
|
606
|
+
Description: 'Checks for associations where the `:foreign_key` option is redundant.'
|
607
|
+
Enabled: true
|
608
|
+
VersionAdded: '2.6'
|
609
|
+
|
396
610
|
Rails/RedundantReceiverInWithOptions:
|
397
611
|
Description: 'Checks for redundant receiver in `with_options`.'
|
398
612
|
Enabled: true
|
@@ -401,7 +615,9 @@ Rails/RedundantReceiverInWithOptions:
|
|
401
615
|
Rails/ReflectionClassName:
|
402
616
|
Description: 'Use a string for `class_name` option value in the definition of a reflection.'
|
403
617
|
Enabled: true
|
618
|
+
Safe: false
|
404
619
|
VersionAdded: '0.64'
|
620
|
+
VersionChanged: '2.10'
|
405
621
|
|
406
622
|
Rails/RefuteMethods:
|
407
623
|
Description: 'Use `assert_not` methods instead of `refute` methods.'
|
@@ -421,15 +637,35 @@ Rails/RelativeDateConstant:
|
|
421
637
|
VersionChanged: '0.59'
|
422
638
|
AutoCorrect: false
|
423
639
|
|
640
|
+
Rails/RenderInline:
|
641
|
+
Description: 'Prefer using a template over inline rendering.'
|
642
|
+
StyleGuide: 'https://rails.rubystyle.guide/#inline-rendering'
|
643
|
+
Enabled: false
|
644
|
+
VersionAdded: '2.7'
|
645
|
+
|
646
|
+
Rails/RenderPlainText:
|
647
|
+
Description: 'Prefer `render plain:` over `render text:`.'
|
648
|
+
StyleGuide: 'https://rails.rubystyle.guide/#plain-text-rendering'
|
649
|
+
Enabled: true
|
650
|
+
VersionAdded: '2.7'
|
651
|
+
# Convert only when `content_type` is explicitly set to `text/plain`.
|
652
|
+
ContentTypeCompatibility: true
|
653
|
+
|
424
654
|
Rails/RequestReferer:
|
425
655
|
Description: 'Use consistent syntax for request.referer.'
|
426
656
|
Enabled: true
|
427
657
|
VersionAdded: '0.41'
|
428
|
-
EnforcedStyle:
|
658
|
+
EnforcedStyle: referer
|
429
659
|
SupportedStyles:
|
430
660
|
- referer
|
431
661
|
- referrer
|
432
662
|
|
663
|
+
Rails/RequireDependency:
|
664
|
+
Description: 'Do not use `require_dependency` when running in Zeitwerk mode. `require_dependency` is for autoloading in classic mode.'
|
665
|
+
Reference: 'https://guides.rubyonrails.org/autoloading_and_reloading_constants.html'
|
666
|
+
Enabled: false # We should enable this cop later, when all or most of our applications use zeitwerk
|
667
|
+
VersionAdded: '2.10'
|
668
|
+
|
433
669
|
Rails/ReversibleMigration:
|
434
670
|
Description: 'Checks whether the change method of the migration file is reversible.'
|
435
671
|
StyleGuide: 'https://rails.rubystyle.guide#reversible-migration'
|
@@ -439,8 +675,15 @@ Rails/ReversibleMigration:
|
|
439
675
|
Include:
|
440
676
|
- db/migrate/*.rb
|
441
677
|
|
678
|
+
Rails/ReversibleMigrationMethodDefinition:
|
679
|
+
Description: 'Checks whether the migration implements either a `change` method or both an `up` and a `down` method.'
|
680
|
+
Enabled: false # If the migration starts with a class definition, no change-, up-, or down-method is recognized, although they exist
|
681
|
+
VersionAdded: '2.10'
|
682
|
+
Include:
|
683
|
+
- db/migrate/*.rb
|
684
|
+
|
442
685
|
Rails/SafeNavigation:
|
443
|
-
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try
|
686
|
+
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`."
|
444
687
|
Enabled: false
|
445
688
|
VersionAdded: '0.43'
|
446
689
|
# This will convert usages of `try` to use safe navigation as well as `try!`.
|
@@ -478,6 +721,16 @@ Rails/ScopeArgs:
|
|
478
721
|
Include:
|
479
722
|
- app/models/**/*.rb
|
480
723
|
|
724
|
+
Rails/ShortI18n:
|
725
|
+
Description: 'Use the short form of the I18n methods: `t` instead of `translate` and `l` instead of `localize`.'
|
726
|
+
StyleGuide: 'https://rails.rubystyle.guide/#short-i18n'
|
727
|
+
Enabled: true
|
728
|
+
VersionAdded: '2.7'
|
729
|
+
EnforcedStyle: conservative
|
730
|
+
SupportedStyles:
|
731
|
+
- conservative
|
732
|
+
- aggressive
|
733
|
+
|
481
734
|
Rails/SkipsModelValidations:
|
482
735
|
Description: >-
|
483
736
|
Use methods that skips model validations with caution.
|
@@ -485,20 +738,37 @@ Rails/SkipsModelValidations:
|
|
485
738
|
Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
|
486
739
|
Enabled: false
|
487
740
|
VersionAdded: '0.47'
|
488
|
-
VersionChanged: '
|
489
|
-
|
741
|
+
VersionChanged: '2.7'
|
742
|
+
ForbiddenMethods:
|
490
743
|
- decrement!
|
491
744
|
- decrement_counter
|
492
745
|
- increment!
|
493
746
|
- increment_counter
|
747
|
+
- insert
|
748
|
+
- insert!
|
749
|
+
- insert_all
|
750
|
+
- insert_all!
|
494
751
|
- toggle!
|
495
752
|
- touch
|
753
|
+
- touch_all
|
496
754
|
- update_all
|
497
755
|
- update_attribute
|
498
756
|
- update_column
|
499
757
|
- update_columns
|
500
758
|
- update_counters
|
501
|
-
|
759
|
+
- upsert
|
760
|
+
- upsert_all
|
761
|
+
AllowedMethods: []
|
762
|
+
|
763
|
+
Rails/SquishedSQLHeredocs:
|
764
|
+
Description: 'Checks SQL heredocs to use `.squish`.'
|
765
|
+
StyleGuide: 'https://rails.rubystyle.guide/#squished-heredocs'
|
766
|
+
Enabled: true
|
767
|
+
VersionAdded: '2.8'
|
768
|
+
VersionChanged: '2.9'
|
769
|
+
# Some SQL syntax (e.g. PostgreSQL comments and functions) requires newlines
|
770
|
+
# to be preserved in order to work, thus auto-correction is not safe.
|
771
|
+
SafeAutoCorrect: false
|
502
772
|
|
503
773
|
Rails/TimeZone:
|
504
774
|
Description: 'Checks the correct usage of time zone aware methods.'
|
@@ -507,23 +777,35 @@ Rails/TimeZone:
|
|
507
777
|
Enabled: false
|
508
778
|
Safe: false
|
509
779
|
VersionAdded: '0.30'
|
510
|
-
VersionChanged: '
|
780
|
+
VersionChanged: '2.10'
|
511
781
|
# The value `strict` means that `Time` should be used with `zone`.
|
512
782
|
# The value `flexible` allows usage of `in_time_zone` instead of `zone`.
|
513
783
|
EnforcedStyle: flexible
|
514
784
|
SupportedStyles:
|
515
785
|
- strict
|
516
786
|
- flexible
|
787
|
+
Exclude:
|
788
|
+
- '**/*.gemspec'
|
789
|
+
|
790
|
+
Rails/TimeZoneAssignment:
|
791
|
+
Description: 'Prefer the usage of `Time.use_zone` instead of manually updating `Time.zone` value.'
|
792
|
+
Reference: 'https://thoughtbot.com/blog/its-about-time-zones'
|
793
|
+
Enabled: false
|
794
|
+
VersionAdded: '2.10'
|
795
|
+
Include:
|
796
|
+
- spec/**/*.rb
|
797
|
+
- test/**/*.rb
|
517
798
|
|
518
799
|
Rails/UniqBeforePluck:
|
519
800
|
Description: 'Prefer the use of uniq or distinct before pluck.'
|
520
801
|
Enabled: true
|
521
802
|
VersionAdded: '0.40'
|
522
|
-
VersionChanged: '
|
803
|
+
VersionChanged: '2.8'
|
523
804
|
EnforcedStyle: conservative
|
524
805
|
SupportedStyles:
|
525
806
|
- conservative
|
526
807
|
- aggressive
|
808
|
+
SafeAutoCorrect: false
|
527
809
|
AutoCorrect: false
|
528
810
|
|
529
811
|
Rails/UniqueValidationWithoutIndex:
|
@@ -542,6 +824,13 @@ Rails/UnknownEnv:
|
|
542
824
|
- test
|
543
825
|
- production
|
544
826
|
|
827
|
+
Rails/UnusedIgnoredColumns:
|
828
|
+
Description: 'Remove a column that does not exist from `ignored_columns`.'
|
829
|
+
Enabled: true
|
830
|
+
VersionAdded: '2.11'
|
831
|
+
Include:
|
832
|
+
- app/models/**/*.rb
|
833
|
+
|
545
834
|
Rails/Validation:
|
546
835
|
Description: 'Use validates :attribute, hash of validations.'
|
547
836
|
Enabled: true
|
@@ -549,3 +838,30 @@ Rails/Validation:
|
|
549
838
|
VersionChanged: '0.41'
|
550
839
|
Include:
|
551
840
|
- app/models/**/*.rb
|
841
|
+
|
842
|
+
Rails/WhereEquals:
|
843
|
+
Description: 'Pass conditions to `where` as a hash instead of manually constructing SQL.'
|
844
|
+
StyleGuide: 'https://rails.rubystyle.guide/#hash-conditions'
|
845
|
+
Enabled: true
|
846
|
+
VersionAdded: '2.9'
|
847
|
+
VersionChanged: '2.10'
|
848
|
+
|
849
|
+
Rails/WhereExists:
|
850
|
+
Description: 'Prefer `exists?(...)` over `where(...).exists?`.'
|
851
|
+
Enabled: true
|
852
|
+
EnforcedStyle: exists
|
853
|
+
SupportedStyles:
|
854
|
+
- exists
|
855
|
+
- where
|
856
|
+
VersionAdded: '2.7'
|
857
|
+
VersionChanged: '2.10'
|
858
|
+
|
859
|
+
Rails/WhereNot:
|
860
|
+
Description: 'Use `where.not(...)` instead of manually constructing negated SQL in `where`.'
|
861
|
+
StyleGuide: 'https://rails.rubystyle.guide/#hash-conditions'
|
862
|
+
Enabled: true
|
863
|
+
VersionAdded: '2.8'
|
864
|
+
|
865
|
+
# Accept `redirect_to(...) and return` and similar cases.
|
866
|
+
Style/AndOr:
|
867
|
+
EnforcedStyle: conditionals
|