rubocop-rails 2.0.0

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