rubocop-rails 2.15.2 → 2.37.0
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.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +84 -9
- data/config/default.yml +417 -82
- data/config/obsoletion.yml +10 -0
- data/lib/rubocop/cop/mixin/active_record_helper.rb +19 -10
- data/lib/rubocop/cop/mixin/active_record_migrations_helper.rb +3 -5
- data/lib/rubocop/cop/mixin/database_type_resolvable.rb +66 -0
- data/lib/rubocop/cop/mixin/enforce_superclass.rb +7 -2
- data/lib/rubocop/cop/mixin/index_method.rb +73 -71
- data/lib/rubocop/cop/mixin/migrations_helper.rb +1 -1
- data/lib/rubocop/cop/mixin/routes_helper.rb +20 -0
- data/lib/rubocop/cop/mixin/target_rails_version.rb +17 -2
- data/lib/rubocop/cop/mixin.rb +17 -0
- data/lib/rubocop/cop/rails/action_controller_flash_before_render.rb +116 -0
- data/lib/rubocop/cop/rails/action_controller_test_case.rb +4 -4
- data/lib/rubocop/cop/rails/action_filter.rb +4 -1
- data/lib/rubocop/cop/rails/action_order.rb +112 -0
- data/lib/rubocop/cop/rails/active_record_aliases.rb +5 -6
- data/lib/rubocop/cop/rails/active_record_callbacks_order.rb +3 -4
- data/lib/rubocop/cop/rails/active_record_override.rb +2 -5
- data/lib/rubocop/cop/rails/active_support_aliases.rb +6 -5
- data/lib/rubocop/cop/rails/active_support_on_load.rb +90 -0
- data/lib/rubocop/cop/rails/add_column_index.rb +3 -5
- data/lib/rubocop/cop/rails/after_commit_override.rb +1 -1
- data/lib/rubocop/cop/rails/application_controller.rb +2 -3
- data/lib/rubocop/cop/rails/application_job.rb +3 -4
- data/lib/rubocop/cop/rails/application_mailer.rb +2 -3
- data/lib/rubocop/cop/rails/application_record.rb +6 -3
- data/lib/rubocop/cop/rails/arel_star.rb +6 -6
- data/lib/rubocop/cop/rails/assert_not.rb +1 -2
- data/lib/rubocop/cop/rails/attribute_default_block_value.rb +9 -0
- data/lib/rubocop/cop/rails/belongs_to.rb +2 -5
- data/lib/rubocop/cop/rails/blank.rb +7 -8
- data/lib/rubocop/cop/rails/bulk_change_table.rb +26 -69
- data/lib/rubocop/cop/rails/compact_blank.rb +34 -9
- data/lib/rubocop/cop/rails/content_tag.rb +7 -8
- data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +16 -3
- data/lib/rubocop/cop/rails/dangerous_column_names.rb +447 -0
- data/lib/rubocop/cop/rails/date.rb +18 -14
- data/lib/rubocop/cop/rails/delegate.rb +71 -14
- data/lib/rubocop/cop/rails/delegate_allow_blank.rb +1 -1
- data/lib/rubocop/cop/rails/deprecated_active_model_errors_methods.rb +18 -14
- data/lib/rubocop/cop/rails/dot_separated_keys.rb +2 -2
- data/lib/rubocop/cop/rails/duplicate_association.rb +71 -10
- data/lib/rubocop/cop/rails/duplicate_scope.rb +2 -2
- data/lib/rubocop/cop/rails/duration_arithmetic.rb +3 -3
- data/lib/rubocop/cop/rails/dynamic_find_by.rb +28 -16
- data/lib/rubocop/cop/rails/eager_evaluation_log_message.rb +9 -7
- data/lib/rubocop/cop/rails/enum_hash.rb +31 -8
- data/lib/rubocop/cop/rails/enum_syntax.rb +130 -0
- data/lib/rubocop/cop/rails/enum_uniqueness.rb +30 -11
- data/lib/rubocop/cop/rails/env.rb +70 -0
- data/lib/rubocop/cop/rails/env_local.rb +93 -0
- data/lib/rubocop/cop/rails/environment_comparison.rb +56 -49
- data/lib/rubocop/cop/rails/exit.rb +7 -4
- data/lib/rubocop/cop/rails/expanded_date_range.rb +1 -1
- data/lib/rubocop/cop/rails/file_path.rb +214 -32
- data/lib/rubocop/cop/rails/find_by.rb +4 -4
- data/lib/rubocop/cop/rails/find_by_id.rb +11 -25
- data/lib/rubocop/cop/rails/find_by_or_assignment_memoization.rb +124 -0
- data/lib/rubocop/cop/rails/find_each.rb +15 -5
- data/lib/rubocop/cop/rails/freeze_time.rb +79 -0
- data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +5 -7
- data/lib/rubocop/cop/rails/helper_instance_variable.rb +17 -18
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +35 -11
- data/lib/rubocop/cop/rails/http_status.rb +22 -16
- data/lib/rubocop/cop/rails/http_status_name_consistency.rb +80 -0
- data/lib/rubocop/cop/rails/i18n_lazy_lookup.rb +65 -13
- data/lib/rubocop/cop/rails/i18n_locale_texts.rb +29 -3
- data/lib/rubocop/cop/rails/ignored_columns_assignment.rb +50 -0
- data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +24 -13
- data/lib/rubocop/cop/rails/index_by.rb +38 -13
- data/lib/rubocop/cop/rails/index_with.rb +43 -13
- data/lib/rubocop/cop/rails/inquiry.rb +2 -1
- data/lib/rubocop/cop/rails/inverse_of.rb +9 -9
- data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +38 -23
- data/lib/rubocop/cop/rails/link_to_blank.rb +3 -6
- data/lib/rubocop/cop/rails/mailer_name.rb +4 -4
- data/lib/rubocop/cop/rails/match_route.rb +1 -9
- data/lib/rubocop/cop/rails/migration_class_name.rb +1 -1
- data/lib/rubocop/cop/rails/multiple_route_paths.rb +50 -0
- data/lib/rubocop/cop/rails/negate_include.rb +1 -1
- data/lib/rubocop/cop/rails/not_null_column.rb +108 -9
- data/lib/rubocop/cop/rails/order_arguments.rb +84 -0
- data/lib/rubocop/cop/rails/output.rb +8 -8
- data/lib/rubocop/cop/rails/output_safety.rb +8 -2
- data/lib/rubocop/cop/rails/pick.rb +10 -5
- data/lib/rubocop/cop/rails/pluck.rb +73 -13
- data/lib/rubocop/cop/rails/pluck_id.rb +3 -2
- data/lib/rubocop/cop/rails/pluck_in_where.rb +35 -13
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +30 -17
- data/lib/rubocop/cop/rails/presence.rb +94 -29
- data/lib/rubocop/cop/rails/present.rb +9 -14
- data/lib/rubocop/cop/rails/rake_environment.rb +23 -7
- data/lib/rubocop/cop/rails/read_write_attribute.rb +2 -2
- data/lib/rubocop/cop/rails/redirect_back_or_to.rb +98 -0
- data/lib/rubocop/cop/rails/redundant_active_record_all_method.rb +190 -0
- data/lib/rubocop/cop/rails/redundant_allow_nil.rb +5 -7
- data/lib/rubocop/cop/rails/redundant_foreign_key.rb +2 -2
- data/lib/rubocop/cop/rails/redundant_presence_validation_on_belongs_to.rb +21 -5
- data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +34 -26
- data/lib/rubocop/cop/rails/reflection_class_name.rb +34 -1
- data/lib/rubocop/cop/rails/refute_methods.rb +1 -6
- data/lib/rubocop/cop/rails/relative_date_constant.rb +5 -8
- data/lib/rubocop/cop/rails/render_plain_text.rb +6 -3
- data/lib/rubocop/cop/rails/request_referer.rb +2 -3
- data/lib/rubocop/cop/rails/require_dependency.rb +1 -1
- data/lib/rubocop/cop/rails/response_parsed_body.rb +108 -0
- data/lib/rubocop/cop/rails/reversible_migration.rb +28 -65
- data/lib/rubocop/cop/rails/reversible_migration_method_definition.rb +1 -2
- data/lib/rubocop/cop/rails/root_join_chain.rb +1 -1
- data/lib/rubocop/cop/rails/root_pathname_methods.rb +281 -0
- data/lib/rubocop/cop/rails/safe_navigation.rb +34 -6
- data/lib/rubocop/cop/rails/safe_navigation_with_blank.rb +1 -3
- data/lib/rubocop/cop/rails/save_bang.rb +42 -39
- data/lib/rubocop/cop/rails/schema_comment.rb +18 -11
- data/lib/rubocop/cop/rails/select_map.rb +100 -0
- data/lib/rubocop/cop/rails/short_i18n.rb +2 -5
- data/lib/rubocop/cop/rails/skips_model_validations.rb +11 -7
- data/lib/rubocop/cop/rails/squished_sql_heredocs.rb +10 -8
- data/lib/rubocop/cop/rails/strip_heredoc.rb +1 -1
- data/lib/rubocop/cop/rails/strong_parameters_expect.rb +212 -0
- data/lib/rubocop/cop/rails/three_state_boolean_column.rb +72 -0
- data/lib/rubocop/cop/rails/time_zone.rb +54 -35
- data/lib/rubocop/cop/rails/time_zone_assignment.rb +1 -1
- 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 +42 -10
- data/lib/rubocop/cop/rails/uniq_before_pluck.rb +11 -29
- data/lib/rubocop/cop/rails/unique_validation_without_index.rb +25 -22
- data/lib/rubocop/cop/rails/unknown_env.rb +40 -11
- data/lib/rubocop/cop/rails/unused_ignored_columns.rb +12 -1
- data/lib/rubocop/cop/rails/unused_render_content.rb +67 -0
- data/lib/rubocop/cop/rails/validation.rb +13 -16
- data/lib/rubocop/cop/rails/where_equals.rb +29 -13
- data/lib/rubocop/cop/rails/where_exists.rb +14 -14
- data/lib/rubocop/cop/rails/where_missing.rb +121 -0
- data/lib/rubocop/cop/rails/where_not.rb +18 -12
- data/lib/rubocop/cop/rails/where_not_with_multiple_conditions.rb +55 -0
- data/lib/rubocop/cop/rails/where_range.rb +202 -0
- data/lib/rubocop/cop/rails.rb +152 -0
- data/lib/rubocop/cop/rails_cops.rb +4 -120
- data/lib/rubocop/rails/migration_file_skippable.rb +50 -0
- data/lib/rubocop/rails/plugin.rb +48 -0
- data/lib/rubocop/rails/schema_loader/schema.rb +8 -7
- data/lib/rubocop/rails/schema_loader.rb +5 -15
- data/lib/rubocop/rails/version.rb +1 -1
- data/lib/rubocop/rails.rb +1 -8
- data/lib/rubocop-rails.rb +30 -3
- metadata +74 -13
- data/bin/console +0 -11
- data/bin/setup +0 -7
- data/lib/rubocop/rails/inject.rb +0 -18
data/config/default.yml
CHANGED
|
@@ -6,24 +6,35 @@ inherit_mode:
|
|
|
6
6
|
|
|
7
7
|
AllCops:
|
|
8
8
|
Exclude:
|
|
9
|
+
- '**/app/assets/**/*'
|
|
9
10
|
- bin/*
|
|
10
11
|
# Exclude db/schema.rb and db/[CONFIGURATION_NAMESPACE]_schema.rb by default.
|
|
11
12
|
# See: https://guides.rubyonrails.org/active_record_multiple_databases.html#setting-up-your-application
|
|
12
13
|
- db/*schema.rb
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
#
|
|
14
|
+
- log/**/*
|
|
15
|
+
- public/**/*
|
|
16
|
+
- storage/**/*
|
|
17
|
+
# Enable checking Active Support extensions.
|
|
18
|
+
# See: https://docs.rubocop.org/rubocop/configuration.html#enable-checking-active-support-extensions
|
|
19
|
+
ActiveSupportExtensionsEnabled: true
|
|
20
|
+
# What version of Rails is the inspected code using? If a value is specified
|
|
21
|
+
# for `TargetRailsVersion` then it is used. Acceptable values are specified
|
|
22
|
+
# as a float (e.g., 7.2); the patch version of Rails should not be included.
|
|
23
|
+
# If `TargetRailsVersion` is not set, RuboCop will parse the Gemfile.lock or
|
|
17
24
|
# gems.locked file to find the version of Rails that has been bound to the
|
|
18
|
-
# application.
|
|
25
|
+
# application. If neither of those files exist, RuboCop will use Rails 5.0
|
|
19
26
|
# as the default.
|
|
20
27
|
TargetRailsVersion: ~
|
|
28
|
+
# By specifying `MigratedSchemaVersion` option, migration files that have been migrated can be ignored.
|
|
29
|
+
# When `MigratedSchemaVersion: '20241231000000'` is set. Migration files lower than or equal to '20250101000000' will be ignored.
|
|
30
|
+
# For example, this is the timestamp in db/migrate/20250101000000_create_articles.rb.
|
|
31
|
+
MigratedSchemaVersion: '19700101000000' # NOTE: Used as a sentinel value for the UNIX epoch time.
|
|
21
32
|
|
|
22
33
|
Lint/NumberConversion:
|
|
23
34
|
# Add Rails' duration methods to the ignore list for `Lint/NumberConversion`
|
|
24
35
|
# so that calling `to_i` on one of these does not register an offense.
|
|
25
36
|
# See: https://github.com/rubocop/rubocop/issues/8950
|
|
26
|
-
|
|
37
|
+
AllowedMethods:
|
|
27
38
|
- ago
|
|
28
39
|
- from_now
|
|
29
40
|
- second
|
|
@@ -39,28 +50,100 @@ Lint/NumberConversion:
|
|
|
39
50
|
- fortnight
|
|
40
51
|
- fortnights
|
|
41
52
|
- in_milliseconds
|
|
53
|
+
AllowedPatterns: []
|
|
54
|
+
|
|
55
|
+
Lint/RedundantSafeNavigation:
|
|
56
|
+
# Add `presence` and `present?` methods to the default of the RuboCop core.
|
|
57
|
+
# https://github.com/rubocop/rubocop/blob/v1.51.0/config/default.yml#L2148-L2159
|
|
58
|
+
AllowedMethods:
|
|
59
|
+
- instance_of?
|
|
60
|
+
- kind_of?
|
|
61
|
+
- is_a?
|
|
62
|
+
- eql?
|
|
63
|
+
- respond_to?
|
|
64
|
+
- equal?
|
|
65
|
+
- presence
|
|
66
|
+
- present?
|
|
67
|
+
|
|
68
|
+
Lint/SafeNavigationChain:
|
|
69
|
+
# Add `presence_in` method to the default of the RuboCop core:
|
|
70
|
+
# https://github.com/rubocop/rubocop/blob/v1.56.0/config/default.yml#L2265-L2271
|
|
71
|
+
AllowedMethods:
|
|
72
|
+
- present?
|
|
73
|
+
- blank?
|
|
74
|
+
- presence
|
|
75
|
+
- presence_in
|
|
76
|
+
- try
|
|
77
|
+
- try!
|
|
78
|
+
- in?
|
|
79
|
+
|
|
80
|
+
Lint/UselessAccessModifier:
|
|
81
|
+
# Add methods from `ActiveSupport::Concern` and `Module::Concerning`:
|
|
82
|
+
# https://api.rubyonrails.org/classes/ActiveSupport/Concern.html
|
|
83
|
+
# https://api.rubyonrails.org/classes/Module/Concerning
|
|
84
|
+
inherit_mode:
|
|
85
|
+
merge:
|
|
86
|
+
- ContextCreatingMethods
|
|
87
|
+
ContextCreatingMethods:
|
|
88
|
+
- class_methods
|
|
89
|
+
- included
|
|
90
|
+
- prepended
|
|
91
|
+
- concern
|
|
92
|
+
- concerning
|
|
93
|
+
|
|
94
|
+
Lint/UselessMethodDefinition:
|
|
95
|
+
# Avoids conflict with `Rails/LexicallyScopedActionFilter` cop.
|
|
96
|
+
Exclude:
|
|
97
|
+
- '**/app/controllers/**/*.rb'
|
|
98
|
+
- '**/app/mailers/**/*.rb'
|
|
99
|
+
|
|
100
|
+
Rails:
|
|
101
|
+
Enabled: true
|
|
102
|
+
DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails
|
|
103
|
+
|
|
104
|
+
Rails/ActionControllerFlashBeforeRender:
|
|
105
|
+
Description: 'Use `flash.now` instead of `flash` before `render`.'
|
|
106
|
+
Enabled: 'pending'
|
|
107
|
+
SafeAutoCorrect: false
|
|
108
|
+
VersionAdded: '2.16'
|
|
42
109
|
|
|
43
110
|
Rails/ActionControllerTestCase:
|
|
44
111
|
Description: 'Use `ActionDispatch::IntegrationTest` instead of `ActionController::TestCase`.'
|
|
45
112
|
StyleGuide: 'https://rails.rubystyle.guide/#integration-testing'
|
|
46
113
|
Reference: 'https://api.rubyonrails.org/classes/ActionController/TestCase.html'
|
|
47
114
|
Enabled: 'pending'
|
|
48
|
-
|
|
115
|
+
SafeAutoCorrect: false
|
|
49
116
|
VersionAdded: '2.14'
|
|
50
117
|
Include:
|
|
51
118
|
- '**/test/**/*.rb'
|
|
52
119
|
|
|
53
120
|
Rails/ActionFilter:
|
|
54
121
|
Description: 'Enforces consistent use of action filter methods.'
|
|
55
|
-
Enabled:
|
|
122
|
+
Enabled: false
|
|
56
123
|
VersionAdded: '0.19'
|
|
124
|
+
VersionChanged: '2.22'
|
|
57
125
|
EnforcedStyle: action
|
|
58
126
|
SupportedStyles:
|
|
59
127
|
- action
|
|
60
128
|
- filter
|
|
61
129
|
Include:
|
|
62
|
-
- app/controllers/**/*.rb
|
|
63
|
-
- app/mailers/**/*.rb
|
|
130
|
+
- '**/app/controllers/**/*.rb'
|
|
131
|
+
- '**/app/mailers/**/*.rb'
|
|
132
|
+
|
|
133
|
+
Rails/ActionOrder:
|
|
134
|
+
Description: 'Enforce consistent ordering of controller actions.'
|
|
135
|
+
Enabled: pending
|
|
136
|
+
VersionAdded: '2.17'
|
|
137
|
+
ExpectedOrder:
|
|
138
|
+
- index
|
|
139
|
+
- show
|
|
140
|
+
- new
|
|
141
|
+
- edit
|
|
142
|
+
- create
|
|
143
|
+
- update
|
|
144
|
+
- destroy
|
|
145
|
+
Include:
|
|
146
|
+
- '**/app/controllers/**/*.rb'
|
|
64
147
|
|
|
65
148
|
Rails/ActiveRecordAliases:
|
|
66
149
|
Description: >-
|
|
@@ -77,16 +160,18 @@ Rails/ActiveRecordCallbacksOrder:
|
|
|
77
160
|
Enabled: 'pending'
|
|
78
161
|
VersionAdded: '2.7'
|
|
79
162
|
Include:
|
|
80
|
-
- app/models/**/*.rb
|
|
163
|
+
- '**/app/models/**/*.rb'
|
|
81
164
|
|
|
82
165
|
Rails/ActiveRecordOverride:
|
|
83
166
|
Description: >-
|
|
84
167
|
Check for overriding Active Record methods instead of using
|
|
85
168
|
callbacks.
|
|
86
169
|
Enabled: true
|
|
170
|
+
Severity: warning
|
|
87
171
|
VersionAdded: '0.67'
|
|
172
|
+
VersionChanged: '2.18'
|
|
88
173
|
Include:
|
|
89
|
-
- app/models/**/*.rb
|
|
174
|
+
- '**/app/models/**/*.rb'
|
|
90
175
|
|
|
91
176
|
Rails/ActiveSupportAliases:
|
|
92
177
|
Description: >-
|
|
@@ -96,6 +181,16 @@ Rails/ActiveSupportAliases:
|
|
|
96
181
|
Enabled: true
|
|
97
182
|
VersionAdded: '0.48'
|
|
98
183
|
|
|
184
|
+
Rails/ActiveSupportOnLoad:
|
|
185
|
+
Description: 'Use `ActiveSupport.on_load(...)` to patch Rails framework classes.'
|
|
186
|
+
Enabled: 'pending'
|
|
187
|
+
Reference:
|
|
188
|
+
- 'https://api.rubyonrails.org/classes/ActiveSupport/LazyLoadHooks.html'
|
|
189
|
+
- 'https://guides.rubyonrails.org/engines.html#available-load-hooks'
|
|
190
|
+
SafeAutoCorrect: false
|
|
191
|
+
VersionAdded: '2.16'
|
|
192
|
+
VersionChanged: '2.24'
|
|
193
|
+
|
|
99
194
|
Rails/AddColumnIndex:
|
|
100
195
|
Description: >-
|
|
101
196
|
Rails migrations don't make use of a given `index` key, but also
|
|
@@ -103,8 +198,9 @@ Rails/AddColumnIndex:
|
|
|
103
198
|
index might be used.
|
|
104
199
|
Enabled: pending
|
|
105
200
|
VersionAdded: '2.11'
|
|
201
|
+
VersionChanged: '2.20'
|
|
106
202
|
Include:
|
|
107
|
-
- db
|
|
203
|
+
- db/**/*.rb
|
|
108
204
|
|
|
109
205
|
Rails/AfterCommitOverride:
|
|
110
206
|
Description: >-
|
|
@@ -140,7 +236,9 @@ Rails/ApplicationRecord:
|
|
|
140
236
|
Enabled: true
|
|
141
237
|
SafeAutoCorrect: false
|
|
142
238
|
VersionAdded: '0.49'
|
|
143
|
-
VersionChanged: '2.
|
|
239
|
+
VersionChanged: '2.26'
|
|
240
|
+
Exclude:
|
|
241
|
+
- db/**/*.rb
|
|
144
242
|
|
|
145
243
|
Rails/ArelStar:
|
|
146
244
|
Description: 'Enforces `Arel.star` instead of `"*"` for expanded columns.'
|
|
@@ -160,12 +258,15 @@ Rails/AttributeDefaultBlockValue:
|
|
|
160
258
|
Enabled: pending
|
|
161
259
|
VersionAdded: '2.9'
|
|
162
260
|
Include:
|
|
163
|
-
- 'app/models/**/*'
|
|
261
|
+
- '**/app/models/**/*'
|
|
164
262
|
|
|
165
263
|
Rails/BelongsTo:
|
|
166
264
|
Description: >-
|
|
167
265
|
Use `optional: true` instead of `required: false` for
|
|
168
266
|
`belongs_to` relations.
|
|
267
|
+
Reference:
|
|
268
|
+
- https://guides.rubyonrails.org/5_0_release_notes.html
|
|
269
|
+
- https://github.com/rails/rails/pull/18937
|
|
169
270
|
Enabled: true
|
|
170
271
|
VersionAdded: '0.62'
|
|
171
272
|
|
|
@@ -184,14 +285,18 @@ Rails/Blank:
|
|
|
184
285
|
|
|
185
286
|
Rails/BulkChangeTable:
|
|
186
287
|
Description: 'Check whether alter queries are combinable.'
|
|
288
|
+
Reference:
|
|
289
|
+
- https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-change_table
|
|
290
|
+
- https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Table.html
|
|
187
291
|
Enabled: true
|
|
188
292
|
VersionAdded: '0.57'
|
|
293
|
+
VersionChanged: '2.20'
|
|
189
294
|
Database: null
|
|
190
295
|
SupportedDatabases:
|
|
191
296
|
- mysql
|
|
192
297
|
- postgresql
|
|
193
298
|
Include:
|
|
194
|
-
- db
|
|
299
|
+
- db/**/*.rb
|
|
195
300
|
|
|
196
301
|
Rails/CompactBlank:
|
|
197
302
|
Description: 'Checks if collection can be blank-compacted with `compact_blank`.'
|
|
@@ -212,8 +317,8 @@ Rails/ContentTag:
|
|
|
212
317
|
# https://puma.io/puma/Puma/DSL.html#tag-instance_method
|
|
213
318
|
# No helpers are used in normal models and configs.
|
|
214
319
|
Exclude:
|
|
215
|
-
- app/models/**/*.rb
|
|
216
|
-
- config/**/*.rb
|
|
320
|
+
- '**/app/models/**/*.rb'
|
|
321
|
+
- '**/config/**/*.rb'
|
|
217
322
|
|
|
218
323
|
Rails/CreateTableWithTimestamps:
|
|
219
324
|
Description: >-
|
|
@@ -221,18 +326,31 @@ Rails/CreateTableWithTimestamps:
|
|
|
221
326
|
when creating a new table.
|
|
222
327
|
Enabled: true
|
|
223
328
|
VersionAdded: '0.52'
|
|
329
|
+
VersionChanged: '2.20'
|
|
224
330
|
Include:
|
|
225
|
-
- db
|
|
331
|
+
- db/**/*.rb
|
|
226
332
|
Exclude:
|
|
227
333
|
# Respect the `active_storage_variant_records` table of `*_create_active_storage_tables.active_storage.rb`
|
|
334
|
+
# and `*_create_active_storage_variant_records.active_storage.rb`
|
|
228
335
|
# auto-generated by `bin/rails active_storage:install` even if `created_at` is not specified.
|
|
229
|
-
- db
|
|
336
|
+
- db/**/*_create_active_storage_tables.active_storage.rb
|
|
337
|
+
- db/**/*_create_active_storage_variant_records.active_storage.rb
|
|
338
|
+
|
|
339
|
+
Rails/DangerousColumnNames:
|
|
340
|
+
Description: >-
|
|
341
|
+
Avoid dangerous column names.
|
|
342
|
+
Enabled: pending
|
|
343
|
+
Severity: warning
|
|
344
|
+
VersionAdded: '2.21'
|
|
345
|
+
Include:
|
|
346
|
+
- 'db/**/*.rb'
|
|
230
347
|
|
|
231
348
|
Rails/Date:
|
|
232
349
|
Description: >-
|
|
233
350
|
Checks the correct usage of date aware methods,
|
|
234
351
|
such as Date.today, Date.current etc.
|
|
235
352
|
Enabled: true
|
|
353
|
+
SafeAutoCorrect: false
|
|
236
354
|
VersionAdded: '0.30'
|
|
237
355
|
VersionChanged: '2.11'
|
|
238
356
|
# The value `strict` disallows usage of `Date.today`, `Date.current`,
|
|
@@ -248,7 +366,6 @@ Rails/Date:
|
|
|
248
366
|
|
|
249
367
|
Rails/DefaultScope:
|
|
250
368
|
Description: 'Avoid use of `default_scope`.'
|
|
251
|
-
StyleGuide: 'https://rails.rubystyle.guide#avoid-default-scope'
|
|
252
369
|
Enabled: false
|
|
253
370
|
VersionAdded: '2.7'
|
|
254
371
|
|
|
@@ -256,11 +373,13 @@ Rails/Delegate:
|
|
|
256
373
|
Description: 'Prefer delegate method for delegations.'
|
|
257
374
|
Enabled: true
|
|
258
375
|
VersionAdded: '0.21'
|
|
259
|
-
VersionChanged: '
|
|
376
|
+
VersionChanged: '2.30'
|
|
260
377
|
# When set to true, using the target object as a prefix of the
|
|
261
378
|
# method name without using the `delegate` method will be a
|
|
262
379
|
# violation. When set to false, this case is legal.
|
|
263
380
|
EnforceForPrefixed: true
|
|
381
|
+
Exclude:
|
|
382
|
+
- '**/app/controllers/**/*.rb'
|
|
264
383
|
|
|
265
384
|
Rails/DelegateAllowBlank:
|
|
266
385
|
Description: 'Do not use allow_blank as an option to delegate.'
|
|
@@ -270,9 +389,10 @@ Rails/DelegateAllowBlank:
|
|
|
270
389
|
Rails/DeprecatedActiveModelErrorsMethods:
|
|
271
390
|
Description: 'Avoid manipulating ActiveModel errors hash directly.'
|
|
272
391
|
Enabled: pending
|
|
392
|
+
Severity: warning
|
|
273
393
|
Safe: false
|
|
274
394
|
VersionAdded: '2.14'
|
|
275
|
-
VersionChanged: '2.
|
|
395
|
+
VersionChanged: '2.18'
|
|
276
396
|
|
|
277
397
|
Rails/DotSeparatedKeys:
|
|
278
398
|
Description: 'Enforces the use of dot-separated keys instead of `:scope` options in `I18n` translation methods.'
|
|
@@ -283,12 +403,16 @@ Rails/DotSeparatedKeys:
|
|
|
283
403
|
Rails/DuplicateAssociation:
|
|
284
404
|
Description: "Don't repeat associations in a model."
|
|
285
405
|
Enabled: pending
|
|
406
|
+
Severity: warning
|
|
286
407
|
VersionAdded: '2.14'
|
|
408
|
+
VersionChanged: '2.18'
|
|
287
409
|
|
|
288
410
|
Rails/DuplicateScope:
|
|
289
|
-
Description: 'Multiple scopes share this same
|
|
411
|
+
Description: 'Multiple scopes share this same expression.'
|
|
290
412
|
Enabled: pending
|
|
413
|
+
Severity: warning
|
|
291
414
|
VersionAdded: '2.14'
|
|
415
|
+
VersionChanged: '2.18'
|
|
292
416
|
|
|
293
417
|
Rails/DurationArithmetic:
|
|
294
418
|
Description: 'Do not use duration as arithmetic operand with `Time.current`.'
|
|
@@ -306,10 +430,13 @@ Rails/DynamicFindBy:
|
|
|
306
430
|
# The `Whitelist` has been deprecated, Please use `AllowedMethods` instead.
|
|
307
431
|
Whitelist:
|
|
308
432
|
- find_by_sql
|
|
433
|
+
- find_by_token_for
|
|
309
434
|
AllowedMethods:
|
|
310
435
|
- find_by_sql
|
|
436
|
+
- find_by_token_for
|
|
311
437
|
AllowedReceivers:
|
|
312
438
|
- Gem::Specification
|
|
439
|
+
- page # Prevents a warning for `page.find_by_id`. See: https://github.com/rubocop/rubocop-rails/issues/778
|
|
313
440
|
|
|
314
441
|
Rails/EagerEvaluationLogMessage:
|
|
315
442
|
Description: 'Checks that blocks are used for interpolated strings passed to `Rails.logger.debug`.'
|
|
@@ -323,14 +450,33 @@ Rails/EnumHash:
|
|
|
323
450
|
Enabled: true
|
|
324
451
|
VersionAdded: '2.3'
|
|
325
452
|
Include:
|
|
326
|
-
- app/models/**/*.rb
|
|
453
|
+
- '**/app/models/**/*.rb'
|
|
454
|
+
|
|
455
|
+
Rails/EnumSyntax:
|
|
456
|
+
Description: 'Use positional arguments over keyword arguments when defining enums.'
|
|
457
|
+
Enabled: pending
|
|
458
|
+
Severity: warning
|
|
459
|
+
VersionAdded: '2.26'
|
|
460
|
+
Include:
|
|
461
|
+
- '**/app/models/**/*.rb'
|
|
462
|
+
- '**/lib/**/*.rb'
|
|
327
463
|
|
|
328
464
|
Rails/EnumUniqueness:
|
|
329
465
|
Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
|
|
330
466
|
Enabled: true
|
|
331
467
|
VersionAdded: '0.46'
|
|
332
468
|
Include:
|
|
333
|
-
- app/models/**/*.rb
|
|
469
|
+
- '**/app/models/**/*.rb'
|
|
470
|
+
|
|
471
|
+
Rails/Env:
|
|
472
|
+
Description: 'Use Feature Flags or config instead of `Rails.env`.'
|
|
473
|
+
Enabled: false
|
|
474
|
+
VersionAdded: '2.34'
|
|
475
|
+
|
|
476
|
+
Rails/EnvLocal:
|
|
477
|
+
Description: 'Use `Rails.env.local?` instead of `Rails.env.development? || Rails.env.test?`.'
|
|
478
|
+
Enabled: pending
|
|
479
|
+
VersionAdded: '2.22'
|
|
334
480
|
|
|
335
481
|
Rails/EnvironmentComparison:
|
|
336
482
|
Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`."
|
|
@@ -342,12 +488,13 @@ Rails/EnvironmentVariableAccess:
|
|
|
342
488
|
# TODO: Set to `pending` status in RuboCop Rails 2 series when migration doc will be written.
|
|
343
489
|
Enabled: false
|
|
344
490
|
VersionAdded: '2.10'
|
|
345
|
-
VersionChanged: '2.
|
|
491
|
+
VersionChanged: '2.24'
|
|
346
492
|
Include:
|
|
347
|
-
- app/**/*.rb
|
|
348
|
-
-
|
|
493
|
+
- '**/app/**/*.rb'
|
|
494
|
+
- '**/config/initializers/**/*.rb'
|
|
495
|
+
- '**/lib/**/*.rb'
|
|
349
496
|
Exclude:
|
|
350
|
-
- lib/**/*.rake
|
|
497
|
+
- '**/lib/**/*.rake'
|
|
351
498
|
AllowReads: false
|
|
352
499
|
AllowWrites: false
|
|
353
500
|
|
|
@@ -359,11 +506,11 @@ Rails/Exit:
|
|
|
359
506
|
Enabled: true
|
|
360
507
|
VersionAdded: '0.41'
|
|
361
508
|
Include:
|
|
362
|
-
- app/**/*.rb
|
|
363
|
-
- config/**/*.rb
|
|
364
|
-
- lib/**/*.rb
|
|
509
|
+
- '**/app/**/*.rb'
|
|
510
|
+
- '**/config/**/*.rb'
|
|
511
|
+
- '**/lib/**/*.rb'
|
|
365
512
|
Exclude:
|
|
366
|
-
- lib/**/*.rake
|
|
513
|
+
- '**/lib/**/*.rake'
|
|
367
514
|
|
|
368
515
|
Rails/ExpandedDateRange:
|
|
369
516
|
Description: 'Checks for expanded date range.'
|
|
@@ -386,10 +533,8 @@ Rails/FindBy:
|
|
|
386
533
|
StyleGuide: 'https://rails.rubystyle.guide#find_by'
|
|
387
534
|
Enabled: true
|
|
388
535
|
VersionAdded: '0.30'
|
|
389
|
-
VersionChanged: '2.
|
|
536
|
+
VersionChanged: '2.21'
|
|
390
537
|
IgnoreWhereFirst: true
|
|
391
|
-
Include:
|
|
392
|
-
- app/models/**/*.rb
|
|
393
538
|
|
|
394
539
|
Rails/FindById:
|
|
395
540
|
Description: >-
|
|
@@ -399,20 +544,34 @@ Rails/FindById:
|
|
|
399
544
|
Enabled: 'pending'
|
|
400
545
|
VersionAdded: '2.7'
|
|
401
546
|
|
|
547
|
+
Rails/FindByOrAssignmentMemoization:
|
|
548
|
+
Description: 'Avoid memoizing `find_by` results with `||=`.'
|
|
549
|
+
StyleGuide: 'https://rails.rubystyle.guide/#find-by-memoization'
|
|
550
|
+
Enabled: pending
|
|
551
|
+
Safe: false
|
|
552
|
+
VersionAdded: '2.33'
|
|
553
|
+
|
|
402
554
|
Rails/FindEach:
|
|
403
|
-
Description: 'Prefer all.find_each over all.
|
|
555
|
+
Description: 'Prefer all.find_each over all.each.'
|
|
404
556
|
StyleGuide: 'https://rails.rubystyle.guide#find-each'
|
|
405
557
|
Enabled: true
|
|
558
|
+
Safe: false
|
|
406
559
|
VersionAdded: '0.30'
|
|
407
|
-
VersionChanged: '2.
|
|
408
|
-
|
|
409
|
-
- app/models/**/*.rb
|
|
410
|
-
IgnoredMethods:
|
|
560
|
+
VersionChanged: '2.21'
|
|
561
|
+
AllowedMethods:
|
|
411
562
|
# Methods that don't work well with `find_each`.
|
|
412
563
|
- order
|
|
413
564
|
- limit
|
|
414
565
|
- select
|
|
415
566
|
- lock
|
|
567
|
+
AllowedPatterns: []
|
|
568
|
+
|
|
569
|
+
Rails/FreezeTime:
|
|
570
|
+
Description: 'Prefer `freeze_time` over `travel_to` with an argument of the current time.'
|
|
571
|
+
StyleGuide: 'https://rails.rubystyle.guide/#freeze-time'
|
|
572
|
+
Enabled: pending
|
|
573
|
+
VersionAdded: '2.16'
|
|
574
|
+
SafeAutoCorrect: false
|
|
416
575
|
|
|
417
576
|
Rails/HasAndBelongsToMany:
|
|
418
577
|
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
|
@@ -420,7 +579,7 @@ Rails/HasAndBelongsToMany:
|
|
|
420
579
|
Enabled: true
|
|
421
580
|
VersionAdded: '0.12'
|
|
422
581
|
Include:
|
|
423
|
-
- app/models/**/*.rb
|
|
582
|
+
- '**/app/models/**/*.rb'
|
|
424
583
|
|
|
425
584
|
Rails/HasManyOrHasOneDependent:
|
|
426
585
|
Description: 'Define the dependent option to the has_many and has_one associations.'
|
|
@@ -428,22 +587,22 @@ Rails/HasManyOrHasOneDependent:
|
|
|
428
587
|
Enabled: true
|
|
429
588
|
VersionAdded: '0.50'
|
|
430
589
|
Include:
|
|
431
|
-
- app/models/**/*.rb
|
|
590
|
+
- '**/app/models/**/*.rb'
|
|
432
591
|
|
|
433
592
|
Rails/HelperInstanceVariable:
|
|
434
593
|
Description: 'Do not use instance variables in helpers.'
|
|
435
594
|
Enabled: true
|
|
436
595
|
VersionAdded: '2.0'
|
|
437
596
|
Include:
|
|
438
|
-
- app/helpers/**/*.rb
|
|
597
|
+
- '**/app/helpers/**/*.rb'
|
|
439
598
|
|
|
440
599
|
Rails/HttpPositionalArguments:
|
|
441
600
|
Description: 'Use keyword arguments instead of positional arguments in http method calls.'
|
|
442
601
|
Enabled: true
|
|
443
602
|
VersionAdded: '0.44'
|
|
444
603
|
Include:
|
|
445
|
-
- 'spec/**/*'
|
|
446
|
-
- 'test/**/*'
|
|
604
|
+
- '**/spec/**/*'
|
|
605
|
+
- '**/test/**/*'
|
|
447
606
|
|
|
448
607
|
Rails/HttpStatus:
|
|
449
608
|
Description: 'Enforces use of symbolic or numeric value to define HTTP status.'
|
|
@@ -455,22 +614,34 @@ Rails/HttpStatus:
|
|
|
455
614
|
- numeric
|
|
456
615
|
- symbolic
|
|
457
616
|
|
|
617
|
+
Rails/HttpStatusNameConsistency:
|
|
618
|
+
Description: 'Enforces consistency by using the current HTTP status names.'
|
|
619
|
+
Enabled: pending
|
|
620
|
+
Severity: warning
|
|
621
|
+
VersionAdded: '2.34'
|
|
622
|
+
Include:
|
|
623
|
+
- '**/app/controllers/**/*.rb'
|
|
624
|
+
|
|
458
625
|
Rails/I18nLazyLookup:
|
|
459
626
|
Description: 'Checks for places where I18n "lazy" lookup can be used.'
|
|
460
627
|
StyleGuide: 'https://rails.rubystyle.guide/#lazy-lookup'
|
|
461
628
|
Reference: 'https://guides.rubyonrails.org/i18n.html#lazy-lookup'
|
|
462
629
|
Enabled: pending
|
|
463
630
|
VersionAdded: '2.14'
|
|
631
|
+
EnforcedStyle: lazy
|
|
632
|
+
SupportedStyles:
|
|
633
|
+
- lazy
|
|
634
|
+
- explicit
|
|
464
635
|
Include:
|
|
465
|
-
- 'controllers
|
|
636
|
+
- '**/app/controllers/**/*.rb'
|
|
466
637
|
|
|
467
638
|
Rails/I18nLocaleAssignment:
|
|
468
639
|
Description: 'Prefer the usage of `I18n.with_locale` instead of manually updating `I18n.locale` value.'
|
|
469
640
|
Enabled: 'pending'
|
|
470
641
|
VersionAdded: '2.11'
|
|
471
642
|
Include:
|
|
472
|
-
- spec/**/*.rb
|
|
473
|
-
- test/**/*.rb
|
|
643
|
+
- '**/spec/**/*.rb'
|
|
644
|
+
- '**/test/**/*.rb'
|
|
474
645
|
|
|
475
646
|
Rails/I18nLocaleTexts:
|
|
476
647
|
Description: 'Enforces use of I18n and locale files instead of locale specific strings.'
|
|
@@ -478,14 +649,21 @@ Rails/I18nLocaleTexts:
|
|
|
478
649
|
Enabled: pending
|
|
479
650
|
VersionAdded: '2.14'
|
|
480
651
|
|
|
652
|
+
Rails/IgnoredColumnsAssignment:
|
|
653
|
+
Description: 'Looks for assignments of `ignored_columns` that override previous assignments.'
|
|
654
|
+
StyleGuide: 'https://rails.rubystyle.guide/#append-ignored-columns'
|
|
655
|
+
Enabled: pending
|
|
656
|
+
SafeAutoCorrect: false
|
|
657
|
+
VersionAdded: '2.17'
|
|
658
|
+
|
|
481
659
|
Rails/IgnoredSkipActionFilterOption:
|
|
482
660
|
Description: 'Checks that `if` and `only` (or `except`) are not used together as options of `skip_*` action filter.'
|
|
483
661
|
Reference: 'https://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#method-i-_normalize_callback_options'
|
|
484
662
|
Enabled: true
|
|
485
663
|
VersionAdded: '0.63'
|
|
486
664
|
Include:
|
|
487
|
-
- app/controllers/**/*.rb
|
|
488
|
-
- app/mailers/**/*.rb
|
|
665
|
+
- '**/app/controllers/**/*.rb'
|
|
666
|
+
- '**/app/mailers/**/*.rb'
|
|
489
667
|
|
|
490
668
|
Rails/IndexBy:
|
|
491
669
|
Description: 'Prefer `index_by` over `each_with_object`, `to_h`, or `map`.'
|
|
@@ -496,8 +674,9 @@ Rails/IndexBy:
|
|
|
496
674
|
Rails/IndexWith:
|
|
497
675
|
Description: 'Prefer `index_with` over `each_with_object`, `to_h`, or `map`.'
|
|
498
676
|
Enabled: true
|
|
677
|
+
SafeAutoCorrect: false
|
|
499
678
|
VersionAdded: '2.5'
|
|
500
|
-
VersionChanged: '2.
|
|
679
|
+
VersionChanged: '2.33'
|
|
501
680
|
|
|
502
681
|
Rails/Inquiry:
|
|
503
682
|
Description: "Prefer Ruby's comparison operators over Active Support's `Array#inquiry` and `String#inquiry`."
|
|
@@ -507,11 +686,14 @@ Rails/Inquiry:
|
|
|
507
686
|
|
|
508
687
|
Rails/InverseOf:
|
|
509
688
|
Description: 'Checks for associations where the inverse cannot be determined automatically.'
|
|
689
|
+
Reference:
|
|
690
|
+
- https://guides.rubyonrails.org/association_basics.html#bi-directional-associations
|
|
691
|
+
- https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses
|
|
510
692
|
Enabled: true
|
|
511
693
|
VersionAdded: '0.52'
|
|
512
694
|
IgnoreScopes: false
|
|
513
695
|
Include:
|
|
514
|
-
- app/models/**/*.rb
|
|
696
|
+
- '**/app/models/**/*.rb'
|
|
515
697
|
|
|
516
698
|
Rails/LexicallyScopedActionFilter:
|
|
517
699
|
Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the class."
|
|
@@ -520,8 +702,8 @@ Rails/LexicallyScopedActionFilter:
|
|
|
520
702
|
Safe: false
|
|
521
703
|
VersionAdded: '0.52'
|
|
522
704
|
Include:
|
|
523
|
-
- app/controllers/**/*.rb
|
|
524
|
-
- app/mailers/**/*.rb
|
|
705
|
+
- '**/app/controllers/**/*.rb'
|
|
706
|
+
- '**/app/mailers/**/*.rb'
|
|
525
707
|
|
|
526
708
|
Rails/LinkToBlank:
|
|
527
709
|
Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
|
|
@@ -539,7 +721,7 @@ Rails/MailerName:
|
|
|
539
721
|
SafeAutoCorrect: false
|
|
540
722
|
VersionAdded: '2.7'
|
|
541
723
|
Include:
|
|
542
|
-
- app/mailers/**/*.rb
|
|
724
|
+
- '**/app/mailers/**/*.rb'
|
|
543
725
|
|
|
544
726
|
Rails/MatchRoute:
|
|
545
727
|
Description: >-
|
|
@@ -549,15 +731,25 @@ Rails/MatchRoute:
|
|
|
549
731
|
Enabled: 'pending'
|
|
550
732
|
VersionAdded: '2.7'
|
|
551
733
|
Include:
|
|
552
|
-
- config/routes.rb
|
|
553
|
-
- config/routes/**/*.rb
|
|
734
|
+
- '**/config/routes.rb'
|
|
735
|
+
- '**/config/routes/**/*.rb'
|
|
554
736
|
|
|
555
737
|
Rails/MigrationClassName:
|
|
556
738
|
Description: 'The class name of the migration should match its file name.'
|
|
557
739
|
Enabled: pending
|
|
558
740
|
VersionAdded: '2.14'
|
|
741
|
+
VersionChanged: '2.20'
|
|
559
742
|
Include:
|
|
560
|
-
- db
|
|
743
|
+
- db/**/*.rb
|
|
744
|
+
|
|
745
|
+
Rails/MultipleRoutePaths:
|
|
746
|
+
Description: 'Checks for mapping a route with multiple paths, which is deprecated and will be removed in Rails 8.1.'
|
|
747
|
+
Enabled: pending
|
|
748
|
+
Severity: warning
|
|
749
|
+
VersionAdded: '2.29'
|
|
750
|
+
Include:
|
|
751
|
+
- '**/config/routes.rb'
|
|
752
|
+
- '**/config/routes/**/*.rb'
|
|
561
753
|
|
|
562
754
|
Rails/NegateInclude:
|
|
563
755
|
Description: 'Prefer `collection.exclude?(obj)` over `!collection.include?(obj)`.'
|
|
@@ -568,11 +760,22 @@ Rails/NegateInclude:
|
|
|
568
760
|
VersionChanged: '2.9'
|
|
569
761
|
|
|
570
762
|
Rails/NotNullColumn:
|
|
571
|
-
Description: 'Do not add a NOT NULL column without a default value.'
|
|
763
|
+
Description: 'Do not add a NOT NULL column without a default value to existing tables.'
|
|
572
764
|
Enabled: true
|
|
573
765
|
VersionAdded: '0.43'
|
|
766
|
+
VersionChanged: '2.20'
|
|
767
|
+
Database: null
|
|
768
|
+
SupportedDatabases:
|
|
769
|
+
- mysql
|
|
574
770
|
Include:
|
|
575
|
-
- db
|
|
771
|
+
- db/**/*.rb
|
|
772
|
+
|
|
773
|
+
Rails/OrderArguments:
|
|
774
|
+
Description: 'Prefer symbol arguments over strings in `order` method.'
|
|
775
|
+
StyleGuide: 'https://rails.rubystyle.guide/#order-arguments'
|
|
776
|
+
Enabled: pending
|
|
777
|
+
VersionAdded: '2.33'
|
|
778
|
+
Safe: false
|
|
576
779
|
|
|
577
780
|
Rails/OrderById:
|
|
578
781
|
Description: >-
|
|
@@ -589,10 +792,10 @@ Rails/Output:
|
|
|
589
792
|
VersionAdded: '0.15'
|
|
590
793
|
VersionChanged: '0.19'
|
|
591
794
|
Include:
|
|
592
|
-
- app/**/*.rb
|
|
593
|
-
- config/**/*.rb
|
|
795
|
+
- '**/app/**/*.rb'
|
|
796
|
+
- '**/config/**/*.rb'
|
|
594
797
|
- db/**/*.rb
|
|
595
|
-
- lib/**/*.rb
|
|
798
|
+
- '**/lib/**/*.rb'
|
|
596
799
|
|
|
597
800
|
Rails/OutputSafety:
|
|
598
801
|
Description: 'The use of `html_safe` or `raw` may be a security risk.'
|
|
@@ -610,7 +813,9 @@ Rails/Pluck:
|
|
|
610
813
|
Description: 'Prefer `pluck` over `map { ... }`.'
|
|
611
814
|
StyleGuide: 'https://rails.rubystyle.guide#pluck'
|
|
612
815
|
Enabled: 'pending'
|
|
816
|
+
Safe: false
|
|
613
817
|
VersionAdded: '2.7'
|
|
818
|
+
VersionChanged: '2.18'
|
|
614
819
|
|
|
615
820
|
Rails/PluckId:
|
|
616
821
|
Description: 'Use `ids` instead of `pluck(:id)` or `pluck(primary_key)`.'
|
|
@@ -639,6 +844,7 @@ Rails/Presence:
|
|
|
639
844
|
Description: 'Checks code that can be written more easily using `Object#presence` defined by Active Support.'
|
|
640
845
|
Enabled: true
|
|
641
846
|
VersionAdded: '0.52'
|
|
847
|
+
VersionChanged: '2.34'
|
|
642
848
|
|
|
643
849
|
Rails/Present:
|
|
644
850
|
Description: 'Enforces use of `present?`.'
|
|
@@ -662,7 +868,7 @@ Rails/RakeEnvironment:
|
|
|
662
868
|
- '**/Rakefile'
|
|
663
869
|
- '**/*.rake'
|
|
664
870
|
Exclude:
|
|
665
|
-
- 'lib/capistrano/tasks/**/*.rake'
|
|
871
|
+
- '**/lib/capistrano/tasks/**/*.rake'
|
|
666
872
|
|
|
667
873
|
Rails/ReadWriteAttribute:
|
|
668
874
|
Description: >-
|
|
@@ -673,7 +879,25 @@ Rails/ReadWriteAttribute:
|
|
|
673
879
|
VersionAdded: '0.20'
|
|
674
880
|
VersionChanged: '0.29'
|
|
675
881
|
Include:
|
|
676
|
-
- app/models/**/*.rb
|
|
882
|
+
- '**/app/models/**/*.rb'
|
|
883
|
+
|
|
884
|
+
Rails/RedirectBackOrTo:
|
|
885
|
+
Description: >-
|
|
886
|
+
Use `redirect_back_or_to` instead of `redirect_back` with
|
|
887
|
+
`fallback_location` option.
|
|
888
|
+
Enabled: pending
|
|
889
|
+
Severity: warning
|
|
890
|
+
VersionAdded: '2.34'
|
|
891
|
+
|
|
892
|
+
Rails/RedundantActiveRecordAllMethod:
|
|
893
|
+
Description: Detect redundant `all` used as a receiver for Active Record query methods.
|
|
894
|
+
StyleGuide: 'https://rails.rubystyle.guide/#redundant-all'
|
|
895
|
+
Enabled: pending
|
|
896
|
+
Safe: false
|
|
897
|
+
AllowedReceivers:
|
|
898
|
+
- ActionMailer::Preview
|
|
899
|
+
- ActiveSupport::TimeZone
|
|
900
|
+
VersionAdded: '2.21'
|
|
677
901
|
|
|
678
902
|
Rails/RedundantAllowNil:
|
|
679
903
|
Description: >-
|
|
@@ -682,7 +906,7 @@ Rails/RedundantAllowNil:
|
|
|
682
906
|
Enabled: true
|
|
683
907
|
VersionAdded: '0.67'
|
|
684
908
|
Include:
|
|
685
|
-
- app/models/**/*.rb
|
|
909
|
+
- '**/app/models/**/*.rb'
|
|
686
910
|
|
|
687
911
|
Rails/RedundantForeignKey:
|
|
688
912
|
Description: 'Checks for associations where the `:foreign_key` option is redundant.'
|
|
@@ -705,8 +929,8 @@ Rails/RedundantTravelBack:
|
|
|
705
929
|
Enabled: pending
|
|
706
930
|
VersionAdded: '2.12'
|
|
707
931
|
Include:
|
|
708
|
-
- spec/**/*.rb
|
|
709
|
-
- test/**/*.rb
|
|
932
|
+
- '**/spec/**/*.rb'
|
|
933
|
+
- '**/test/**/*.rb'
|
|
710
934
|
|
|
711
935
|
Rails/ReflectionClassName:
|
|
712
936
|
Description: 'Use a string for `class_name` option value in the definition of a reflection.'
|
|
@@ -762,6 +986,18 @@ Rails/RequireDependency:
|
|
|
762
986
|
Enabled: false
|
|
763
987
|
VersionAdded: '2.10'
|
|
764
988
|
|
|
989
|
+
Rails/ResponseParsedBody:
|
|
990
|
+
Description: Prefer `response.parsed_body` to custom parsing logic for `response.body`.
|
|
991
|
+
Enabled: pending
|
|
992
|
+
Safe: false
|
|
993
|
+
VersionAdded: '2.18'
|
|
994
|
+
VersionChanged: '2.19'
|
|
995
|
+
Include:
|
|
996
|
+
- '**/spec/controllers/**/*.rb'
|
|
997
|
+
- '**/spec/requests/**/*.rb'
|
|
998
|
+
- '**/test/controllers/**/*.rb'
|
|
999
|
+
- '**/test/integration/**/*.rb'
|
|
1000
|
+
|
|
765
1001
|
Rails/ReversibleMigration:
|
|
766
1002
|
Description: 'Checks whether the change method of the migration file is reversible.'
|
|
767
1003
|
StyleGuide: 'https://rails.rubystyle.guide#reversible-migration'
|
|
@@ -785,6 +1021,12 @@ Rails/RootJoinChain:
|
|
|
785
1021
|
Enabled: pending
|
|
786
1022
|
VersionAdded: '2.13'
|
|
787
1023
|
|
|
1024
|
+
Rails/RootPathnameMethods:
|
|
1025
|
+
Description: 'Use `Rails.root` IO methods instead of passing it to `File`.'
|
|
1026
|
+
Enabled: pending
|
|
1027
|
+
SafeAutoCorrect: false
|
|
1028
|
+
VersionAdded: '2.16'
|
|
1029
|
+
|
|
788
1030
|
Rails/RootPublicPath:
|
|
789
1031
|
Description: "Favor `Rails.public_path` over `Rails.root` with `'public'`."
|
|
790
1032
|
Enabled: pending
|
|
@@ -835,7 +1077,13 @@ Rails/ScopeArgs:
|
|
|
835
1077
|
VersionAdded: '0.19'
|
|
836
1078
|
VersionChanged: '2.12'
|
|
837
1079
|
Include:
|
|
838
|
-
- app/models/**/*.rb
|
|
1080
|
+
- '**/app/models/**/*.rb'
|
|
1081
|
+
|
|
1082
|
+
Rails/SelectMap:
|
|
1083
|
+
Description: 'Checks for uses of `select(:column_name)` with `map(&:column_name)`.'
|
|
1084
|
+
Enabled: pending
|
|
1085
|
+
Safe: false
|
|
1086
|
+
VersionAdded: '2.21'
|
|
839
1087
|
|
|
840
1088
|
Rails/ShortI18n:
|
|
841
1089
|
Description: 'Use the short form of the I18n methods: `t` instead of `translate` and `l` instead of `localize`.'
|
|
@@ -853,8 +1101,9 @@ Rails/SkipsModelValidations:
|
|
|
853
1101
|
See reference for more information.
|
|
854
1102
|
Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
|
|
855
1103
|
Enabled: true
|
|
1104
|
+
Safe: false
|
|
856
1105
|
VersionAdded: '0.47'
|
|
857
|
-
VersionChanged: '2.
|
|
1106
|
+
VersionChanged: '2.25'
|
|
858
1107
|
ForbiddenMethods:
|
|
859
1108
|
- decrement!
|
|
860
1109
|
- decrement_counter
|
|
@@ -892,6 +1141,15 @@ Rails/StripHeredoc:
|
|
|
892
1141
|
Enabled: pending
|
|
893
1142
|
VersionAdded: '2.15'
|
|
894
1143
|
|
|
1144
|
+
Rails/StrongParametersExpect:
|
|
1145
|
+
Description: 'Enforces the use of `ActionController::Parameters#expect` as a method for strong parameter handling.'
|
|
1146
|
+
Reference: 'https://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-expect'
|
|
1147
|
+
Enabled: pending
|
|
1148
|
+
Include:
|
|
1149
|
+
- '**/app/controllers/**/*.rb'
|
|
1150
|
+
SafeAutoCorrect: false
|
|
1151
|
+
VersionAdded: '2.29'
|
|
1152
|
+
|
|
895
1153
|
Rails/TableNameAssignment:
|
|
896
1154
|
Description: >-
|
|
897
1155
|
Do not use `self.table_name =`. Use Inflections or `table_name_prefix` instead.
|
|
@@ -899,12 +1157,20 @@ Rails/TableNameAssignment:
|
|
|
899
1157
|
Enabled: false
|
|
900
1158
|
VersionAdded: '2.14'
|
|
901
1159
|
Include:
|
|
902
|
-
- app/models/**/*.rb
|
|
1160
|
+
- '**/app/models/**/*.rb'
|
|
1161
|
+
|
|
1162
|
+
Rails/ThreeStateBooleanColumn:
|
|
1163
|
+
Description: 'Add a default value and a `NOT NULL` constraint to boolean columns.'
|
|
1164
|
+
StyleGuide: 'https://rails.rubystyle.guide/#three-state-boolean'
|
|
1165
|
+
Enabled: pending
|
|
1166
|
+
VersionAdded: '2.19'
|
|
1167
|
+
Include:
|
|
1168
|
+
- db/**/*.rb
|
|
903
1169
|
|
|
904
1170
|
Rails/TimeZone:
|
|
905
1171
|
Description: 'Checks the correct usage of time zone aware methods.'
|
|
906
1172
|
StyleGuide: 'https://rails.rubystyle.guide#time'
|
|
907
|
-
Reference: '
|
|
1173
|
+
Reference: 'https://danilenko.org/2012/7/6/rails_timezones'
|
|
908
1174
|
Enabled: true
|
|
909
1175
|
SafeAutoCorrect: false
|
|
910
1176
|
VersionAdded: '0.30'
|
|
@@ -924,8 +1190,8 @@ Rails/TimeZoneAssignment:
|
|
|
924
1190
|
Enabled: 'pending'
|
|
925
1191
|
VersionAdded: '2.10'
|
|
926
1192
|
Include:
|
|
927
|
-
- spec/**/*.rb
|
|
928
|
-
- test/**/*.rb
|
|
1193
|
+
- '**/spec/**/*.rb'
|
|
1194
|
+
- '**/test/**/*.rb'
|
|
929
1195
|
|
|
930
1196
|
Rails/ToFormattedS:
|
|
931
1197
|
Description: 'Checks for consistent uses of `to_fs` or `to_formatted_s`.'
|
|
@@ -937,10 +1203,27 @@ Rails/ToFormattedS:
|
|
|
937
1203
|
- to_formatted_s
|
|
938
1204
|
VersionAdded: '2.15'
|
|
939
1205
|
|
|
1206
|
+
Rails/ToSWithArgument:
|
|
1207
|
+
Description: 'Identifies passing any argument to `#to_s`.'
|
|
1208
|
+
Enabled: pending
|
|
1209
|
+
Safe: false
|
|
1210
|
+
VersionAdded: '2.16'
|
|
1211
|
+
|
|
1212
|
+
Rails/TopLevelHashWithIndifferentAccess:
|
|
1213
|
+
Description: 'Identifies top-level `HashWithIndifferentAccess`.'
|
|
1214
|
+
Reference: 'https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#top-level-hashwithindifferentaccess-is-soft-deprecated'
|
|
1215
|
+
Enabled: pending
|
|
1216
|
+
Severity: warning
|
|
1217
|
+
VersionAdded: '2.16'
|
|
1218
|
+
VersionChanged: '2.18'
|
|
1219
|
+
|
|
940
1220
|
Rails/TransactionExitStatement:
|
|
941
1221
|
Description: 'Avoid the usage of `return`, `break` and `throw` in transaction blocks.'
|
|
1222
|
+
Reference:
|
|
1223
|
+
- https://github.com/rails/rails/commit/15aa4200e083
|
|
942
1224
|
Enabled: pending
|
|
943
1225
|
VersionAdded: '2.14'
|
|
1226
|
+
TransactionMethods: []
|
|
944
1227
|
|
|
945
1228
|
Rails/UniqBeforePluck:
|
|
946
1229
|
Description: 'Prefer the use of uniq or distinct before pluck.'
|
|
@@ -958,12 +1241,14 @@ Rails/UniqueValidationWithoutIndex:
|
|
|
958
1241
|
Enabled: true
|
|
959
1242
|
VersionAdded: '2.5'
|
|
960
1243
|
Include:
|
|
961
|
-
- app/models/**/*.rb
|
|
1244
|
+
- '**/app/models/**/*.rb'
|
|
962
1245
|
|
|
963
1246
|
Rails/UnknownEnv:
|
|
964
1247
|
Description: 'Use correct environment name.'
|
|
965
1248
|
Enabled: true
|
|
1249
|
+
Severity: warning
|
|
966
1250
|
VersionAdded: '0.51'
|
|
1251
|
+
VersionChanged: '2.18'
|
|
967
1252
|
Environments:
|
|
968
1253
|
- development
|
|
969
1254
|
- test
|
|
@@ -971,10 +1256,17 @@ Rails/UnknownEnv:
|
|
|
971
1256
|
|
|
972
1257
|
Rails/UnusedIgnoredColumns:
|
|
973
1258
|
Description: 'Remove a column that does not exist from `ignored_columns`.'
|
|
974
|
-
Enabled:
|
|
1259
|
+
Enabled: false
|
|
975
1260
|
VersionAdded: '2.11'
|
|
1261
|
+
VersionChanged: '2.25'
|
|
976
1262
|
Include:
|
|
977
|
-
- app/models/**/*.rb
|
|
1263
|
+
- '**/app/models/**/*.rb'
|
|
1264
|
+
|
|
1265
|
+
Rails/UnusedRenderContent:
|
|
1266
|
+
Description: 'Do not specify body content for a response with a non-content status code.'
|
|
1267
|
+
Enabled: pending
|
|
1268
|
+
Severity: warning
|
|
1269
|
+
VersionAdded: '2.21'
|
|
978
1270
|
|
|
979
1271
|
Rails/Validation:
|
|
980
1272
|
Description: 'Use validates :attribute, hash of validations.'
|
|
@@ -982,15 +1274,15 @@ Rails/Validation:
|
|
|
982
1274
|
VersionAdded: '0.9'
|
|
983
1275
|
VersionChanged: '0.41'
|
|
984
1276
|
Include:
|
|
985
|
-
- app/models/**/*.rb
|
|
1277
|
+
- '**/app/models/**/*.rb'
|
|
986
1278
|
|
|
987
1279
|
Rails/WhereEquals:
|
|
988
|
-
Description: 'Pass conditions to `where` as a hash instead of manually constructing SQL.'
|
|
1280
|
+
Description: 'Pass conditions to `where` and `where.not` as a hash instead of manually constructing SQL.'
|
|
989
1281
|
StyleGuide: 'https://rails.rubystyle.guide/#hash-conditions'
|
|
990
1282
|
Enabled: 'pending'
|
|
991
1283
|
SafeAutoCorrect: false
|
|
992
1284
|
VersionAdded: '2.9'
|
|
993
|
-
VersionChanged: '2.
|
|
1285
|
+
VersionChanged: '2.26'
|
|
994
1286
|
|
|
995
1287
|
Rails/WhereExists:
|
|
996
1288
|
Description: 'Prefer `exists?(...)` over `where(...).exists?`.'
|
|
@@ -1003,12 +1295,55 @@ Rails/WhereExists:
|
|
|
1003
1295
|
VersionAdded: '2.7'
|
|
1004
1296
|
VersionChanged: '2.10'
|
|
1005
1297
|
|
|
1298
|
+
Rails/WhereMissing:
|
|
1299
|
+
Description: 'Use `where.missing(...)` to find missing relationship records.'
|
|
1300
|
+
StyleGuide: 'https://rails.rubystyle.guide/#finding-missing-relationship-records'
|
|
1301
|
+
Enabled: pending
|
|
1302
|
+
VersionAdded: '2.16'
|
|
1303
|
+
|
|
1006
1304
|
Rails/WhereNot:
|
|
1007
1305
|
Description: 'Use `where.not(...)` instead of manually constructing negated SQL in `where`.'
|
|
1008
1306
|
StyleGuide: 'https://rails.rubystyle.guide/#hash-conditions'
|
|
1009
1307
|
Enabled: 'pending'
|
|
1010
1308
|
VersionAdded: '2.8'
|
|
1011
1309
|
|
|
1310
|
+
Rails/WhereNotWithMultipleConditions:
|
|
1311
|
+
Description: 'Do not use `where.not(...)` with multiple conditions.'
|
|
1312
|
+
StyleGuide: 'https://rails.rubystyle.guide/#where-not-with-multiple-attributes'
|
|
1313
|
+
Enabled: 'pending'
|
|
1314
|
+
Severity: warning
|
|
1315
|
+
VersionAdded: '2.17'
|
|
1316
|
+
VersionChanged: '2.18'
|
|
1317
|
+
|
|
1318
|
+
Rails/WhereRange:
|
|
1319
|
+
Description: 'Use ranges in `where` instead of manually constructing SQL.'
|
|
1320
|
+
StyleGuide: 'https://rails.rubystyle.guide/#where-ranges'
|
|
1321
|
+
Enabled: pending
|
|
1322
|
+
SafeAutoCorrect: false
|
|
1323
|
+
VersionAdded: '2.25'
|
|
1324
|
+
|
|
1012
1325
|
# Accept `redirect_to(...) and return` and similar cases.
|
|
1013
1326
|
Style/AndOr:
|
|
1014
1327
|
EnforcedStyle: conditionals
|
|
1328
|
+
|
|
1329
|
+
Style/CollectionCompact:
|
|
1330
|
+
AllowedReceivers:
|
|
1331
|
+
- params
|
|
1332
|
+
|
|
1333
|
+
Style/FormatStringToken:
|
|
1334
|
+
AllowedMethods:
|
|
1335
|
+
- redirect
|
|
1336
|
+
|
|
1337
|
+
Style/InvertibleUnlessCondition:
|
|
1338
|
+
InverseMethods:
|
|
1339
|
+
# Active Support defines some common inverse methods. They are listed below:
|
|
1340
|
+
:present?: :blank?
|
|
1341
|
+
:blank?: :present?
|
|
1342
|
+
:include?: :exclude?
|
|
1343
|
+
:exclude?: :include?
|
|
1344
|
+
|
|
1345
|
+
Style/SymbolProc:
|
|
1346
|
+
AllowedMethods:
|
|
1347
|
+
- define_method
|
|
1348
|
+
- mail
|
|
1349
|
+
- respond_to
|