/
default.yml
477 lines (423 loc) · 13.2 KB
/
default.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# Common configuration.
AllCops:
# What version of Rails is the inspected code using? If a value is specified
# for TargetRailsVersion then it is used. Acceptable values are specificed
# as a float (i.e. 5.1); the patch version of Rails should not be included.
# If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or
# gems.locked file to find the version of Rails that has been bound to the
# application. If neither of those files exist, RuboCop will use Rails 5.0
# as the default.
TargetRailsVersion: ~
# When specifying style guide URLs, any paths and/or fragments will be
# evaluated relative to the base URL.
StyleGuideBaseURL: https://rails.rubystyle.guide
Rails/ActionFilter:
Description: 'Enforces consistent use of action filter methods.'
Enabled: true
VersionAdded: '0.19'
EnforcedStyle: action
SupportedStyles:
- action
- filter
Include:
- app/controllers/**/*.rb
Rails/ActiveRecordAliases:
Description: >-
Avoid Active Record aliases:
Use `update` instead of `update_attributes`.
Use `update!` instead of `update_attributes!`.
Enabled: true
VersionAdded: '0.53'
Rails/ActiveRecordOverride:
Description: >-
Check for overriding Active Record methods instead of using
callbacks.
Enabled: true
VersionAdded: '0.67'
Include:
- app/models/**/*.rb
Rails/ActiveSupportAliases:
Description: >-
Avoid ActiveSupport aliases of standard ruby methods:
`String#starts_with?`, `String#ends_with?`,
`Array#append`, `Array#prepend`.
Enabled: true
VersionAdded: '0.48'
Rails/ApplicationJob:
Description: 'Check that jobs subclass ApplicationJob.'
Enabled: true
VersionAdded: '0.49'
Rails/ApplicationRecord:
Description: 'Check that models subclass ApplicationRecord.'
Enabled: true
VersionAdded: '0.49'
Rails/AssertNot:
Description: 'Use `assert_not` instead of `assert !`.'
Enabled: true
VersionAdded: '0.56'
Include:
- '**/test/**/*'
Rails/BelongsTo:
Description: >-
Use `optional: true` instead of `required: false` for
`belongs_to` relations'
Enabled: true
VersionAdded: '0.62'
Rails/Blank:
Description: 'Enforces use of `blank?`.'
Enabled: true
VersionAdded: '0.48'
VersionChanged: '0.67'
# Convert usages of `nil? || empty?` to `blank?`
NilOrEmpty: true
# Convert usages of `!present?` to `blank?`
NotPresent: true
# Convert usages of `unless present?` to `if blank?`
UnlessPresent: true
Rails/BulkChangeTable:
Description: 'Check whether alter queries are combinable.'
Enabled: true
VersionAdded: '0.57'
Database: null
SupportedDatabases:
- mysql
- postgresql
Include:
- db/migrate/*.rb
Rails/CreateTableWithTimestamps:
Description: >-
Checks the migration for which timestamps are not included
when creating a new table.
Enabled: true
VersionAdded: '0.52'
Include:
- db/migrate/*.rb
Rails/Date:
Description: >-
Checks the correct usage of date aware methods,
such as Date.today, Date.current etc.
Enabled: true
VersionAdded: '0.30'
VersionChanged: '0.33'
# The value `strict` disallows usage of `Date.today`, `Date.current`,
# `Date#to_time` etc.
# The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
# (but not `Date.today`) which are overridden by ActiveSupport to handle current
# time zone.
EnforcedStyle: flexible
SupportedStyles:
- strict
- flexible
Rails/Delegate:
Description: 'Prefer delegate method for delegations.'
Enabled: true
VersionAdded: '0.21'
VersionChanged: '0.50'
# When set to true, using the target object as a prefix of the
# method name without using the `delegate` method will be a
# violation. When set to false, this case is legal.
EnforceForPrefixed: true
Rails/DelegateAllowBlank:
Description: 'Do not use allow_blank as an option to delegate.'
Enabled: true
VersionAdded: '0.44'
Rails/DynamicFindBy:
Description: 'Use `find_by` instead of dynamic `find_by_*`.'
StyleGuide: '#find_by'
Enabled: true
VersionAdded: '0.44'
Whitelist:
- find_by_sql
Rails/EnumHash:
Description: 'Prefer hash syntax over array syntax when defining enums.'
StyleGuide: '#enums'
Enabled: true
VersionAdded: '2.3'
Include:
- app/models/**/*.rb
Rails/EnumUniqueness:
Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
Enabled: true
VersionAdded: '0.46'
Include:
- app/models/**/*.rb
Rails/EnvironmentComparison:
Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`"
Enabled: true
VersionAdded: '0.52'
Rails/Exit:
Description: >-
Favor `fail`, `break`, `return`, etc. over `exit` in
application or library code outside of Rake files to avoid
exits during unit testing or running in production.
Enabled: true
VersionAdded: '0.41'
Include:
- app/**/*.rb
- config/**/*.rb
- lib/**/*.rb
Exclude:
- lib/**/*.rake
Rails/FilePath:
Description: 'Use `Rails.root.join` for file path joining.'
Enabled: true
VersionAdded: '0.47'
VersionChanged: '0.57'
EnforcedStyle: arguments
SupportedStyles:
- slashes
- arguments
Rails/FindBy:
Description: 'Prefer find_by over where.first.'
StyleGuide: '#find_by'
Enabled: true
VersionAdded: '0.30'
Include:
- app/models/**/*.rb
Rails/FindEach:
Description: 'Prefer all.find_each over all.find.'
StyleGuide: '#find-each'
Enabled: true
VersionAdded: '0.30'
Include:
- app/models/**/*.rb
Rails/HasAndBelongsToMany:
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
StyleGuide: '#has-many-through'
Enabled: true
VersionAdded: '0.12'
Include:
- app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
Description: 'Define the dependent option to the has_many and has_one associations.'
StyleGuide: '#has_many-has_one-dependent-option'
Enabled: true
VersionAdded: '0.50'
Include:
- app/models/**/*.rb
Rails/HelperInstanceVariable:
Description: 'Do not use instance variables in helpers'
Enabled: true
VersionAdded: '2.0'
Include:
- app/helpers/**/*.rb
Rails/HttpPositionalArguments:
Description: 'Use keyword arguments instead of positional arguments in http method calls.'
Enabled: true
VersionAdded: '0.44'
Include:
- 'spec/**/*'
- 'test/**/*'
Rails/HttpStatus:
Description: 'Enforces use of symbolic or numeric value to define HTTP status.'
Enabled: true
VersionAdded: '0.54'
EnforcedStyle: symbolic
SupportedStyles:
- numeric
- symbolic
Rails/IgnoredSkipActionFilterOption:
Description: 'Checks that `if` and `only` (or `except`) are not used together as options of `skip_*` action filter.'
Reference: 'https://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#method-i-_normalize_callback_options'
Enabled: true
VersionAdded: '0.63'
Include:
- app/controllers/**/*.rb
Rails/InverseOf:
Description: 'Checks for associations where the inverse cannot be determined automatically.'
Enabled: true
VersionAdded: '0.52'
Include:
- app/models/**/*.rb
Rails/LexicallyScopedActionFilter:
Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller."
StyleGuide: '#lexically-scoped-action-filter'
Enabled: true
Safe: false
VersionAdded: '0.52'
Include:
- app/controllers/**/*.rb
Rails/LinkToBlank:
Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
Reference:
- https://mathiasbynens.github.io/rel-noopener/
- https://html.spec.whatwg.org/multipage/links.html#link-type-noopener
- https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer
Enabled: true
VersionAdded: '0.62'
Rails/NotNullColumn:
Description: 'Do not add a NOT NULL column without a default value'
Enabled: true
VersionAdded: '0.43'
Include:
- db/migrate/*.rb
Rails/Output:
Description: 'Checks for calls to puts, print, etc.'
Enabled: true
VersionAdded: '0.15'
VersionChanged: '0.19'
Include:
- app/**/*.rb
- config/**/*.rb
- db/**/*.rb
- lib/**/*.rb
Rails/OutputSafety:
Description: 'The use of `html_safe` or `raw` may be a security risk.'
Enabled: true
VersionAdded: '0.41'
Rails/PluralizationGrammar:
Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
Enabled: true
VersionAdded: '0.35'
Rails/Presence:
Description: 'Checks code that can be written more easily using `Object#presence` defined by Active Support.'
Enabled: true
VersionAdded: '0.52'
Rails/Present:
Description: 'Enforces use of `present?`.'
Enabled: true
VersionAdded: '0.48'
VersionChanged: '0.67'
# Convert usages of `!nil? && !empty?` to `present?`
NotNilAndNotEmpty: true
# Convert usages of `!blank?` to `present?`
NotBlank: true
# Convert usages of `unless blank?` to `if present?`
UnlessBlank: true
Rails/ReadWriteAttribute:
Description: >-
Checks for read_attribute(:attr) and
write_attribute(:attr, val).
StyleGuide: '#read-attribute'
Enabled: true
VersionAdded: '0.20'
VersionChanged: '0.29'
Include:
- app/models/**/*.rb
Rails/RedundantAllowNil:
Description: >-
Finds redundant use of `allow_nil` when `allow_blank` is set to
certain values in model validations.
Enabled: true
VersionAdded: '0.67'
Include:
- app/models/**/*.rb
Rails/RedundantReceiverInWithOptions:
Description: 'Checks for redundant receiver in `with_options`.'
Enabled: true
VersionAdded: '0.52'
Rails/ReflectionClassName:
Description: 'Use a string for `class_name` option value in the definition of a reflection.'
Enabled: true
VersionAdded: '0.64'
Rails/RefuteMethods:
Description: 'Use `assert_not` methods instead of `refute` methods.'
Enabled: true
VersionAdded: '0.56'
Include:
- '**/test/**/*'
Rails/RelativeDateConstant:
Description: 'Do not assign relative date to constants.'
Enabled: true
VersionAdded: '0.48'
VersionChanged: '0.59'
AutoCorrect: false
Rails/RequestReferer:
Description: 'Use consistent syntax for request.referer.'
Enabled: true
VersionAdded: '0.41'
EnforcedStyle: referer
SupportedStyles:
- referer
- referrer
Rails/ReversibleMigration:
Description: 'Checks whether the change method of the migration file is reversible.'
StyleGuide: '#reversible-migration'
Reference: 'https://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
Enabled: true
VersionAdded: '0.47'
Include:
- db/migrate/*.rb
Rails/SafeNavigation:
Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
Enabled: true
VersionAdded: '0.43'
# This will convert usages of `try` to use safe navigation as well as `try!`.
# `try` and `try!` work slightly differently. `try!` and safe navigation will
# both raise a `NoMethodError` if the receiver of the method call does not
# implement the intended method. `try` will not raise an exception for this.
ConvertTry: false
Rails/SaveBang:
Description: 'Identifies possible cases where Active Record save! or related should be used.'
StyleGuide: '#save-bang'
Enabled: false
VersionAdded: '0.42'
VersionChanged: '0.59'
AllowImplicitReturn: true
AllowedReceivers: []
Rails/ScopeArgs:
Description: 'Checks the arguments of ActiveRecord scopes.'
Enabled: true
VersionAdded: '0.19'
Include:
- app/models/**/*.rb
Rails/SkipsModelValidations:
Description: >-
Use methods that skips model validations with caution.
See reference for more information.
Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
Enabled: true
VersionAdded: '0.47'
VersionChanged: '0.60'
Blacklist:
- decrement!
- decrement_counter
- increment!
- increment_counter
- toggle!
- touch
- update_all
- update_attribute
- update_column
- update_columns
- update_counters
Whitelist: []
Rails/TimeZone:
Description: 'Checks the correct usage of time zone aware methods.'
StyleGuide: '#time'
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
Enabled: true
Safe: false
VersionAdded: '0.30'
VersionChanged: '0.68'
# The value `strict` means that `Time` should be used with `zone`.
# The value `flexible` allows usage of `in_time_zone` instead of `zone`.
EnforcedStyle: flexible
SupportedStyles:
- strict
- flexible
Rails/UniqBeforePluck:
Description: 'Prefer the use of uniq or distinct before pluck.'
Enabled: true
VersionAdded: '0.40'
VersionChanged: '0.47'
EnforcedStyle: conservative
SupportedStyles:
- conservative
- aggressive
AutoCorrect: false
Rails/UnknownEnv:
Description: 'Use correct environment name.'
Enabled: true
VersionAdded: '0.51'
Environments:
- development
- test
- production
Rails/Validation:
Description: 'Use validates :attribute, hash of validations.'
Enabled: true
VersionAdded: '0.9'
VersionChanged: '0.41'
Include:
- app/models/**/*.rb