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