rubocop-rails 2.4.1

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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.md +92 -0
  4. data/bin/setup +7 -0
  5. data/config/default.yml +510 -0
  6. data/lib/rubocop-rails.rb +12 -0
  7. data/lib/rubocop/cop/mixin/target_rails_version.rb +16 -0
  8. data/lib/rubocop/cop/rails/action_filter.rb +111 -0
  9. data/lib/rubocop/cop/rails/active_record_aliases.rb +48 -0
  10. data/lib/rubocop/cop/rails/active_record_override.rb +82 -0
  11. data/lib/rubocop/cop/rails/active_support_aliases.rb +69 -0
  12. data/lib/rubocop/cop/rails/application_controller.rb +36 -0
  13. data/lib/rubocop/cop/rails/application_job.rb +40 -0
  14. data/lib/rubocop/cop/rails/application_mailer.rb +40 -0
  15. data/lib/rubocop/cop/rails/application_record.rb +40 -0
  16. data/lib/rubocop/cop/rails/assert_not.rb +44 -0
  17. data/lib/rubocop/cop/rails/belongs_to.rb +102 -0
  18. data/lib/rubocop/cop/rails/blank.rb +164 -0
  19. data/lib/rubocop/cop/rails/bulk_change_table.rb +293 -0
  20. data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +91 -0
  21. data/lib/rubocop/cop/rails/date.rb +161 -0
  22. data/lib/rubocop/cop/rails/delegate.rb +132 -0
  23. data/lib/rubocop/cop/rails/delegate_allow_blank.rb +37 -0
  24. data/lib/rubocop/cop/rails/dynamic_find_by.rb +91 -0
  25. data/lib/rubocop/cop/rails/enum_hash.rb +75 -0
  26. data/lib/rubocop/cop/rails/enum_uniqueness.rb +65 -0
  27. data/lib/rubocop/cop/rails/environment_comparison.rb +68 -0
  28. data/lib/rubocop/cop/rails/exit.rb +67 -0
  29. data/lib/rubocop/cop/rails/file_path.rb +108 -0
  30. data/lib/rubocop/cop/rails/find_by.rb +55 -0
  31. data/lib/rubocop/cop/rails/find_each.rb +51 -0
  32. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +25 -0
  33. data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +106 -0
  34. data/lib/rubocop/cop/rails/helper_instance_variable.rb +39 -0
  35. data/lib/rubocop/cop/rails/http_positional_arguments.rb +117 -0
  36. data/lib/rubocop/cop/rails/http_status.rb +160 -0
  37. data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +94 -0
  38. data/lib/rubocop/cop/rails/inverse_of.rb +246 -0
  39. data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +175 -0
  40. data/lib/rubocop/cop/rails/link_to_blank.rb +98 -0
  41. data/lib/rubocop/cop/rails/not_null_column.rb +67 -0
  42. data/lib/rubocop/cop/rails/output.rb +49 -0
  43. data/lib/rubocop/cop/rails/output_safety.rb +99 -0
  44. data/lib/rubocop/cop/rails/pluralization_grammar.rb +107 -0
  45. data/lib/rubocop/cop/rails/presence.rb +148 -0
  46. data/lib/rubocop/cop/rails/present.rb +153 -0
  47. data/lib/rubocop/cop/rails/rake_environment.rb +91 -0
  48. data/lib/rubocop/cop/rails/read_write_attribute.rb +74 -0
  49. data/lib/rubocop/cop/rails/redundant_allow_nil.rb +111 -0
  50. data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +136 -0
  51. data/lib/rubocop/cop/rails/reflection_class_name.rb +37 -0
  52. data/lib/rubocop/cop/rails/refute_methods.rb +76 -0
  53. data/lib/rubocop/cop/rails/relative_date_constant.rb +102 -0
  54. data/lib/rubocop/cop/rails/request_referer.rb +56 -0
  55. data/lib/rubocop/cop/rails/reversible_migration.rb +284 -0
  56. data/lib/rubocop/cop/rails/safe_navigation.rb +85 -0
  57. data/lib/rubocop/cop/rails/safe_navigation_with_blank.rb +48 -0
  58. data/lib/rubocop/cop/rails/save_bang.rb +331 -0
  59. data/lib/rubocop/cop/rails/scope_args.rb +29 -0
  60. data/lib/rubocop/cop/rails/skips_model_validations.rb +87 -0
  61. data/lib/rubocop/cop/rails/time_zone.rb +249 -0
  62. data/lib/rubocop/cop/rails/uniq_before_pluck.rb +105 -0
  63. data/lib/rubocop/cop/rails/unknown_env.rb +84 -0
  64. data/lib/rubocop/cop/rails/validation.rb +147 -0
  65. data/lib/rubocop/cop/rails_cops.rb +61 -0
  66. data/lib/rubocop/rails.rb +12 -0
  67. data/lib/rubocop/rails/inject.rb +18 -0
  68. data/lib/rubocop/rails/version.rb +10 -0
  69. metadata +148 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c9d8cbc9fa9fc0752a334a92dd7af50f2a33331ac1b9604dc7c1f27efbc141e6
4
+ data.tar.gz: 81833c9b0dbc71254f75f18eb59a13147025efdff95342c3ba1855e773301fc2
5
+ SHA512:
6
+ metadata.gz: a5ffc7a5e763076a13e5addebf2b4321ebfddbbb19e752bfe9697003eb4451e5d5eebc4ced8c2f3f55e1e10f24a81670e14b7ec48ee748d1c15996085618b5c8
7
+ data.tar.gz: 0e8b3557bfa819b2fb1304f992a48845afbb52db0c8c7beb970bbcc09c4345c5f9d2f9f273efb2692374f3a03c28c6d615824af20ca669c40359299dca53f41a
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012-18 Bozhidar Batsov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,92 @@
1
+ # RuboCop Rails
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/rubocop-rails.svg)](https://badge.fury.io/rb/rubocop-rails)
4
+ [![CircleCI](https://circleci.com/gh/rubocop-hq/rubocop-rails.svg?style=svg)](https://circleci.com/gh/rubocop-hq/rubocop-rails)
5
+
6
+ A [RuboCop](https://github.com/rubocop-hq/rubocop) extension focused on enforcing Rails best practices and coding conventions.
7
+
8
+ Note: This repository manages rubocop-rails gem (>= 2.0.0). rubocop-rails gem (<= 1.5.0) has been renamed to [rubocop-rails_config](https://rubygems.org/gems/rubocop-rails_config) gem.
9
+
10
+ ## Installation
11
+
12
+ Just install the `rubocop-rails` gem
13
+
14
+ ```sh
15
+ gem install rubocop-rails
16
+ ```
17
+
18
+ or if you use bundler put this in your `Gemfile`
19
+
20
+ ```ruby
21
+ gem 'rubocop-rails'
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ You need to tell RuboCop to load the Rails extension. There are three
27
+ ways to do this:
28
+
29
+ ### RuboCop configuration file
30
+
31
+ Put this into your `.rubocop.yml`.
32
+
33
+ ```yaml
34
+ require: rubocop-rails
35
+ ```
36
+
37
+ Alternatively, use the following array notation when specifying multiple extensions.
38
+
39
+ ```yaml
40
+ require:
41
+ - rubocop-other-extension
42
+ - rubocop-rails
43
+ ```
44
+
45
+ Now you can run `rubocop` and it will automatically load the RuboCop Rails
46
+ cops together with the standard cops.
47
+
48
+ ### Command line
49
+
50
+ ```sh
51
+ rubocop --require rubocop-rails
52
+ ```
53
+
54
+ Note: `--rails` option is required while `rubocop` command supports `--rails` option.
55
+
56
+ ### Rake task
57
+
58
+ ```ruby
59
+ RuboCop::RakeTask.new do |task|
60
+ task.requires << 'rubocop-rails'
61
+ end
62
+ ```
63
+
64
+ ## The Cops
65
+
66
+ All cops are located under
67
+ [`lib/rubocop/cop/rails`](lib/rubocop/cop/rails), and contain
68
+ examples/documentation.
69
+
70
+ In your `.rubocop.yml`, you may treat the Rails cops just like any other
71
+ cop. For example:
72
+
73
+ ```yaml
74
+ Rails/FindBy:
75
+ Exclude:
76
+ - lib/example.rb
77
+ ```
78
+
79
+ ## Compatibility
80
+
81
+ Rails cops support the following versions:
82
+
83
+ - Rails 4.0+
84
+
85
+ ## Contributing
86
+
87
+ Checkout the [contribution guidelines](CONTRIBUTING.md).
88
+
89
+ ## License
90
+
91
+ `rubocop-rails` is MIT licensed. [See the accompanying file](LICENSE.txt) for
92
+ the full text.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+ IFS=$'\n\t'
5
+ set -vx
6
+
7
+ bundle install
@@ -0,0 +1,510 @@
1
+ # Common configuration.
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - bin/*
6
+ - db/schema.rb
7
+ # What version of Rails is the inspected code using? If a value is specified
8
+ # for TargetRailsVersion then it is used. Acceptable values are specificed
9
+ # as a float (i.e. 5.1); the patch version of Rails should not be included.
10
+ # If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or
11
+ # gems.locked file to find the version of Rails that has been bound to the
12
+ # application. If neither of those files exist, RuboCop will use Rails 5.0
13
+ # as the default.
14
+ TargetRailsVersion: ~
15
+
16
+ Rails/ActionFilter:
17
+ Description: 'Enforces consistent use of action filter methods.'
18
+ Enabled: true
19
+ VersionAdded: '0.19'
20
+ EnforcedStyle: action
21
+ SupportedStyles:
22
+ - action
23
+ - filter
24
+ Include:
25
+ - app/controllers/**/*.rb
26
+
27
+ Rails/ActiveRecordAliases:
28
+ Description: >-
29
+ Avoid Active Record aliases:
30
+ Use `update` instead of `update_attributes`.
31
+ Use `update!` instead of `update_attributes!`.
32
+ Enabled: true
33
+ VersionAdded: '0.53'
34
+ SafeAutoCorrect: false
35
+
36
+ Rails/ActiveRecordOverride:
37
+ Description: >-
38
+ Check for overriding Active Record methods instead of using
39
+ callbacks.
40
+ Enabled: true
41
+ VersionAdded: '0.67'
42
+ Include:
43
+ - app/models/**/*.rb
44
+
45
+ Rails/ActiveSupportAliases:
46
+ Description: >-
47
+ Avoid ActiveSupport aliases of standard ruby methods:
48
+ `String#starts_with?`, `String#ends_with?`,
49
+ `Array#append`, `Array#prepend`.
50
+ Enabled: true
51
+ VersionAdded: '0.48'
52
+
53
+ Rails/ApplicationController:
54
+ Description: 'Check that controllers subclass ApplicationController.'
55
+ Enabled: true
56
+ VersionAdded: '2.4'
57
+
58
+ Rails/ApplicationJob:
59
+ Description: 'Check that jobs subclass ApplicationJob.'
60
+ Enabled: true
61
+ VersionAdded: '0.49'
62
+
63
+ Rails/ApplicationMailer:
64
+ Description: 'Check that mailers subclass ApplicationMailer.'
65
+ Enabled: true
66
+ VersionAdded: '2.4'
67
+
68
+ Rails/ApplicationRecord:
69
+ Description: 'Check that models subclass ApplicationRecord.'
70
+ Enabled: true
71
+ VersionAdded: '0.49'
72
+
73
+ Rails/AssertNot:
74
+ Description: 'Use `assert_not` instead of `assert !`.'
75
+ Enabled: true
76
+ VersionAdded: '0.56'
77
+ Include:
78
+ - '**/test/**/*'
79
+
80
+ Rails/BelongsTo:
81
+ Description: >-
82
+ Use `optional: true` instead of `required: false` for
83
+ `belongs_to` relations'
84
+ Enabled: true
85
+ VersionAdded: '0.62'
86
+
87
+ Rails/Blank:
88
+ Description: 'Enforces use of `blank?`.'
89
+ Enabled: true
90
+ VersionAdded: '0.48'
91
+ VersionChanged: '0.67'
92
+ # Convert usages of `nil? || empty?` to `blank?`
93
+ NilOrEmpty: true
94
+ # Convert usages of `!present?` to `blank?`
95
+ NotPresent: true
96
+ # Convert usages of `unless present?` to `if blank?`
97
+ UnlessPresent: true
98
+
99
+ Rails/BulkChangeTable:
100
+ Description: 'Check whether alter queries are combinable.'
101
+ Enabled: true
102
+ VersionAdded: '0.57'
103
+ Database: null
104
+ SupportedDatabases:
105
+ - mysql
106
+ - postgresql
107
+ Include:
108
+ - db/migrate/*.rb
109
+
110
+ Rails/CreateTableWithTimestamps:
111
+ Description: >-
112
+ Checks the migration for which timestamps are not included
113
+ when creating a new table.
114
+ Enabled: true
115
+ VersionAdded: '0.52'
116
+ Include:
117
+ - db/migrate/*.rb
118
+
119
+ Rails/Date:
120
+ Description: >-
121
+ Checks the correct usage of date aware methods,
122
+ such as Date.today, Date.current etc.
123
+ Enabled: true
124
+ VersionAdded: '0.30'
125
+ VersionChanged: '0.33'
126
+ # The value `strict` disallows usage of `Date.today`, `Date.current`,
127
+ # `Date#to_time` etc.
128
+ # The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
129
+ # (but not `Date.today`) which are overridden by ActiveSupport to handle current
130
+ # time zone.
131
+ EnforcedStyle: flexible
132
+ SupportedStyles:
133
+ - strict
134
+ - flexible
135
+
136
+ Rails/Delegate:
137
+ Description: 'Prefer delegate method for delegations.'
138
+ Enabled: true
139
+ VersionAdded: '0.21'
140
+ VersionChanged: '0.50'
141
+ # When set to true, using the target object as a prefix of the
142
+ # method name without using the `delegate` method will be a
143
+ # violation. When set to false, this case is legal.
144
+ EnforceForPrefixed: true
145
+
146
+ Rails/DelegateAllowBlank:
147
+ Description: 'Do not use allow_blank as an option to delegate.'
148
+ Enabled: true
149
+ VersionAdded: '0.44'
150
+
151
+ Rails/DynamicFindBy:
152
+ Description: 'Use `find_by` instead of dynamic `find_by_*`.'
153
+ StyleGuide: 'https://rails.rubystyle.guide#find_by'
154
+ Enabled: true
155
+ VersionAdded: '0.44'
156
+ Whitelist:
157
+ - find_by_sql
158
+
159
+ Rails/EnumHash:
160
+ Description: 'Prefer hash syntax over array syntax when defining enums.'
161
+ StyleGuide: 'https://rails.rubystyle.guide#enums'
162
+ Enabled: true
163
+ VersionAdded: '2.3'
164
+ Include:
165
+ - app/models/**/*.rb
166
+
167
+ Rails/EnumUniqueness:
168
+ Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
169
+ Enabled: true
170
+ VersionAdded: '0.46'
171
+ Include:
172
+ - app/models/**/*.rb
173
+
174
+ Rails/EnvironmentComparison:
175
+ Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`"
176
+ Enabled: true
177
+ VersionAdded: '0.52'
178
+
179
+ Rails/Exit:
180
+ Description: >-
181
+ Favor `fail`, `break`, `return`, etc. over `exit` in
182
+ application or library code outside of Rake files to avoid
183
+ exits during unit testing or running in production.
184
+ Enabled: true
185
+ VersionAdded: '0.41'
186
+ Include:
187
+ - app/**/*.rb
188
+ - config/**/*.rb
189
+ - lib/**/*.rb
190
+ Exclude:
191
+ - lib/**/*.rake
192
+
193
+ Rails/FilePath:
194
+ Description: 'Use `Rails.root.join` for file path joining.'
195
+ Enabled: true
196
+ VersionAdded: '0.47'
197
+ VersionChanged: '2.4'
198
+ EnforcedStyle: slashes
199
+ SupportedStyles:
200
+ - slashes
201
+ - arguments
202
+
203
+ Rails/FindBy:
204
+ Description: 'Prefer find_by over where.first.'
205
+ StyleGuide: 'https://rails.rubystyle.guide#find_by'
206
+ Enabled: true
207
+ VersionAdded: '0.30'
208
+ Include:
209
+ - app/models/**/*.rb
210
+
211
+ Rails/FindEach:
212
+ Description: 'Prefer all.find_each over all.find.'
213
+ StyleGuide: 'https://rails.rubystyle.guide#find-each'
214
+ Enabled: true
215
+ VersionAdded: '0.30'
216
+ Include:
217
+ - app/models/**/*.rb
218
+
219
+ Rails/HasAndBelongsToMany:
220
+ Description: 'Prefer has_many :through to has_and_belongs_to_many.'
221
+ StyleGuide: 'https://rails.rubystyle.guide#has-many-through'
222
+ Enabled: true
223
+ VersionAdded: '0.12'
224
+ Include:
225
+ - app/models/**/*.rb
226
+
227
+ Rails/HasManyOrHasOneDependent:
228
+ Description: 'Define the dependent option to the has_many and has_one associations.'
229
+ StyleGuide: 'https://rails.rubystyle.guide#has_many-has_one-dependent-option'
230
+ Enabled: true
231
+ VersionAdded: '0.50'
232
+ Include:
233
+ - app/models/**/*.rb
234
+
235
+ Rails/HelperInstanceVariable:
236
+ Description: 'Do not use instance variables in helpers'
237
+ Enabled: true
238
+ VersionAdded: '2.0'
239
+ Include:
240
+ - app/helpers/**/*.rb
241
+
242
+ Rails/HttpPositionalArguments:
243
+ Description: 'Use keyword arguments instead of positional arguments in http method calls.'
244
+ Enabled: true
245
+ VersionAdded: '0.44'
246
+ Include:
247
+ - 'spec/**/*'
248
+ - 'test/**/*'
249
+
250
+ Rails/HttpStatus:
251
+ Description: 'Enforces use of symbolic or numeric value to define HTTP status.'
252
+ Enabled: true
253
+ VersionAdded: '0.54'
254
+ EnforcedStyle: symbolic
255
+ SupportedStyles:
256
+ - numeric
257
+ - symbolic
258
+
259
+ Rails/IgnoredSkipActionFilterOption:
260
+ Description: 'Checks that `if` and `only` (or `except`) are not used together as options of `skip_*` action filter.'
261
+ Reference: 'https://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#method-i-_normalize_callback_options'
262
+ Enabled: true
263
+ VersionAdded: '0.63'
264
+ Include:
265
+ - app/controllers/**/*.rb
266
+
267
+ Rails/InverseOf:
268
+ Description: 'Checks for associations where the inverse cannot be determined automatically.'
269
+ Enabled: true
270
+ VersionAdded: '0.52'
271
+ Include:
272
+ - app/models/**/*.rb
273
+
274
+ Rails/LexicallyScopedActionFilter:
275
+ Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller."
276
+ StyleGuide: 'https://rails.rubystyle.guide#lexically-scoped-action-filter'
277
+ Enabled: true
278
+ Safe: false
279
+ VersionAdded: '0.52'
280
+ Include:
281
+ - app/controllers/**/*.rb
282
+
283
+ Rails/LinkToBlank:
284
+ Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
285
+ Reference:
286
+ - https://mathiasbynens.github.io/rel-noopener/
287
+ - https://html.spec.whatwg.org/multipage/links.html#link-type-noopener
288
+ - https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer
289
+ Enabled: true
290
+ VersionAdded: '0.62'
291
+
292
+ Rails/NotNullColumn:
293
+ Description: 'Do not add a NOT NULL column without a default value'
294
+ Enabled: true
295
+ VersionAdded: '0.43'
296
+ Include:
297
+ - db/migrate/*.rb
298
+
299
+ Rails/Output:
300
+ Description: 'Checks for calls to puts, print, etc.'
301
+ Enabled: true
302
+ VersionAdded: '0.15'
303
+ VersionChanged: '0.19'
304
+ Include:
305
+ - app/**/*.rb
306
+ - config/**/*.rb
307
+ - db/**/*.rb
308
+ - lib/**/*.rb
309
+
310
+ Rails/OutputSafety:
311
+ Description: 'The use of `html_safe` or `raw` may be a security risk.'
312
+ Enabled: true
313
+ VersionAdded: '0.41'
314
+
315
+ Rails/PluralizationGrammar:
316
+ Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
317
+ Enabled: true
318
+ VersionAdded: '0.35'
319
+
320
+ Rails/Presence:
321
+ Description: 'Checks code that can be written more easily using `Object#presence` defined by Active Support.'
322
+ Enabled: true
323
+ VersionAdded: '0.52'
324
+
325
+ Rails/Present:
326
+ Description: 'Enforces use of `present?`.'
327
+ Enabled: true
328
+ VersionAdded: '0.48'
329
+ VersionChanged: '0.67'
330
+ # Convert usages of `!nil? && !empty?` to `present?`
331
+ NotNilAndNotEmpty: true
332
+ # Convert usages of `!blank?` to `present?`
333
+ NotBlank: true
334
+ # Convert usages of `unless blank?` to `if present?`
335
+ UnlessBlank: true
336
+
337
+ Rails/RakeEnvironment:
338
+ Description: 'Include `:environment` as a dependency for all Rake tasks.'
339
+ Enabled: true
340
+ Safe: false
341
+ VersionAdded: '2.4'
342
+ Include:
343
+ - '**/Rakefile'
344
+ - '**/*.rake'
345
+
346
+ Rails/ReadWriteAttribute:
347
+ Description: >-
348
+ Checks for read_attribute(:attr) and
349
+ write_attribute(:attr, val).
350
+ StyleGuide: 'https://rails.rubystyle.guide#read-attribute'
351
+ Enabled: true
352
+ VersionAdded: '0.20'
353
+ VersionChanged: '0.29'
354
+ Include:
355
+ - app/models/**/*.rb
356
+
357
+ Rails/RedundantAllowNil:
358
+ Description: >-
359
+ Finds redundant use of `allow_nil` when `allow_blank` is set to
360
+ certain values in model validations.
361
+ Enabled: true
362
+ VersionAdded: '0.67'
363
+ Include:
364
+ - app/models/**/*.rb
365
+
366
+ Rails/RedundantReceiverInWithOptions:
367
+ Description: 'Checks for redundant receiver in `with_options`.'
368
+ Enabled: true
369
+ VersionAdded: '0.52'
370
+
371
+ Rails/ReflectionClassName:
372
+ Description: 'Use a string for `class_name` option value in the definition of a reflection.'
373
+ Enabled: true
374
+ VersionAdded: '0.64'
375
+
376
+ Rails/RefuteMethods:
377
+ Description: 'Use `assert_not` methods instead of `refute` methods.'
378
+ Enabled: true
379
+ VersionAdded: '0.56'
380
+ Include:
381
+ - '**/test/**/*'
382
+
383
+ Rails/RelativeDateConstant:
384
+ Description: 'Do not assign relative date to constants.'
385
+ Enabled: true
386
+ VersionAdded: '0.48'
387
+ VersionChanged: '0.59'
388
+ AutoCorrect: false
389
+
390
+ Rails/RequestReferer:
391
+ Description: 'Use consistent syntax for request.referer.'
392
+ Enabled: true
393
+ VersionAdded: '0.41'
394
+ EnforcedStyle: referer
395
+ SupportedStyles:
396
+ - referer
397
+ - referrer
398
+
399
+ Rails/ReversibleMigration:
400
+ Description: 'Checks whether the change method of the migration file is reversible.'
401
+ StyleGuide: 'https://rails.rubystyle.guide#reversible-migration'
402
+ Reference: 'https://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
403
+ Enabled: true
404
+ VersionAdded: '0.47'
405
+ Include:
406
+ - db/migrate/*.rb
407
+
408
+ Rails/SafeNavigation:
409
+ Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
410
+ Enabled: true
411
+ VersionAdded: '0.43'
412
+ # This will convert usages of `try` to use safe navigation as well as `try!`.
413
+ # `try` and `try!` work slightly differently. `try!` and safe navigation will
414
+ # both raise a `NoMethodError` if the receiver of the method call does not
415
+ # implement the intended method. `try` will not raise an exception for this.
416
+ ConvertTry: false
417
+
418
+ Rails/SafeNavigationWithBlank:
419
+ Description: 'Avoid `foo&.blank?` in conditionals.'
420
+ Enabled: true
421
+ VersionAdded: '2.4'
422
+ # While the safe navigation operator is generally a good idea, when
423
+ # checking `foo&.blank?` in a conditional, `foo` being `nil` will actually
424
+ # do the opposite of what the author intends.
425
+ #
426
+ # foo&.blank? #=> nil
427
+ # foo.blank? #=> true
428
+ SafeAutoCorrect: false
429
+
430
+ Rails/SaveBang:
431
+ Description: 'Identifies possible cases where Active Record save! or related should be used.'
432
+ StyleGuide: 'https://rails.rubystyle.guide#save-bang'
433
+ Enabled: false
434
+ VersionAdded: '0.42'
435
+ VersionChanged: '0.59'
436
+ AllowImplicitReturn: true
437
+ AllowedReceivers: []
438
+ SafeAutoCorrect: false
439
+
440
+ Rails/ScopeArgs:
441
+ Description: 'Checks the arguments of ActiveRecord scopes.'
442
+ Enabled: true
443
+ VersionAdded: '0.19'
444
+ Include:
445
+ - app/models/**/*.rb
446
+
447
+ Rails/SkipsModelValidations:
448
+ Description: >-
449
+ Use methods that skips model validations with caution.
450
+ See reference for more information.
451
+ Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
452
+ Enabled: true
453
+ VersionAdded: '0.47'
454
+ VersionChanged: '0.60'
455
+ Blacklist:
456
+ - decrement!
457
+ - decrement_counter
458
+ - increment!
459
+ - increment_counter
460
+ - toggle!
461
+ - touch
462
+ - update_all
463
+ - update_attribute
464
+ - update_column
465
+ - update_columns
466
+ - update_counters
467
+ Whitelist: []
468
+
469
+ Rails/TimeZone:
470
+ Description: 'Checks the correct usage of time zone aware methods.'
471
+ StyleGuide: 'https://rails.rubystyle.guide#time'
472
+ Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
473
+ Enabled: true
474
+ Safe: false
475
+ VersionAdded: '0.30'
476
+ VersionChanged: '0.68'
477
+ # The value `strict` means that `Time` should be used with `zone`.
478
+ # The value `flexible` allows usage of `in_time_zone` instead of `zone`.
479
+ EnforcedStyle: flexible
480
+ SupportedStyles:
481
+ - strict
482
+ - flexible
483
+
484
+ Rails/UniqBeforePluck:
485
+ Description: 'Prefer the use of uniq or distinct before pluck.'
486
+ Enabled: true
487
+ VersionAdded: '0.40'
488
+ VersionChanged: '0.47'
489
+ EnforcedStyle: conservative
490
+ SupportedStyles:
491
+ - conservative
492
+ - aggressive
493
+ AutoCorrect: false
494
+
495
+ Rails/UnknownEnv:
496
+ Description: 'Use correct environment name.'
497
+ Enabled: true
498
+ VersionAdded: '0.51'
499
+ Environments:
500
+ - development
501
+ - test
502
+ - production
503
+
504
+ Rails/Validation:
505
+ Description: 'Use validates :attribute, hash of validations.'
506
+ Enabled: true
507
+ VersionAdded: '0.9'
508
+ VersionChanged: '0.41'
509
+ Include:
510
+ - app/models/**/*.rb