standard-rails 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.standard.yml +1 -1
- data/CHANGELOG.md +8 -4
- data/Gemfile +1 -2
- data/Gemfile.lock +17 -9
- data/README.md +31 -3
- data/Rakefile +42 -1
- data/config/base.yml +474 -115
- data/lib/standard/rails/load_rubocop_rails_without_the_monkey_patch.rb +46 -0
- data/lib/standard/rails/plugin.rb +76 -0
- data/lib/standard/rails/version.rb +1 -1
- data/lib/standard/rails.rb +3 -7
- data/lib/standard-rails.rb +1 -0
- metadata +24 -6
data/config/base.yml
CHANGED
@@ -1,15 +1,17 @@
|
|
1
|
-
# Common configuration.
|
2
|
-
|
3
|
-
inherit_mode:
|
4
|
-
merge:
|
5
|
-
- Exclude
|
6
|
-
|
7
1
|
AllCops:
|
8
2
|
Exclude:
|
9
3
|
- bin/*
|
10
|
-
|
4
|
+
# Exclude db/schema.rb and db/[CONFIGURATION_NAMESPACE]_schema.rb by default.
|
5
|
+
# See: https://guides.rubyonrails.org/active_record_multiple_databases.html#setting-up-your-application
|
6
|
+
- db/*schema.rb
|
7
|
+
- log/**/*
|
8
|
+
- public/**/*
|
9
|
+
- storage/**/*
|
10
|
+
# Enable checking Active Support extensions.
|
11
|
+
# See: https://docs.rubocop.org/rubocop/configuration.html#enable-checking-active-support-extensions
|
12
|
+
ActiveSupportExtensionsEnabled: true
|
11
13
|
# What version of Rails is the inspected code using? If a value is specified
|
12
|
-
# for TargetRailsVersion then it is used. Acceptable values are
|
14
|
+
# for TargetRailsVersion then it is used. Acceptable values are specified
|
13
15
|
# as a float (i.e. 5.1); the patch version of Rails should not be included.
|
14
16
|
# If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or
|
15
17
|
# gems.locked file to find the version of Rails that has been bound to the
|
@@ -17,9 +19,28 @@ AllCops:
|
|
17
19
|
# as the default.
|
18
20
|
TargetRailsVersion: ~
|
19
21
|
|
22
|
+
Rails:
|
23
|
+
DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails
|
24
|
+
|
25
|
+
Rails/ActionControllerFlashBeforeRender:
|
26
|
+
Enabled: false
|
27
|
+
Description: 'Use `flash.now` instead of `flash` before `render`.'
|
28
|
+
SafeAutoCorrect: false
|
29
|
+
VersionAdded: '2.16'
|
30
|
+
|
31
|
+
Rails/ActionControllerTestCase:
|
32
|
+
Enabled: false
|
33
|
+
Description: 'Use `ActionDispatch::IntegrationTest` instead of `ActionController::TestCase`.'
|
34
|
+
StyleGuide: 'https://rails.rubystyle.guide/#integration-testing'
|
35
|
+
Reference: 'https://api.rubyonrails.org/classes/ActionController/TestCase.html'
|
36
|
+
SafeAutoCorrect: false
|
37
|
+
VersionAdded: '2.14'
|
38
|
+
Include:
|
39
|
+
- '**/test/**/*.rb'
|
40
|
+
|
20
41
|
Rails/ActionFilter:
|
42
|
+
Enabled: false
|
21
43
|
Description: 'Enforces consistent use of action filter methods.'
|
22
|
-
Enabled: true
|
23
44
|
VersionAdded: '0.19'
|
24
45
|
EnforcedStyle: action
|
25
46
|
SupportedStyles:
|
@@ -27,109 +48,150 @@ Rails/ActionFilter:
|
|
27
48
|
- filter
|
28
49
|
Include:
|
29
50
|
- app/controllers/**/*.rb
|
51
|
+
- app/mailers/**/*.rb
|
52
|
+
|
53
|
+
Rails/ActionOrder:
|
54
|
+
Enabled: false
|
55
|
+
Description: 'Enforce consistent ordering of controller actions.'
|
56
|
+
VersionAdded: '2.17'
|
57
|
+
ExpectedOrder:
|
58
|
+
- index
|
59
|
+
- show
|
60
|
+
- new
|
61
|
+
- edit
|
62
|
+
- create
|
63
|
+
- update
|
64
|
+
- destroy
|
65
|
+
Include:
|
66
|
+
- app/controllers/**/*.rb
|
30
67
|
|
31
68
|
Rails/ActiveRecordAliases:
|
69
|
+
Enabled: false
|
32
70
|
Description: >-
|
33
71
|
Avoid Active Record aliases:
|
34
72
|
Use `update` instead of `update_attributes`.
|
35
73
|
Use `update!` instead of `update_attributes!`.
|
36
|
-
Enabled: true
|
37
74
|
VersionAdded: '0.53'
|
38
75
|
SafeAutoCorrect: false
|
39
76
|
|
40
77
|
Rails/ActiveRecordCallbacksOrder:
|
78
|
+
Enabled: false
|
41
79
|
Description: 'Order callback declarations in the order in which they will be executed.'
|
42
80
|
StyleGuide: 'https://rails.rubystyle.guide/#callbacks-order'
|
43
|
-
Enabled: 'pending'
|
44
81
|
VersionAdded: '2.7'
|
45
82
|
Include:
|
46
83
|
- app/models/**/*.rb
|
47
84
|
|
48
85
|
Rails/ActiveRecordOverride:
|
86
|
+
Enabled: true
|
49
87
|
Description: >-
|
50
88
|
Check for overriding Active Record methods instead of using
|
51
89
|
callbacks.
|
52
|
-
|
90
|
+
Severity: warning
|
53
91
|
VersionAdded: '0.67'
|
92
|
+
VersionChanged: '2.18'
|
54
93
|
Include:
|
55
94
|
- app/models/**/*.rb
|
56
95
|
|
57
96
|
Rails/ActiveSupportAliases:
|
97
|
+
Enabled: false
|
58
98
|
Description: >-
|
59
99
|
Avoid ActiveSupport aliases of standard ruby methods:
|
60
100
|
`String#starts_with?`, `String#ends_with?`,
|
61
101
|
`Array#append`, `Array#prepend`.
|
62
|
-
Enabled: true
|
63
102
|
VersionAdded: '0.48'
|
64
103
|
|
104
|
+
Rails/ActiveSupportOnLoad:
|
105
|
+
Enabled: false
|
106
|
+
Description: 'Use `ActiveSupport.on_load(...)` to patch Rails framework classes.'
|
107
|
+
Reference:
|
108
|
+
- 'https://api.rubyonrails.org/classes/ActiveSupport/LazyLoadHooks.html'
|
109
|
+
- 'https://guides.rubyonrails.org/engines.html#available-load-hooks'
|
110
|
+
SafeAutoCorrect: false
|
111
|
+
VersionAdded: '2.16'
|
112
|
+
|
113
|
+
Rails/AddColumnIndex:
|
114
|
+
Enabled: false
|
115
|
+
Description: >-
|
116
|
+
Rails migrations don't make use of a given `index` key, but also
|
117
|
+
doesn't given an error when it's used, so it makes it seem like an
|
118
|
+
index might be used.
|
119
|
+
VersionAdded: '2.11'
|
120
|
+
Include:
|
121
|
+
- db/migrate/*.rb
|
122
|
+
|
65
123
|
Rails/AfterCommitOverride:
|
124
|
+
Enabled: false
|
66
125
|
Description: >-
|
67
|
-
|
126
|
+
Enforces that there is only one call to `after_commit`
|
68
127
|
(and its aliases - `after_create_commit`, `after_update_commit`,
|
69
128
|
and `after_destroy_commit`) with the same callback name per model.
|
70
|
-
Enabled: 'pending'
|
71
129
|
VersionAdded: '2.8'
|
72
130
|
|
73
131
|
Rails/ApplicationController:
|
74
|
-
Description: 'Check that controllers subclass ApplicationController.'
|
75
132
|
Enabled: true
|
133
|
+
Description: 'Check that controllers subclass ApplicationController.'
|
76
134
|
SafeAutoCorrect: false
|
77
135
|
VersionAdded: '2.4'
|
78
136
|
VersionChanged: '2.5'
|
79
137
|
|
80
138
|
Rails/ApplicationJob:
|
81
|
-
Description: 'Check that jobs subclass ApplicationJob.'
|
82
139
|
Enabled: true
|
140
|
+
Description: 'Check that jobs subclass ApplicationJob.'
|
83
141
|
SafeAutoCorrect: false
|
84
142
|
VersionAdded: '0.49'
|
85
143
|
VersionChanged: '2.5'
|
86
144
|
|
87
145
|
Rails/ApplicationMailer:
|
88
|
-
Description: 'Check that mailers subclass ApplicationMailer.'
|
89
146
|
Enabled: true
|
147
|
+
Description: 'Check that mailers subclass ApplicationMailer.'
|
90
148
|
SafeAutoCorrect: false
|
91
149
|
VersionAdded: '2.4'
|
92
150
|
VersionChanged: '2.5'
|
93
151
|
|
94
152
|
Rails/ApplicationRecord:
|
95
|
-
Description: 'Check that models subclass ApplicationRecord.'
|
96
153
|
Enabled: true
|
154
|
+
Description: 'Check that models subclass ApplicationRecord.'
|
97
155
|
SafeAutoCorrect: false
|
98
156
|
VersionAdded: '0.49'
|
99
157
|
VersionChanged: '2.5'
|
100
158
|
|
101
159
|
Rails/ArelStar:
|
160
|
+
Enabled: false
|
102
161
|
Description: 'Enforces `Arel.star` instead of `"*"` for expanded columns.'
|
103
|
-
Enabled: true
|
104
162
|
SafeAutoCorrect: false
|
105
163
|
VersionAdded: '2.9'
|
106
164
|
|
107
165
|
Rails/AssertNot:
|
166
|
+
Enabled: false
|
108
167
|
Description: 'Use `assert_not` instead of `assert !`.'
|
109
|
-
Enabled: true
|
110
168
|
VersionAdded: '0.56'
|
111
169
|
Include:
|
112
170
|
- '**/test/**/*'
|
113
171
|
|
114
172
|
Rails/AttributeDefaultBlockValue:
|
173
|
+
Enabled: false
|
115
174
|
Description: 'Pass method call in block for attribute option `default`.'
|
116
|
-
Enabled: pending
|
117
175
|
VersionAdded: '2.9'
|
118
176
|
Include:
|
119
|
-
- 'models/**/*'
|
177
|
+
- 'app/models/**/*'
|
120
178
|
|
121
179
|
Rails/BelongsTo:
|
180
|
+
Enabled: true
|
122
181
|
Description: >-
|
123
182
|
Use `optional: true` instead of `required: false` for
|
124
183
|
`belongs_to` relations.
|
125
|
-
|
184
|
+
Reference:
|
185
|
+
- https://guides.rubyonrails.org/5_0_release_notes.html
|
186
|
+
- https://github.com/rails/rails/pull/18937
|
126
187
|
VersionAdded: '0.62'
|
127
188
|
|
128
189
|
Rails/Blank:
|
129
|
-
Description: 'Enforces use of `blank?`.'
|
130
190
|
Enabled: true
|
191
|
+
Description: 'Enforces use of `blank?`.'
|
192
|
+
SafeAutoCorrect: false
|
131
193
|
VersionAdded: '0.48'
|
132
|
-
VersionChanged: '
|
194
|
+
VersionChanged: '2.10'
|
133
195
|
# Convert usages of `nil? || empty?` to `blank?`
|
134
196
|
NilOrEmpty: true
|
135
197
|
# Convert usages of `!present?` to `blank?`
|
@@ -138,8 +200,11 @@ Rails/Blank:
|
|
138
200
|
UnlessPresent: true
|
139
201
|
|
140
202
|
Rails/BulkChangeTable:
|
203
|
+
Enabled: false
|
141
204
|
Description: 'Check whether alter queries are combinable.'
|
142
|
-
|
205
|
+
Reference:
|
206
|
+
- https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-change_table
|
207
|
+
- https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Table.html
|
143
208
|
VersionAdded: '0.57'
|
144
209
|
Database: null
|
145
210
|
SupportedDatabases:
|
@@ -148,30 +213,48 @@ Rails/BulkChangeTable:
|
|
148
213
|
Include:
|
149
214
|
- db/migrate/*.rb
|
150
215
|
|
216
|
+
Rails/CompactBlank:
|
217
|
+
Enabled: false
|
218
|
+
Description: 'Checks if collection can be blank-compacted with `compact_blank`.'
|
219
|
+
Safe: false
|
220
|
+
VersionAdded: '2.13'
|
221
|
+
|
151
222
|
Rails/ContentTag:
|
152
|
-
|
223
|
+
Enabled: false
|
224
|
+
Description: 'Use `tag.something` instead of `tag(:something)`.'
|
153
225
|
Reference:
|
226
|
+
- 'https://github.com/rubocop/rubocop-rails/issues/260'
|
154
227
|
- 'https://github.com/rails/rails/issues/25195'
|
155
228
|
- 'https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-content_tag'
|
156
|
-
Enabled: true
|
157
229
|
VersionAdded: '2.6'
|
230
|
+
VersionChanged: '2.12'
|
231
|
+
# This `Exclude` config prevents false positives for `tag` calls to `has_one: tag` and Puma configuration:
|
232
|
+
# https://puma.io/puma/Puma/DSL.html#tag-instance_method
|
233
|
+
# No helpers are used in normal models and configs.
|
234
|
+
Exclude:
|
235
|
+
- app/models/**/*.rb
|
236
|
+
- config/**/*.rb
|
158
237
|
|
159
238
|
Rails/CreateTableWithTimestamps:
|
239
|
+
Enabled: true
|
160
240
|
Description: >-
|
161
241
|
Checks the migration for which timestamps are not included
|
162
242
|
when creating a new table.
|
163
|
-
Enabled: true
|
164
243
|
VersionAdded: '0.52'
|
165
244
|
Include:
|
166
245
|
- db/migrate/*.rb
|
246
|
+
Exclude:
|
247
|
+
# Respect the `active_storage_variant_records` table of `*_create_active_storage_tables.active_storage.rb`
|
248
|
+
# auto-generated by `bin/rails active_storage:install` even if `created_at` is not specified.
|
249
|
+
- db/migrate/*_create_active_storage_tables.active_storage.rb
|
167
250
|
|
168
251
|
Rails/Date:
|
252
|
+
Enabled: true
|
169
253
|
Description: >-
|
170
254
|
Checks the correct usage of date aware methods,
|
171
255
|
such as Date.today, Date.current etc.
|
172
|
-
Enabled: true
|
173
256
|
VersionAdded: '0.30'
|
174
|
-
VersionChanged: '
|
257
|
+
VersionChanged: '2.11'
|
175
258
|
# The value `strict` disallows usage of `Date.today`, `Date.current`,
|
176
259
|
# `Date#to_time` etc.
|
177
260
|
# The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
|
@@ -181,16 +264,17 @@ Rails/Date:
|
|
181
264
|
SupportedStyles:
|
182
265
|
- strict
|
183
266
|
- flexible
|
267
|
+
AllowToTime: true
|
184
268
|
|
185
269
|
Rails/DefaultScope:
|
270
|
+
Enabled: false
|
186
271
|
Description: 'Avoid use of `default_scope`.'
|
187
272
|
StyleGuide: 'https://rails.rubystyle.guide#avoid-default-scope'
|
188
|
-
Enabled: false
|
189
273
|
VersionAdded: '2.7'
|
190
274
|
|
191
275
|
Rails/Delegate:
|
276
|
+
Enabled: false
|
192
277
|
Description: 'Prefer delegate method for delegations.'
|
193
|
-
Enabled: true
|
194
278
|
VersionAdded: '0.21'
|
195
279
|
VersionChanged: '0.50'
|
196
280
|
# When set to true, using the target object as a prefix of the
|
@@ -199,50 +283,108 @@ Rails/Delegate:
|
|
199
283
|
EnforceForPrefixed: true
|
200
284
|
|
201
285
|
Rails/DelegateAllowBlank:
|
286
|
+
Enabled: false
|
202
287
|
Description: 'Do not use allow_blank as an option to delegate.'
|
203
|
-
Enabled: true
|
204
288
|
VersionAdded: '0.44'
|
205
289
|
|
290
|
+
Rails/DeprecatedActiveModelErrorsMethods:
|
291
|
+
Enabled: false
|
292
|
+
Description: 'Avoid manipulating ActiveModel errors hash directly.'
|
293
|
+
Severity: warning
|
294
|
+
Safe: false
|
295
|
+
VersionAdded: '2.14'
|
296
|
+
VersionChanged: '2.18'
|
297
|
+
|
298
|
+
Rails/DotSeparatedKeys:
|
299
|
+
Enabled: false
|
300
|
+
Description: 'Enforces the use of dot-separated keys instead of `:scope` options in `I18n` translation methods.'
|
301
|
+
StyleGuide: 'https://rails.rubystyle.guide/#dot-separated-keys'
|
302
|
+
VersionAdded: '2.15'
|
303
|
+
|
304
|
+
Rails/DuplicateAssociation:
|
305
|
+
Enabled: false
|
306
|
+
Description: "Don't repeat associations in a model."
|
307
|
+
Severity: warning
|
308
|
+
VersionAdded: '2.14'
|
309
|
+
VersionChanged: '2.18'
|
310
|
+
|
311
|
+
Rails/DuplicateScope:
|
312
|
+
Enabled: false
|
313
|
+
Description: 'Multiple scopes share this same where clause.'
|
314
|
+
Severity: warning
|
315
|
+
VersionAdded: '2.14'
|
316
|
+
VersionChanged: '2.18'
|
317
|
+
|
318
|
+
Rails/DurationArithmetic:
|
319
|
+
Enabled: false
|
320
|
+
Description: 'Do not use duration as arithmetic operand with `Time.current`.'
|
321
|
+
StyleGuide: 'https://rails.rubystyle.guide#duration-arithmetic'
|
322
|
+
VersionAdded: '2.13'
|
323
|
+
|
206
324
|
Rails/DynamicFindBy:
|
325
|
+
Enabled: false
|
207
326
|
Description: 'Use `find_by` instead of dynamic `find_by_*`.'
|
208
327
|
StyleGuide: 'https://rails.rubystyle.guide#find_by'
|
209
|
-
|
328
|
+
Safe: false
|
210
329
|
VersionAdded: '0.44'
|
211
|
-
VersionChanged: '2.
|
330
|
+
VersionChanged: '2.10'
|
212
331
|
# The `Whitelist` has been deprecated, Please use `AllowedMethods` instead.
|
213
332
|
Whitelist:
|
214
333
|
- find_by_sql
|
334
|
+
- find_by_token_for
|
215
335
|
AllowedMethods:
|
216
336
|
- find_by_sql
|
337
|
+
- find_by_token_for
|
217
338
|
AllowedReceivers:
|
218
339
|
- Gem::Specification
|
340
|
+
- page # Prevents a warning for `page.find_by_id`. See: https://github.com/rubocop/rubocop-rails/issues/778
|
341
|
+
|
342
|
+
Rails/EagerEvaluationLogMessage:
|
343
|
+
Enabled: false
|
344
|
+
Description: 'Checks that blocks are used for interpolated strings passed to `Rails.logger.debug`.'
|
345
|
+
Reference: 'https://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance'
|
346
|
+
VersionAdded: '2.11'
|
219
347
|
|
220
348
|
Rails/EnumHash:
|
349
|
+
Enabled: false
|
221
350
|
Description: 'Prefer hash syntax over array syntax when defining enums.'
|
222
351
|
StyleGuide: 'https://rails.rubystyle.guide#enums'
|
223
|
-
Enabled: true
|
224
352
|
VersionAdded: '2.3'
|
225
353
|
Include:
|
226
354
|
- app/models/**/*.rb
|
227
355
|
|
228
356
|
Rails/EnumUniqueness:
|
357
|
+
Enabled: false
|
229
358
|
Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
|
230
|
-
Enabled: true
|
231
359
|
VersionAdded: '0.46'
|
232
360
|
Include:
|
233
361
|
- app/models/**/*.rb
|
234
362
|
|
235
363
|
Rails/EnvironmentComparison:
|
364
|
+
Enabled: false
|
236
365
|
Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`."
|
237
|
-
Enabled: true
|
238
366
|
VersionAdded: '0.52'
|
239
367
|
|
368
|
+
Rails/EnvironmentVariableAccess:
|
369
|
+
Enabled: true
|
370
|
+
Description: 'Do not access `ENV` directly after initialization.'
|
371
|
+
# TODO: Set to `pending` status in RuboCop Rails 2 series when migration doc will be written.
|
372
|
+
VersionAdded: '2.10'
|
373
|
+
VersionChanged: '2.11'
|
374
|
+
Include:
|
375
|
+
- app/**/*.rb
|
376
|
+
- lib/**/*.rb
|
377
|
+
Exclude:
|
378
|
+
- lib/**/*.rake
|
379
|
+
AllowReads: false
|
380
|
+
AllowWrites: false
|
381
|
+
|
240
382
|
Rails/Exit:
|
383
|
+
Enabled: false
|
241
384
|
Description: >-
|
242
385
|
Favor `fail`, `break`, `return`, etc. over `exit` in
|
243
386
|
application or library code outside of Rake files to avoid
|
244
387
|
exits during unit testing or running in production.
|
245
|
-
Enabled: true
|
246
388
|
VersionAdded: '0.41'
|
247
389
|
Include:
|
248
390
|
- app/**/*.rb
|
@@ -251,9 +393,15 @@ Rails/Exit:
|
|
251
393
|
Exclude:
|
252
394
|
- lib/**/*.rake
|
253
395
|
|
396
|
+
Rails/ExpandedDateRange:
|
397
|
+
Enabled: false
|
398
|
+
Description: 'Checks for expanded date range.'
|
399
|
+
StyleGuide: 'https://rails.rubystyle.guide/#date-time-range'
|
400
|
+
VersionAdded: '2.11'
|
401
|
+
|
254
402
|
Rails/FilePath:
|
403
|
+
Enabled: false
|
255
404
|
Description: 'Use `Rails.root.join` for file path joining.'
|
256
|
-
Enabled: true
|
257
405
|
VersionAdded: '0.47'
|
258
406
|
VersionChanged: '2.4'
|
259
407
|
EnforcedStyle: slashes
|
@@ -262,173 +410,229 @@ Rails/FilePath:
|
|
262
410
|
- arguments
|
263
411
|
|
264
412
|
Rails/FindBy:
|
413
|
+
Enabled: false
|
265
414
|
Description: 'Prefer find_by over where.first.'
|
266
415
|
StyleGuide: 'https://rails.rubystyle.guide#find_by'
|
267
|
-
Enabled: true
|
268
416
|
VersionAdded: '0.30'
|
417
|
+
VersionChanged: '2.11'
|
418
|
+
IgnoreWhereFirst: true
|
269
419
|
Include:
|
270
420
|
- app/models/**/*.rb
|
271
421
|
|
272
422
|
Rails/FindById:
|
423
|
+
Enabled: false
|
273
424
|
Description: >-
|
274
425
|
Favor the use of `find` over `where.take!`, `find_by!`, and `find_by_id!` when you
|
275
426
|
need to retrieve a single record by primary key when you expect it to be found.
|
276
427
|
StyleGuide: 'https://rails.rubystyle.guide/#find'
|
277
|
-
Enabled: 'pending'
|
278
428
|
VersionAdded: '2.7'
|
279
429
|
|
280
430
|
Rails/FindEach:
|
281
|
-
|
431
|
+
Enabled: false
|
432
|
+
Description: 'Prefer all.find_each over all.each.'
|
282
433
|
StyleGuide: 'https://rails.rubystyle.guide#find-each'
|
283
|
-
|
434
|
+
Safe: false
|
284
435
|
VersionAdded: '0.30'
|
285
|
-
VersionChanged: '2.
|
436
|
+
VersionChanged: '2.19'
|
286
437
|
Include:
|
287
438
|
- app/models/**/*.rb
|
288
|
-
|
439
|
+
AllowedMethods:
|
289
440
|
# Methods that don't work well with `find_each`.
|
290
441
|
- order
|
291
442
|
- limit
|
292
443
|
- select
|
293
444
|
- lock
|
445
|
+
AllowedPatterns: []
|
446
|
+
|
447
|
+
Rails/FreezeTime:
|
448
|
+
Enabled: false
|
449
|
+
Description: 'Prefer `freeze_time` over `travel_to` with an argument of the current time.'
|
450
|
+
StyleGuide: 'https://rails.rubystyle.guide/#freeze-time'
|
451
|
+
VersionAdded: '2.16'
|
452
|
+
SafeAutoCorrect: false
|
294
453
|
|
295
454
|
Rails/HasAndBelongsToMany:
|
455
|
+
Enabled: false
|
296
456
|
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
297
457
|
StyleGuide: 'https://rails.rubystyle.guide#has-many-through'
|
298
|
-
Enabled: true
|
299
458
|
VersionAdded: '0.12'
|
300
459
|
Include:
|
301
460
|
- app/models/**/*.rb
|
302
461
|
|
303
462
|
Rails/HasManyOrHasOneDependent:
|
463
|
+
Enabled: false
|
304
464
|
Description: 'Define the dependent option to the has_many and has_one associations.'
|
305
465
|
StyleGuide: 'https://rails.rubystyle.guide#has_many-has_one-dependent-option'
|
306
|
-
Enabled: true
|
307
466
|
VersionAdded: '0.50'
|
308
467
|
Include:
|
309
468
|
- app/models/**/*.rb
|
310
469
|
|
311
470
|
Rails/HelperInstanceVariable:
|
471
|
+
Enabled: false
|
312
472
|
Description: 'Do not use instance variables in helpers.'
|
313
|
-
Enabled: true
|
314
473
|
VersionAdded: '2.0'
|
315
474
|
Include:
|
316
475
|
- app/helpers/**/*.rb
|
317
476
|
|
318
477
|
Rails/HttpPositionalArguments:
|
478
|
+
Enabled: false
|
319
479
|
Description: 'Use keyword arguments instead of positional arguments in http method calls.'
|
320
|
-
Enabled: true
|
321
480
|
VersionAdded: '0.44'
|
322
481
|
Include:
|
323
482
|
- 'spec/**/*'
|
324
483
|
- 'test/**/*'
|
325
484
|
|
326
485
|
Rails/HttpStatus:
|
486
|
+
Enabled: false
|
327
487
|
Description: 'Enforces use of symbolic or numeric value to define HTTP status.'
|
328
|
-
Enabled: true
|
329
488
|
VersionAdded: '0.54'
|
489
|
+
VersionChanged: '2.11'
|
330
490
|
EnforcedStyle: symbolic
|
331
491
|
SupportedStyles:
|
332
492
|
- numeric
|
333
493
|
- symbolic
|
334
494
|
|
495
|
+
Rails/I18nLazyLookup:
|
496
|
+
Enabled: false
|
497
|
+
Description: 'Checks for places where I18n "lazy" lookup can be used.'
|
498
|
+
StyleGuide: 'https://rails.rubystyle.guide/#lazy-lookup'
|
499
|
+
Reference: 'https://guides.rubyonrails.org/i18n.html#lazy-lookup'
|
500
|
+
VersionAdded: '2.14'
|
501
|
+
Include:
|
502
|
+
- 'app/controllers/**/*.rb'
|
503
|
+
|
504
|
+
Rails/I18nLocaleAssignment:
|
505
|
+
Enabled: false
|
506
|
+
Description: 'Prefer the usage of `I18n.with_locale` instead of manually updating `I18n.locale` value.'
|
507
|
+
VersionAdded: '2.11'
|
508
|
+
Include:
|
509
|
+
- spec/**/*.rb
|
510
|
+
- test/**/*.rb
|
511
|
+
|
512
|
+
Rails/I18nLocaleTexts:
|
513
|
+
Enabled: false
|
514
|
+
Description: 'Enforces use of I18n and locale files instead of locale specific strings.'
|
515
|
+
StyleGuide: 'https://rails.rubystyle.guide/#locale-texts'
|
516
|
+
VersionAdded: '2.14'
|
517
|
+
|
518
|
+
Rails/IgnoredColumnsAssignment:
|
519
|
+
Enabled: false
|
520
|
+
Description: 'Looks for assignments of `ignored_columns` that override previous assignments.'
|
521
|
+
StyleGuide: 'https://rails.rubystyle.guide/#append-ignored-columns'
|
522
|
+
SafeAutoCorrect: false
|
523
|
+
VersionAdded: '2.17'
|
524
|
+
|
335
525
|
Rails/IgnoredSkipActionFilterOption:
|
526
|
+
Enabled: false
|
336
527
|
Description: 'Checks that `if` and `only` (or `except`) are not used together as options of `skip_*` action filter.'
|
337
528
|
Reference: 'https://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#method-i-_normalize_callback_options'
|
338
|
-
Enabled: true
|
339
529
|
VersionAdded: '0.63'
|
340
530
|
Include:
|
341
531
|
- app/controllers/**/*.rb
|
532
|
+
- app/mailers/**/*.rb
|
342
533
|
|
343
534
|
Rails/IndexBy:
|
535
|
+
Enabled: false
|
344
536
|
Description: 'Prefer `index_by` over `each_with_object`, `to_h`, or `map`.'
|
345
|
-
Enabled: true
|
346
537
|
VersionAdded: '2.5'
|
347
538
|
VersionChanged: '2.8'
|
348
539
|
|
349
540
|
Rails/IndexWith:
|
541
|
+
Enabled: false
|
350
542
|
Description: 'Prefer `index_with` over `each_with_object`, `to_h`, or `map`.'
|
351
|
-
Enabled: true
|
352
543
|
VersionAdded: '2.5'
|
353
544
|
VersionChanged: '2.8'
|
354
545
|
|
355
546
|
Rails/Inquiry:
|
547
|
+
Enabled: false
|
356
548
|
Description: "Prefer Ruby's comparison operators over Active Support's `Array#inquiry` and `String#inquiry`."
|
357
549
|
StyleGuide: 'https://rails.rubystyle.guide/#inquiry'
|
358
|
-
Enabled: 'pending'
|
359
550
|
VersionAdded: '2.7'
|
360
551
|
|
361
552
|
Rails/InverseOf:
|
553
|
+
Enabled: false
|
362
554
|
Description: 'Checks for associations where the inverse cannot be determined automatically.'
|
363
|
-
|
555
|
+
Reference:
|
556
|
+
- https://guides.rubyonrails.org/association_basics.html#bi-directional-associations
|
557
|
+
- https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses
|
364
558
|
VersionAdded: '0.52'
|
559
|
+
IgnoreScopes: false
|
365
560
|
Include:
|
366
561
|
- app/models/**/*.rb
|
367
562
|
|
368
563
|
Rails/LexicallyScopedActionFilter:
|
369
|
-
|
564
|
+
Enabled: false
|
565
|
+
Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the class."
|
370
566
|
StyleGuide: 'https://rails.rubystyle.guide#lexically-scoped-action-filter'
|
371
|
-
Enabled: true
|
372
567
|
Safe: false
|
373
568
|
VersionAdded: '0.52'
|
374
569
|
Include:
|
375
570
|
- app/controllers/**/*.rb
|
571
|
+
- app/mailers/**/*.rb
|
376
572
|
|
377
573
|
Rails/LinkToBlank:
|
574
|
+
Enabled: false
|
378
575
|
Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
|
379
576
|
Reference:
|
380
577
|
- https://mathiasbynens.github.io/rel-noopener/
|
381
578
|
- https://html.spec.whatwg.org/multipage/links.html#link-type-noopener
|
382
579
|
- https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer
|
383
|
-
Enabled: true
|
384
580
|
VersionAdded: '0.62'
|
385
581
|
|
386
582
|
Rails/MailerName:
|
583
|
+
Enabled: false
|
387
584
|
Description: 'Mailer should end with `Mailer` suffix.'
|
388
585
|
StyleGuide: 'https://rails.rubystyle.guide/#mailer-name'
|
389
|
-
Enabled: 'pending'
|
390
586
|
SafeAutoCorrect: false
|
391
587
|
VersionAdded: '2.7'
|
392
588
|
Include:
|
393
589
|
- app/mailers/**/*.rb
|
394
590
|
|
395
591
|
Rails/MatchRoute:
|
592
|
+
Enabled: false
|
396
593
|
Description: >-
|
397
594
|
Don't use `match` to define any routes unless there is a need to map multiple request types
|
398
595
|
among [:get, :post, :patch, :put, :delete] to a single action using the `:via` option.
|
399
596
|
StyleGuide: 'https://rails.rubystyle.guide/#no-match-routes'
|
400
|
-
Enabled: 'pending'
|
401
597
|
VersionAdded: '2.7'
|
402
598
|
Include:
|
403
599
|
- config/routes.rb
|
404
600
|
- config/routes/**/*.rb
|
405
601
|
|
602
|
+
Rails/MigrationClassName:
|
603
|
+
Enabled: false
|
604
|
+
Description: 'The class name of the migration should match its file name.'
|
605
|
+
VersionAdded: '2.14'
|
606
|
+
Include:
|
607
|
+
- db/migrate/*.rb
|
608
|
+
|
406
609
|
Rails/NegateInclude:
|
610
|
+
Enabled: false
|
407
611
|
Description: 'Prefer `collection.exclude?(obj)` over `!collection.include?(obj)`.'
|
408
612
|
StyleGuide: 'https://rails.rubystyle.guide#exclude'
|
409
|
-
Enabled: 'pending'
|
410
613
|
Safe: false
|
411
614
|
VersionAdded: '2.7'
|
412
615
|
VersionChanged: '2.9'
|
413
616
|
|
414
617
|
Rails/NotNullColumn:
|
618
|
+
Enabled: false
|
415
619
|
Description: 'Do not add a NOT NULL column without a default value.'
|
416
|
-
Enabled: true
|
417
620
|
VersionAdded: '0.43'
|
418
621
|
Include:
|
419
622
|
- db/migrate/*.rb
|
420
623
|
|
421
624
|
Rails/OrderById:
|
625
|
+
Enabled: false
|
422
626
|
Description: >-
|
423
627
|
Do not use the `id` column for ordering.
|
424
628
|
Use a timestamp column to order chronologically.
|
425
629
|
StyleGuide: 'https://rails.rubystyle.guide/#order-by-id'
|
426
|
-
Enabled: false
|
427
630
|
VersionAdded: '2.8'
|
428
631
|
|
429
632
|
Rails/Output:
|
633
|
+
Enabled: false
|
430
634
|
Description: 'Checks for calls to puts, print, etc.'
|
431
|
-
|
635
|
+
SafeAutoCorrect: false
|
432
636
|
VersionAdded: '0.15'
|
433
637
|
VersionChanged: '0.19'
|
434
638
|
Include:
|
@@ -438,33 +642,35 @@ Rails/Output:
|
|
438
642
|
- lib/**/*.rb
|
439
643
|
|
440
644
|
Rails/OutputSafety:
|
645
|
+
Enabled: false
|
441
646
|
Description: 'The use of `html_safe` or `raw` may be a security risk.'
|
442
|
-
Enabled: true
|
443
647
|
VersionAdded: '0.41'
|
444
648
|
|
445
649
|
Rails/Pick:
|
650
|
+
Enabled: false
|
446
651
|
Description: 'Prefer `pick` over `pluck(...).first`.'
|
447
652
|
StyleGuide: 'https://rails.rubystyle.guide#pick'
|
448
|
-
Enabled: true
|
449
653
|
Safe: false
|
450
654
|
VersionAdded: '2.6'
|
451
655
|
|
452
656
|
Rails/Pluck:
|
657
|
+
Enabled: false
|
453
658
|
Description: 'Prefer `pluck` over `map { ... }`.'
|
454
659
|
StyleGuide: 'https://rails.rubystyle.guide#pluck'
|
455
|
-
|
660
|
+
Safe: false
|
456
661
|
VersionAdded: '2.7'
|
662
|
+
VersionChanged: '2.18'
|
457
663
|
|
458
664
|
Rails/PluckId:
|
665
|
+
Enabled: false
|
459
666
|
Description: 'Use `ids` instead of `pluck(:id)` or `pluck(primary_key)`.'
|
460
667
|
StyleGuide: 'https://rails.rubystyle.guide/#ids'
|
461
|
-
Enabled: false
|
462
668
|
Safe: false
|
463
669
|
VersionAdded: '2.7'
|
464
670
|
|
465
671
|
Rails/PluckInWhere:
|
672
|
+
Enabled: false
|
466
673
|
Description: 'Use `select` instead of `pluck` in `where` query methods.'
|
467
|
-
Enabled: 'pending'
|
468
674
|
Safe: false
|
469
675
|
VersionAdded: '2.7'
|
470
676
|
VersionChanged: '2.8'
|
@@ -474,18 +680,18 @@ Rails/PluckInWhere:
|
|
474
680
|
- aggressive
|
475
681
|
|
476
682
|
Rails/PluralizationGrammar:
|
683
|
+
Enabled: false
|
477
684
|
Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
|
478
|
-
Enabled: true
|
479
685
|
VersionAdded: '0.35'
|
480
686
|
|
481
687
|
Rails/Presence:
|
688
|
+
Enabled: false
|
482
689
|
Description: 'Checks code that can be written more easily using `Object#presence` defined by Active Support.'
|
483
|
-
Enabled: true
|
484
690
|
VersionAdded: '0.52'
|
485
691
|
|
486
692
|
Rails/Present:
|
693
|
+
Enabled: false
|
487
694
|
Description: 'Enforces use of `present?`.'
|
488
|
-
Enabled: true
|
489
695
|
VersionAdded: '0.48'
|
490
696
|
VersionChanged: '0.67'
|
491
697
|
# Convert usages of `!nil? && !empty?` to `present?`
|
@@ -496,8 +702,8 @@ Rails/Present:
|
|
496
702
|
UnlessBlank: true
|
497
703
|
|
498
704
|
Rails/RakeEnvironment:
|
705
|
+
Enabled: false
|
499
706
|
Description: 'Include `:environment` as a dependency for all Rake tasks.'
|
500
|
-
Enabled: true
|
501
707
|
Safe: false
|
502
708
|
VersionAdded: '2.4'
|
503
709
|
VersionChanged: '2.6'
|
@@ -508,43 +714,59 @@ Rails/RakeEnvironment:
|
|
508
714
|
- 'lib/capistrano/tasks/**/*.rake'
|
509
715
|
|
510
716
|
Rails/ReadWriteAttribute:
|
717
|
+
Enabled: false
|
511
718
|
Description: >-
|
512
719
|
Checks for read_attribute(:attr) and
|
513
720
|
write_attribute(:attr, val).
|
514
721
|
StyleGuide: 'https://rails.rubystyle.guide#read-attribute'
|
515
|
-
Enabled: true
|
516
722
|
VersionAdded: '0.20'
|
517
723
|
VersionChanged: '0.29'
|
518
724
|
Include:
|
519
725
|
- app/models/**/*.rb
|
520
726
|
|
521
727
|
Rails/RedundantAllowNil:
|
728
|
+
Enabled: false
|
522
729
|
Description: >-
|
523
730
|
Finds redundant use of `allow_nil` when `allow_blank` is set to
|
524
731
|
certain values in model validations.
|
525
|
-
Enabled: true
|
526
732
|
VersionAdded: '0.67'
|
527
733
|
Include:
|
528
734
|
- app/models/**/*.rb
|
529
735
|
|
530
736
|
Rails/RedundantForeignKey:
|
737
|
+
Enabled: false
|
531
738
|
Description: 'Checks for associations where the `:foreign_key` option is redundant.'
|
532
|
-
Enabled: true
|
533
739
|
VersionAdded: '2.6'
|
534
740
|
|
741
|
+
Rails/RedundantPresenceValidationOnBelongsTo:
|
742
|
+
Enabled: true
|
743
|
+
Description: 'Checks for redundant presence validation on belongs_to association.'
|
744
|
+
SafeAutoCorrect: false
|
745
|
+
VersionAdded: '2.13'
|
746
|
+
|
535
747
|
Rails/RedundantReceiverInWithOptions:
|
748
|
+
Enabled: false
|
536
749
|
Description: 'Checks for redundant receiver in `with_options`.'
|
537
|
-
Enabled: true
|
538
750
|
VersionAdded: '0.52'
|
539
751
|
|
752
|
+
Rails/RedundantTravelBack:
|
753
|
+
Enabled: false
|
754
|
+
Description: Checks for redundant `travel_back` calls.
|
755
|
+
VersionAdded: '2.12'
|
756
|
+
Include:
|
757
|
+
- spec/**/*.rb
|
758
|
+
- test/**/*.rb
|
759
|
+
|
540
760
|
Rails/ReflectionClassName:
|
761
|
+
Enabled: false
|
541
762
|
Description: 'Use a string for `class_name` option value in the definition of a reflection.'
|
542
|
-
|
763
|
+
Safe: false
|
543
764
|
VersionAdded: '0.64'
|
765
|
+
VersionChanged: '2.10'
|
544
766
|
|
545
767
|
Rails/RefuteMethods:
|
768
|
+
Enabled: false
|
546
769
|
Description: 'Use `assert_not` methods instead of `refute` methods.'
|
547
|
-
Enabled: true
|
548
770
|
VersionAdded: '0.56'
|
549
771
|
EnforcedStyle: assert_not
|
550
772
|
SupportedStyles:
|
@@ -554,47 +776,90 @@ Rails/RefuteMethods:
|
|
554
776
|
- '**/test/**/*'
|
555
777
|
|
556
778
|
Rails/RelativeDateConstant:
|
779
|
+
Enabled: false
|
557
780
|
Description: 'Do not assign relative date to constants.'
|
558
|
-
|
781
|
+
SafeAutoCorrect: false
|
559
782
|
VersionAdded: '0.48'
|
560
|
-
VersionChanged: '
|
561
|
-
AutoCorrect: false
|
783
|
+
VersionChanged: '2.13'
|
562
784
|
|
563
785
|
Rails/RenderInline:
|
786
|
+
Enabled: false
|
564
787
|
Description: 'Prefer using a template over inline rendering.'
|
565
788
|
StyleGuide: 'https://rails.rubystyle.guide/#inline-rendering'
|
566
|
-
Enabled: 'pending'
|
567
789
|
VersionAdded: '2.7'
|
568
790
|
|
569
791
|
Rails/RenderPlainText:
|
792
|
+
Enabled: false
|
570
793
|
Description: 'Prefer `render plain:` over `render text:`.'
|
571
794
|
StyleGuide: 'https://rails.rubystyle.guide/#plain-text-rendering'
|
572
|
-
Enabled: 'pending'
|
573
795
|
VersionAdded: '2.7'
|
574
796
|
# Convert only when `content_type` is explicitly set to `text/plain`.
|
575
797
|
ContentTypeCompatibility: true
|
576
798
|
|
577
799
|
Rails/RequestReferer:
|
800
|
+
Enabled: false
|
578
801
|
Description: 'Use consistent syntax for request.referer.'
|
579
|
-
Enabled: true
|
580
802
|
VersionAdded: '0.41'
|
581
803
|
EnforcedStyle: referer
|
582
804
|
SupportedStyles:
|
583
805
|
- referer
|
584
806
|
- referrer
|
585
807
|
|
808
|
+
Rails/RequireDependency:
|
809
|
+
Enabled: false
|
810
|
+
Description: 'Do not use `require_dependency` when running in Zeitwerk mode. `require_dependency` is for autoloading in classic mode.'
|
811
|
+
Reference: 'https://guides.rubyonrails.org/autoloading_and_reloading_constants.html'
|
812
|
+
VersionAdded: '2.10'
|
813
|
+
|
814
|
+
Rails/ResponseParsedBody:
|
815
|
+
Enabled: false
|
816
|
+
Description: Prefer `response.parsed_body` to `JSON.parse(response.body)`.
|
817
|
+
Safe: false
|
818
|
+
VersionAdded: '2.18'
|
819
|
+
VersionChanged: '2.19'
|
820
|
+
Include:
|
821
|
+
- spec/controllers/**/*.rb
|
822
|
+
- spec/requests/**/*.rb
|
823
|
+
- test/controllers/**/*.rb
|
824
|
+
- test/integration/**/*.rb
|
825
|
+
|
586
826
|
Rails/ReversibleMigration:
|
827
|
+
Enabled: false
|
587
828
|
Description: 'Checks whether the change method of the migration file is reversible.'
|
588
829
|
StyleGuide: 'https://rails.rubystyle.guide#reversible-migration'
|
589
830
|
Reference: 'https://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
|
590
|
-
Enabled: true
|
591
831
|
VersionAdded: '0.47'
|
832
|
+
VersionChanged: '2.13'
|
592
833
|
Include:
|
593
|
-
- db
|
834
|
+
- db/**/*.rb
|
835
|
+
|
836
|
+
Rails/ReversibleMigrationMethodDefinition:
|
837
|
+
Enabled: false
|
838
|
+
Description: 'Checks whether the migration implements either a `change` method or both an `up` and a `down` method.'
|
839
|
+
VersionAdded: '2.10'
|
840
|
+
VersionChanged: '2.13'
|
841
|
+
Include:
|
842
|
+
- db/**/*.rb
|
843
|
+
|
844
|
+
Rails/RootJoinChain:
|
845
|
+
Enabled: false
|
846
|
+
Description: 'Use a single `#join` instead of chaining on `Rails.root` or `Rails.public_path`.'
|
847
|
+
VersionAdded: '2.13'
|
848
|
+
|
849
|
+
Rails/RootPathnameMethods:
|
850
|
+
Enabled: false
|
851
|
+
Description: 'Use `Rails.root` IO methods instead of passing it to `File`.'
|
852
|
+
SafeAutoCorrect: false
|
853
|
+
VersionAdded: '2.16'
|
854
|
+
|
855
|
+
Rails/RootPublicPath:
|
856
|
+
Enabled: false
|
857
|
+
Description: "Favor `Rails.public_path` over `Rails.root` with `'public'`."
|
858
|
+
VersionAdded: '2.15'
|
594
859
|
|
595
860
|
Rails/SafeNavigation:
|
596
|
-
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`."
|
597
861
|
Enabled: true
|
862
|
+
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`."
|
598
863
|
VersionAdded: '0.43'
|
599
864
|
# This will convert usages of `try` to use safe navigation as well as `try!`.
|
600
865
|
# `try` and `try!` work slightly differently. `try!` and safe navigation will
|
@@ -603,8 +868,8 @@ Rails/SafeNavigation:
|
|
603
868
|
ConvertTry: false
|
604
869
|
|
605
870
|
Rails/SafeNavigationWithBlank:
|
606
|
-
Description: 'Avoid `foo&.blank?` in conditionals.'
|
607
871
|
Enabled: true
|
872
|
+
Description: 'Avoid `foo&.blank?` in conditionals.'
|
608
873
|
VersionAdded: '2.4'
|
609
874
|
# While the safe navigation operator is generally a good idea, when
|
610
875
|
# checking `foo&.blank?` in a conditional, `foo` being `nil` will actually
|
@@ -615,26 +880,34 @@ Rails/SafeNavigationWithBlank:
|
|
615
880
|
SafeAutoCorrect: false
|
616
881
|
|
617
882
|
Rails/SaveBang:
|
883
|
+
Enabled: false
|
618
884
|
Description: 'Identifies possible cases where Active Record save! or related should be used.'
|
619
885
|
StyleGuide: 'https://rails.rubystyle.guide#save-bang'
|
620
|
-
Enabled: false
|
621
886
|
VersionAdded: '0.42'
|
622
887
|
VersionChanged: '0.59'
|
623
888
|
AllowImplicitReturn: true
|
624
889
|
AllowedReceivers: []
|
625
890
|
SafeAutoCorrect: false
|
626
891
|
|
892
|
+
Rails/SchemaComment:
|
893
|
+
Enabled: false
|
894
|
+
Description: >-
|
895
|
+
Enforces the use of the `comment` option when adding a new table or column
|
896
|
+
to the database during a migration.
|
897
|
+
VersionAdded: '2.13'
|
898
|
+
|
627
899
|
Rails/ScopeArgs:
|
628
|
-
Description: 'Checks the arguments of ActiveRecord scopes.'
|
629
900
|
Enabled: true
|
901
|
+
Description: 'Checks the arguments of ActiveRecord scopes.'
|
630
902
|
VersionAdded: '0.19'
|
903
|
+
VersionChanged: '2.12'
|
631
904
|
Include:
|
632
905
|
- app/models/**/*.rb
|
633
906
|
|
634
907
|
Rails/ShortI18n:
|
908
|
+
Enabled: false
|
635
909
|
Description: 'Use the short form of the I18n methods: `t` instead of `translate` and `l` instead of `localize`.'
|
636
910
|
StyleGuide: 'https://rails.rubystyle.guide/#short-i18n'
|
637
|
-
Enabled: 'pending'
|
638
911
|
VersionAdded: '2.7'
|
639
912
|
EnforcedStyle: conservative
|
640
913
|
SupportedStyles:
|
@@ -642,11 +915,11 @@ Rails/ShortI18n:
|
|
642
915
|
- aggressive
|
643
916
|
|
644
917
|
Rails/SkipsModelValidations:
|
918
|
+
Enabled: false
|
645
919
|
Description: >-
|
646
920
|
Use methods that skips model validations with caution.
|
647
921
|
See reference for more information.
|
648
922
|
Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
|
649
|
-
Enabled: true
|
650
923
|
VersionAdded: '0.47'
|
651
924
|
VersionChanged: '2.7'
|
652
925
|
ForbiddenMethods:
|
@@ -671,88 +944,174 @@ Rails/SkipsModelValidations:
|
|
671
944
|
AllowedMethods: []
|
672
945
|
|
673
946
|
Rails/SquishedSQLHeredocs:
|
947
|
+
Enabled: false
|
674
948
|
Description: 'Checks SQL heredocs to use `.squish`.'
|
675
949
|
StyleGuide: 'https://rails.rubystyle.guide/#squished-heredocs'
|
676
|
-
Enabled: 'pending'
|
677
950
|
VersionAdded: '2.8'
|
678
951
|
VersionChanged: '2.9'
|
679
952
|
# Some SQL syntax (e.g. PostgreSQL comments and functions) requires newlines
|
680
|
-
# to be preserved in order to work, thus
|
953
|
+
# to be preserved in order to work, thus autocorrection is not safe.
|
681
954
|
SafeAutoCorrect: false
|
682
955
|
|
956
|
+
Rails/StripHeredoc:
|
957
|
+
Enabled: true
|
958
|
+
Description: 'Enforces the use of squiggly heredoc over `strip_heredoc`.'
|
959
|
+
StyleGuide: 'https://rails.rubystyle.guide/#prefer-squiggly-heredoc'
|
960
|
+
VersionAdded: '2.15'
|
961
|
+
|
962
|
+
Rails/TableNameAssignment:
|
963
|
+
Enabled: false
|
964
|
+
Description: >-
|
965
|
+
Do not use `self.table_name =`. Use Inflections or `table_name_prefix` instead.
|
966
|
+
StyleGuide: 'https://rails.rubystyle.guide/#keep-ar-defaults'
|
967
|
+
VersionAdded: '2.14'
|
968
|
+
Include:
|
969
|
+
- app/models/**/*.rb
|
970
|
+
|
971
|
+
Rails/ThreeStateBooleanColumn:
|
972
|
+
Enabled: true
|
973
|
+
Description: 'Add a default value and a `NOT NULL` constraint to boolean columns.'
|
974
|
+
StyleGuide: 'https://rails.rubystyle.guide/#three-state-boolean'
|
975
|
+
VersionAdded: '2.19'
|
976
|
+
Include:
|
977
|
+
- db/**/*.rb
|
978
|
+
|
683
979
|
Rails/TimeZone:
|
980
|
+
Enabled: false
|
684
981
|
Description: 'Checks the correct usage of time zone aware methods.'
|
685
982
|
StyleGuide: 'https://rails.rubystyle.guide#time'
|
686
983
|
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
|
687
|
-
|
688
|
-
Safe: false
|
984
|
+
SafeAutoCorrect: false
|
689
985
|
VersionAdded: '0.30'
|
690
|
-
VersionChanged: '
|
986
|
+
VersionChanged: '2.13'
|
691
987
|
# The value `strict` means that `Time` should be used with `zone`.
|
692
988
|
# The value `flexible` allows usage of `in_time_zone` instead of `zone`.
|
693
989
|
EnforcedStyle: flexible
|
694
990
|
SupportedStyles:
|
695
991
|
- strict
|
696
992
|
- flexible
|
993
|
+
Exclude:
|
994
|
+
- '**/*.gemspec'
|
995
|
+
|
996
|
+
Rails/TimeZoneAssignment:
|
997
|
+
Enabled: true
|
998
|
+
Description: 'Prefer the usage of `Time.use_zone` instead of manually updating `Time.zone` value.'
|
999
|
+
Reference: 'https://thoughtbot.com/blog/its-about-time-zones'
|
1000
|
+
VersionAdded: '2.10'
|
1001
|
+
Include:
|
1002
|
+
- spec/**/*.rb
|
1003
|
+
- test/**/*.rb
|
1004
|
+
|
1005
|
+
Rails/ToFormattedS:
|
1006
|
+
Enabled: false
|
1007
|
+
Description: 'Checks for consistent uses of `to_fs` or `to_formatted_s`.'
|
1008
|
+
StyleGuide: 'https://rails.rubystyle.guide/#prefer-to-fs'
|
1009
|
+
EnforcedStyle: to_fs
|
1010
|
+
SupportedStyles:
|
1011
|
+
- to_fs
|
1012
|
+
- to_formatted_s
|
1013
|
+
VersionAdded: '2.15'
|
1014
|
+
|
1015
|
+
Rails/ToSWithArgument:
|
1016
|
+
Enabled: false
|
1017
|
+
Description: 'Identifies passing any argument to `#to_s`.'
|
1018
|
+
Safe: false
|
1019
|
+
VersionAdded: '2.16'
|
1020
|
+
|
1021
|
+
Rails/TopLevelHashWithIndifferentAccess:
|
1022
|
+
Enabled: false
|
1023
|
+
Description: 'Identifies top-level `HashWithIndifferentAccess`.'
|
1024
|
+
Reference: 'https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#top-level-hashwithindifferentaccess-is-soft-deprecated'
|
1025
|
+
Severity: warning
|
1026
|
+
VersionAdded: '2.16'
|
1027
|
+
VersionChanged: '2.18'
|
1028
|
+
|
1029
|
+
Rails/TransactionExitStatement:
|
1030
|
+
Enabled: false
|
1031
|
+
Description: 'Avoid the usage of `return`, `break` and `throw` in transaction blocks.'
|
1032
|
+
Reference:
|
1033
|
+
- https://github.com/rails/rails/commit/15aa4200e083
|
1034
|
+
VersionAdded: '2.14'
|
697
1035
|
|
698
1036
|
Rails/UniqBeforePluck:
|
699
|
-
Description: 'Prefer the use of uniq or distinct before pluck.'
|
700
1037
|
Enabled: true
|
1038
|
+
Description: 'Prefer the use of uniq or distinct before pluck.'
|
701
1039
|
VersionAdded: '0.40'
|
702
|
-
VersionChanged: '2.
|
1040
|
+
VersionChanged: '2.13'
|
703
1041
|
EnforcedStyle: conservative
|
704
1042
|
SupportedStyles:
|
705
1043
|
- conservative
|
706
1044
|
- aggressive
|
707
1045
|
SafeAutoCorrect: false
|
708
|
-
AutoCorrect: false
|
709
1046
|
|
710
1047
|
Rails/UniqueValidationWithoutIndex:
|
711
|
-
|
712
|
-
|
1048
|
+
Enabled: false
|
1049
|
+
Description: 'Uniqueness validation should have a unique index on the database column.'
|
713
1050
|
VersionAdded: '2.5'
|
714
1051
|
Include:
|
715
1052
|
- app/models/**/*.rb
|
716
1053
|
|
717
1054
|
Rails/UnknownEnv:
|
1055
|
+
Enabled: false
|
718
1056
|
Description: 'Use correct environment name.'
|
719
|
-
|
1057
|
+
Severity: warning
|
720
1058
|
VersionAdded: '0.51'
|
1059
|
+
VersionChanged: '2.18'
|
721
1060
|
Environments:
|
722
1061
|
- development
|
723
1062
|
- test
|
724
1063
|
- production
|
725
1064
|
|
1065
|
+
Rails/UnusedIgnoredColumns:
|
1066
|
+
Enabled: true
|
1067
|
+
Description: 'Remove a column that does not exist from `ignored_columns`.'
|
1068
|
+
VersionAdded: '2.11'
|
1069
|
+
Include:
|
1070
|
+
- app/models/**/*.rb
|
1071
|
+
|
726
1072
|
Rails/Validation:
|
1073
|
+
Enabled: false
|
727
1074
|
Description: 'Use validates :attribute, hash of validations.'
|
728
|
-
Enabled: true
|
729
1075
|
VersionAdded: '0.9'
|
730
1076
|
VersionChanged: '0.41'
|
731
1077
|
Include:
|
732
1078
|
- app/models/**/*.rb
|
733
1079
|
|
734
1080
|
Rails/WhereEquals:
|
1081
|
+
Enabled: false
|
735
1082
|
Description: 'Pass conditions to `where` as a hash instead of manually constructing SQL.'
|
736
1083
|
StyleGuide: 'https://rails.rubystyle.guide/#hash-conditions'
|
737
|
-
|
1084
|
+
SafeAutoCorrect: false
|
738
1085
|
VersionAdded: '2.9'
|
1086
|
+
VersionChanged: '2.10'
|
739
1087
|
|
740
1088
|
Rails/WhereExists:
|
1089
|
+
Enabled: false
|
741
1090
|
Description: 'Prefer `exists?(...)` over `where(...).exists?`.'
|
742
|
-
|
1091
|
+
SafeAutoCorrect: false
|
743
1092
|
EnforcedStyle: exists
|
744
1093
|
SupportedStyles:
|
745
1094
|
- exists
|
746
1095
|
- where
|
747
1096
|
VersionAdded: '2.7'
|
748
|
-
VersionChanged: '2.
|
1097
|
+
VersionChanged: '2.10'
|
1098
|
+
|
1099
|
+
Rails/WhereMissing:
|
1100
|
+
Enabled: true
|
1101
|
+
Description: 'Use `where.missing(...)` to find missing relationship records.'
|
1102
|
+
StyleGuide: 'https://rails.rubystyle.guide/#finding-missing-relationship-records'
|
1103
|
+
VersionAdded: '2.16'
|
749
1104
|
|
750
1105
|
Rails/WhereNot:
|
1106
|
+
Enabled: true
|
751
1107
|
Description: 'Use `where.not(...)` instead of manually constructing negated SQL in `where`.'
|
752
1108
|
StyleGuide: 'https://rails.rubystyle.guide/#hash-conditions'
|
753
|
-
Enabled: 'pending'
|
754
1109
|
VersionAdded: '2.8'
|
755
1110
|
|
756
|
-
|
757
|
-
|
758
|
-
|
1111
|
+
Rails/WhereNotWithMultipleConditions:
|
1112
|
+
Enabled: false
|
1113
|
+
Description: 'Do not use `where.not(...)` with multiple conditions.'
|
1114
|
+
StyleGuide: 'https://rails.rubystyle.guide/#where-not-with-multiple-attributes'
|
1115
|
+
Severity: warning
|
1116
|
+
VersionAdded: '2.17'
|
1117
|
+
VersionChanged: '2.18'
|