rubocop-rails 2.25.1 → 2.32.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 +60 -8
- data/config/default.yml +103 -51
- data/lib/rubocop/cop/mixin/active_record_helper.rb +2 -2
- data/lib/rubocop/cop/mixin/active_record_migrations_helper.rb +2 -2
- data/lib/rubocop/cop/mixin/database_type_resolvable.rb +2 -2
- data/lib/rubocop/cop/mixin/enforce_superclass.rb +6 -1
- data/lib/rubocop/cop/mixin/index_method.rb +69 -61
- data/lib/rubocop/cop/mixin/routes_helper.rb +20 -0
- data/lib/rubocop/cop/mixin/target_rails_version.rb +3 -5
- data/lib/rubocop/cop/rails/action_order.rb +1 -5
- data/lib/rubocop/cop/rails/active_record_callbacks_order.rb +1 -5
- data/lib/rubocop/cop/rails/add_column_index.rb +1 -0
- data/lib/rubocop/cop/rails/application_record.rb +4 -0
- data/lib/rubocop/cop/rails/arel_star.rb +5 -5
- data/lib/rubocop/cop/rails/belongs_to.rb +1 -1
- data/lib/rubocop/cop/rails/blank.rb +1 -1
- data/lib/rubocop/cop/rails/bulk_change_table.rb +3 -2
- data/lib/rubocop/cop/rails/compact_blank.rb +29 -8
- data/lib/rubocop/cop/rails/content_tag.rb +1 -1
- data/lib/rubocop/cop/rails/dangerous_column_names.rb +2 -0
- data/lib/rubocop/cop/rails/date.rb +2 -2
- data/lib/rubocop/cop/rails/delegate.rb +53 -7
- data/lib/rubocop/cop/rails/duplicate_association.rb +8 -4
- data/lib/rubocop/cop/rails/eager_evaluation_log_message.rb +1 -3
- 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 +29 -7
- data/lib/rubocop/cop/rails/env_local.rb +26 -3
- data/lib/rubocop/cop/rails/file_path.rb +62 -10
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +7 -0
- data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +1 -1
- data/lib/rubocop/cop/rails/index_by.rb +37 -12
- data/lib/rubocop/cop/rails/index_with.rb +37 -12
- data/lib/rubocop/cop/rails/inquiry.rb +1 -1
- data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +11 -1
- data/lib/rubocop/cop/rails/match_route.rb +1 -9
- data/lib/rubocop/cop/rails/multiple_route_paths.rb +50 -0
- data/lib/rubocop/cop/rails/not_null_column.rb +6 -2
- data/lib/rubocop/cop/rails/output.rb +1 -2
- data/lib/rubocop/cop/rails/pluck.rb +30 -4
- data/lib/rubocop/cop/rails/pluck_in_where.rb +17 -8
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +30 -16
- data/lib/rubocop/cop/rails/presence.rb +1 -1
- data/lib/rubocop/cop/rails/present.rb +1 -3
- data/lib/rubocop/cop/rails/redundant_active_record_all_method.rb +1 -30
- data/lib/rubocop/cop/rails/redundant_foreign_key.rb +1 -1
- data/lib/rubocop/cop/rails/redundant_presence_validation_on_belongs_to.rb +9 -0
- data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +7 -2
- data/lib/rubocop/cop/rails/reflection_class_name.rb +3 -3
- data/lib/rubocop/cop/rails/relative_date_constant.rb +1 -1
- data/lib/rubocop/cop/rails/render_plain_text.rb +6 -3
- data/lib/rubocop/cop/rails/request_referer.rb +1 -1
- data/lib/rubocop/cop/rails/reversible_migration.rb +4 -1
- data/lib/rubocop/cop/rails/root_pathname_methods.rb +21 -12
- data/lib/rubocop/cop/rails/save_bang.rb +8 -7
- data/lib/rubocop/cop/rails/schema_comment.rb +2 -1
- data/lib/rubocop/cop/rails/select_map.rb +3 -2
- data/lib/rubocop/cop/rails/skips_model_validations.rb +5 -3
- data/lib/rubocop/cop/rails/squished_sql_heredocs.rb +1 -1
- data/lib/rubocop/cop/rails/strip_heredoc.rb +1 -1
- data/lib/rubocop/cop/rails/strong_parameters_expect.rb +104 -0
- data/lib/rubocop/cop/rails/three_state_boolean_column.rb +3 -2
- data/lib/rubocop/cop/rails/time_zone.rb +16 -7
- data/lib/rubocop/cop/rails/transaction_exit_statement.rb +7 -2
- data/lib/rubocop/cop/rails/uniq_before_pluck.rb +10 -33
- data/lib/rubocop/cop/rails/unique_validation_without_index.rb +1 -1
- data/lib/rubocop/cop/rails/validation.rb +1 -1
- data/lib/rubocop/cop/rails/where_equals.rb +28 -12
- data/lib/rubocop/cop/rails/where_not.rb +11 -6
- data/lib/rubocop/cop/rails/where_range.rb +7 -2
- data/lib/rubocop/cop/rails_cops.rb +4 -0
- data/lib/rubocop/rails/migration_file_skippable.rb +54 -0
- data/lib/rubocop/rails/plugin.rb +48 -0
- data/lib/rubocop/rails/version.rb +1 -1
- data/lib/rubocop/rails.rb +1 -8
- data/lib/rubocop-rails.rb +4 -5
- metadata +29 -12
- data/lib/rubocop/rails/inject.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '009a04a87f7692e278ce16b061ff93814ada6644691ce2fdd4ac4c7659e68c4d'
|
4
|
+
data.tar.gz: 313e26b30279cf9ebba24f5f99bc78b2b44433b24bc3522a6d4261de1cf72282
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f7397609be46c75da8ff050ed1325db850c39df7d097d9faeb6984162b706ed92e203f151a30a68aa41b3af8fcdd63b7e76c51ebdcfe31980129a853d7cd8a3
|
7
|
+
data.tar.gz: 46006ebeb148838e1ae7f3dc56614b261fc90779c5e3772e163c9431034a89dbc614ef1cb1b913d5236fbc2b04708643fc27b593d8c0c4147898271c045cb4c7
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,8 @@
|
|
5
5
|
|
6
6
|
A [RuboCop](https://github.com/rubocop/rubocop) extension focused on enforcing Rails best practices and coding conventions.
|
7
7
|
|
8
|
-
|
8
|
+
> [!IMPORTANT]
|
9
|
+
> This repository manages rubocop-rails gem (>= 2.0.0). rubocop-rails gem (<= 1.5.0) has been renamed to [rubocop-rails_config](https://rubygems.org/gems/rubocop-rails_config) gem.
|
9
10
|
|
10
11
|
## Installation
|
11
12
|
|
@@ -31,13 +32,13 @@ ways to do this:
|
|
31
32
|
Put this into your `.rubocop.yml`.
|
32
33
|
|
33
34
|
```yaml
|
34
|
-
|
35
|
+
plugins: rubocop-rails
|
35
36
|
```
|
36
37
|
|
37
38
|
Alternatively, use the following array notation when specifying multiple extensions.
|
38
39
|
|
39
40
|
```yaml
|
40
|
-
|
41
|
+
plugins:
|
41
42
|
- rubocop-other-extension
|
42
43
|
- rubocop-rails
|
43
44
|
```
|
@@ -45,27 +46,64 @@ require:
|
|
45
46
|
Now you can run `rubocop` and it will automatically load the RuboCop Rails
|
46
47
|
cops together with the standard cops.
|
47
48
|
|
49
|
+
> [!NOTE]
|
50
|
+
> The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
|
51
|
+
|
48
52
|
### Command line
|
49
53
|
|
50
54
|
```sh
|
51
|
-
$ rubocop --
|
55
|
+
$ rubocop --plugin rubocop-rails
|
52
56
|
```
|
53
57
|
|
54
|
-
Note: `--rails` option is required while `rubocop` command supports `--rails` option.
|
55
|
-
|
56
58
|
### Rake task
|
57
59
|
|
58
60
|
```ruby
|
59
61
|
require 'rubocop/rake_task'
|
60
62
|
|
61
63
|
RuboCop::RakeTask.new do |task|
|
62
|
-
task.
|
64
|
+
task.plugins << 'rubocop-rails'
|
63
65
|
end
|
64
66
|
```
|
65
67
|
|
68
|
+
## RuboCop Rails configuration
|
69
|
+
|
70
|
+
The following settings specific to RuboCop Rails can be configured in `.rubocop.yml`.
|
71
|
+
|
72
|
+
### `AllCops: TargetRailsVersion`
|
73
|
+
|
74
|
+
What version of Rails is the inspected code using? If a value is specified
|
75
|
+
for `TargetRailsVersion` then it is used. Acceptable values are specified
|
76
|
+
as a float (e.g., 7.2); the patch version of Rails should not be included.
|
77
|
+
|
78
|
+
```yaml
|
79
|
+
AllCops:
|
80
|
+
TargetRailsVersion: 7.2
|
81
|
+
```
|
82
|
+
|
83
|
+
If `TargetRailsVersion` is not set, RuboCop will parse the Gemfile.lock or
|
84
|
+
gems.locked file to find the version of Rails that has been bound to the
|
85
|
+
application. If neither of those files exist, RuboCop will use Rails 5.0
|
86
|
+
as the default.
|
87
|
+
|
88
|
+
### `AllCops: MigratedSchemaVersion`
|
89
|
+
|
90
|
+
By specifying the `MigratedSchemaVersion` option, migration files that have already been run can be ignored.
|
91
|
+
When `MigratedSchemaVersion: '20241225000000'` is set, migration files lower than or equal to '20241225000000' will be ignored.
|
92
|
+
For example, to ignore db/migrate/20241225000000_create_articles.rb and earlier migrations you would configure it the following way:
|
93
|
+
|
94
|
+
```yaml
|
95
|
+
AllCops:
|
96
|
+
MigratedSchemaVersion: '20241225000000'
|
97
|
+
```
|
98
|
+
|
99
|
+
This prevents inspecting schema settings for already applied migration files.
|
100
|
+
Changing already applied migrations should be avoided because it can lead to the schema getting out of sync
|
101
|
+
between your local copy and what it actually is in production, depending on when `bin/rails db:migrate` was executed.
|
102
|
+
If you want to modify your schema to comply with the cops, you should instead create new migrations.
|
103
|
+
|
66
104
|
## Rails configuration tip
|
67
105
|
|
68
|
-
|
106
|
+
In Rails 6.1+, add the following `config.generators.after_generate` setting to
|
69
107
|
your `config/environments/development.rb` to apply RuboCop autocorrection to code generated by `bin/rails g`.
|
70
108
|
|
71
109
|
```ruby
|
@@ -84,6 +122,20 @@ It uses `rubocop -A` to apply `Style/FrozenStringLiteralComment` and other unsaf
|
|
84
122
|
`rubocop -A` is unsafe autocorrection, but code generated by default is simple and less likely to
|
85
123
|
be incompatible with `rubocop -A`. If you have problems you can replace it with `rubocop -a` instead.
|
86
124
|
|
125
|
+
In Rails 7.2+, it is recommended to use `config.generators.apply_rubocop_autocorrect_after_generate!` instead of the above setting:
|
126
|
+
|
127
|
+
```diff
|
128
|
+
# config/environments/development.rb
|
129
|
+
Rails.application.configure do
|
130
|
+
(snip)
|
131
|
+
# Apply autocorrection by RuboCop to files generated by `bin/rails generate`.
|
132
|
+
- # config.generators.apply_rubocop_autocorrect_after_generate!
|
133
|
+
+ config.generators.apply_rubocop_autocorrect_after_generate!
|
134
|
+
end
|
135
|
+
```
|
136
|
+
|
137
|
+
You only need to uncomment.
|
138
|
+
|
87
139
|
## The Cops
|
88
140
|
|
89
141
|
All cops are located under
|
data/config/default.yml
CHANGED
@@ -6,7 +6,7 @@ inherit_mode:
|
|
6
6
|
|
7
7
|
AllCops:
|
8
8
|
Exclude:
|
9
|
-
- app/assets/**/*
|
9
|
+
- '**/app/assets/**/*'
|
10
10
|
- bin/*
|
11
11
|
# Exclude db/schema.rb and db/[CONFIGURATION_NAMESPACE]_schema.rb by default.
|
12
12
|
# See: https://guides.rubyonrails.org/active_record_multiple_databases.html#setting-up-your-application
|
@@ -17,14 +17,18 @@ AllCops:
|
|
17
17
|
# Enable checking Active Support extensions.
|
18
18
|
# See: https://docs.rubocop.org/rubocop/configuration.html#enable-checking-active-support-extensions
|
19
19
|
ActiveSupportExtensionsEnabled: true
|
20
|
-
# What version of Rails is the inspected code using?
|
21
|
-
# for TargetRailsVersion then it is used.
|
22
|
-
# as a float (
|
23
|
-
# If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or
|
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
|
24
24
|
# gems.locked file to find the version of Rails that has been bound to the
|
25
|
-
# application.
|
25
|
+
# application. If neither of those files exist, RuboCop will use Rails 5.0
|
26
26
|
# as the default.
|
27
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.
|
28
32
|
|
29
33
|
Lint/NumberConversion:
|
30
34
|
# Add Rails' duration methods to the ignore list for `Lint/NumberConversion`
|
@@ -73,6 +77,20 @@ Lint/SafeNavigationChain:
|
|
73
77
|
- try!
|
74
78
|
- in?
|
75
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
|
+
|
76
94
|
Rails:
|
77
95
|
Enabled: true
|
78
96
|
DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails
|
@@ -103,8 +121,8 @@ Rails/ActionFilter:
|
|
103
121
|
- action
|
104
122
|
- filter
|
105
123
|
Include:
|
106
|
-
- app/controllers/**/*.rb
|
107
|
-
- app/mailers/**/*.rb
|
124
|
+
- '**/app/controllers/**/*.rb'
|
125
|
+
- '**/app/mailers/**/*.rb'
|
108
126
|
|
109
127
|
Rails/ActionOrder:
|
110
128
|
Description: 'Enforce consistent ordering of controller actions.'
|
@@ -119,7 +137,7 @@ Rails/ActionOrder:
|
|
119
137
|
- update
|
120
138
|
- destroy
|
121
139
|
Include:
|
122
|
-
- app/controllers/**/*.rb
|
140
|
+
- '**/app/controllers/**/*.rb'
|
123
141
|
|
124
142
|
Rails/ActiveRecordAliases:
|
125
143
|
Description: >-
|
@@ -136,7 +154,7 @@ Rails/ActiveRecordCallbacksOrder:
|
|
136
154
|
Enabled: 'pending'
|
137
155
|
VersionAdded: '2.7'
|
138
156
|
Include:
|
139
|
-
- app/models/**/*.rb
|
157
|
+
- '**/app/models/**/*.rb'
|
140
158
|
|
141
159
|
Rails/ActiveRecordOverride:
|
142
160
|
Description: >-
|
@@ -147,7 +165,7 @@ Rails/ActiveRecordOverride:
|
|
147
165
|
VersionAdded: '0.67'
|
148
166
|
VersionChanged: '2.18'
|
149
167
|
Include:
|
150
|
-
- app/models/**/*.rb
|
168
|
+
- '**/app/models/**/*.rb'
|
151
169
|
|
152
170
|
Rails/ActiveSupportAliases:
|
153
171
|
Description: >-
|
@@ -212,7 +230,9 @@ Rails/ApplicationRecord:
|
|
212
230
|
Enabled: true
|
213
231
|
SafeAutoCorrect: false
|
214
232
|
VersionAdded: '0.49'
|
215
|
-
VersionChanged: '2.
|
233
|
+
VersionChanged: '2.26'
|
234
|
+
Exclude:
|
235
|
+
- db/**/*.rb
|
216
236
|
|
217
237
|
Rails/ArelStar:
|
218
238
|
Description: 'Enforces `Arel.star` instead of `"*"` for expanded columns.'
|
@@ -232,7 +252,7 @@ Rails/AttributeDefaultBlockValue:
|
|
232
252
|
Enabled: pending
|
233
253
|
VersionAdded: '2.9'
|
234
254
|
Include:
|
235
|
-
- 'app/models/**/*'
|
255
|
+
- '**/app/models/**/*'
|
236
256
|
|
237
257
|
Rails/BelongsTo:
|
238
258
|
Description: >-
|
@@ -291,8 +311,8 @@ Rails/ContentTag:
|
|
291
311
|
# https://puma.io/puma/Puma/DSL.html#tag-instance_method
|
292
312
|
# No helpers are used in normal models and configs.
|
293
313
|
Exclude:
|
294
|
-
- app/models/**/*.rb
|
295
|
-
- config/**/*.rb
|
314
|
+
- '**/app/models/**/*.rb'
|
315
|
+
- '**/config/**/*.rb'
|
296
316
|
|
297
317
|
Rails/CreateTableWithTimestamps:
|
298
318
|
Description: >-
|
@@ -347,11 +367,13 @@ Rails/Delegate:
|
|
347
367
|
Description: 'Prefer delegate method for delegations.'
|
348
368
|
Enabled: true
|
349
369
|
VersionAdded: '0.21'
|
350
|
-
VersionChanged: '
|
370
|
+
VersionChanged: '2.30'
|
351
371
|
# When set to true, using the target object as a prefix of the
|
352
372
|
# method name without using the `delegate` method will be a
|
353
373
|
# violation. When set to false, this case is legal.
|
354
374
|
EnforceForPrefixed: true
|
375
|
+
Exclude:
|
376
|
+
- '**/app/controllers/**/*.rb'
|
355
377
|
|
356
378
|
Rails/DelegateAllowBlank:
|
357
379
|
Description: 'Do not use allow_blank as an option to delegate.'
|
@@ -422,14 +444,22 @@ Rails/EnumHash:
|
|
422
444
|
Enabled: true
|
423
445
|
VersionAdded: '2.3'
|
424
446
|
Include:
|
425
|
-
- app/models/**/*.rb
|
447
|
+
- '**/app/models/**/*.rb'
|
448
|
+
|
449
|
+
Rails/EnumSyntax:
|
450
|
+
Description: 'Use positional arguments over keyword arguments when defining enums.'
|
451
|
+
Enabled: pending
|
452
|
+
Severity: warning
|
453
|
+
VersionAdded: '2.26'
|
454
|
+
Include:
|
455
|
+
- '**/app/models/**/*.rb'
|
426
456
|
|
427
457
|
Rails/EnumUniqueness:
|
428
458
|
Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
|
429
459
|
Enabled: true
|
430
460
|
VersionAdded: '0.46'
|
431
461
|
Include:
|
432
|
-
- app/models/**/*.rb
|
462
|
+
- '**/app/models/**/*.rb'
|
433
463
|
|
434
464
|
Rails/EnvLocal:
|
435
465
|
Description: 'Use `Rails.env.local?` instead of `Rails.env.development? || Rails.env.test?`.'
|
@@ -448,11 +478,11 @@ Rails/EnvironmentVariableAccess:
|
|
448
478
|
VersionAdded: '2.10'
|
449
479
|
VersionChanged: '2.24'
|
450
480
|
Include:
|
451
|
-
- app/**/*.rb
|
452
|
-
- config/initializers/**/*.rb
|
453
|
-
- lib/**/*.rb
|
481
|
+
- '**/app/**/*.rb'
|
482
|
+
- '**/config/initializers/**/*.rb'
|
483
|
+
- '**/lib/**/*.rb'
|
454
484
|
Exclude:
|
455
|
-
- lib/**/*.rake
|
485
|
+
- '**/lib/**/*.rake'
|
456
486
|
AllowReads: false
|
457
487
|
AllowWrites: false
|
458
488
|
|
@@ -464,11 +494,11 @@ Rails/Exit:
|
|
464
494
|
Enabled: true
|
465
495
|
VersionAdded: '0.41'
|
466
496
|
Include:
|
467
|
-
- app/**/*.rb
|
468
|
-
- config/**/*.rb
|
469
|
-
- lib/**/*.rb
|
497
|
+
- '**/app/**/*.rb'
|
498
|
+
- '**/config/**/*.rb'
|
499
|
+
- '**/lib/**/*.rb'
|
470
500
|
Exclude:
|
471
|
-
- lib/**/*.rake
|
501
|
+
- '**/lib/**/*.rake'
|
472
502
|
|
473
503
|
Rails/ExpandedDateRange:
|
474
504
|
Description: 'Checks for expanded date range.'
|
@@ -530,7 +560,7 @@ Rails/HasAndBelongsToMany:
|
|
530
560
|
Enabled: true
|
531
561
|
VersionAdded: '0.12'
|
532
562
|
Include:
|
533
|
-
- app/models/**/*.rb
|
563
|
+
- '**/app/models/**/*.rb'
|
534
564
|
|
535
565
|
Rails/HasManyOrHasOneDependent:
|
536
566
|
Description: 'Define the dependent option to the has_many and has_one associations.'
|
@@ -538,14 +568,14 @@ Rails/HasManyOrHasOneDependent:
|
|
538
568
|
Enabled: true
|
539
569
|
VersionAdded: '0.50'
|
540
570
|
Include:
|
541
|
-
- app/models/**/*.rb
|
571
|
+
- '**/app/models/**/*.rb'
|
542
572
|
|
543
573
|
Rails/HelperInstanceVariable:
|
544
574
|
Description: 'Do not use instance variables in helpers.'
|
545
575
|
Enabled: true
|
546
576
|
VersionAdded: '2.0'
|
547
577
|
Include:
|
548
|
-
- app/helpers/**/*.rb
|
578
|
+
- '**/app/helpers/**/*.rb'
|
549
579
|
|
550
580
|
Rails/HttpPositionalArguments:
|
551
581
|
Description: 'Use keyword arguments instead of positional arguments in http method calls.'
|
@@ -576,7 +606,7 @@ Rails/I18nLazyLookup:
|
|
576
606
|
- lazy
|
577
607
|
- explicit
|
578
608
|
Include:
|
579
|
-
- 'app/controllers/**/*.rb'
|
609
|
+
- '**/app/controllers/**/*.rb'
|
580
610
|
|
581
611
|
Rails/I18nLocaleAssignment:
|
582
612
|
Description: 'Prefer the usage of `I18n.with_locale` instead of manually updating `I18n.locale` value.'
|
@@ -605,8 +635,8 @@ Rails/IgnoredSkipActionFilterOption:
|
|
605
635
|
Enabled: true
|
606
636
|
VersionAdded: '0.63'
|
607
637
|
Include:
|
608
|
-
- app/controllers/**/*.rb
|
609
|
-
- app/mailers/**/*.rb
|
638
|
+
- '**/app/controllers/**/*.rb'
|
639
|
+
- '**/app/mailers/**/*.rb'
|
610
640
|
|
611
641
|
Rails/IndexBy:
|
612
642
|
Description: 'Prefer `index_by` over `each_with_object`, `to_h`, or `map`.'
|
@@ -635,7 +665,7 @@ Rails/InverseOf:
|
|
635
665
|
VersionAdded: '0.52'
|
636
666
|
IgnoreScopes: false
|
637
667
|
Include:
|
638
|
-
- app/models/**/*.rb
|
668
|
+
- '**/app/models/**/*.rb'
|
639
669
|
|
640
670
|
Rails/LexicallyScopedActionFilter:
|
641
671
|
Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the class."
|
@@ -644,8 +674,8 @@ Rails/LexicallyScopedActionFilter:
|
|
644
674
|
Safe: false
|
645
675
|
VersionAdded: '0.52'
|
646
676
|
Include:
|
647
|
-
- app/controllers/**/*.rb
|
648
|
-
- app/mailers/**/*.rb
|
677
|
+
- '**/app/controllers/**/*.rb'
|
678
|
+
- '**/app/mailers/**/*.rb'
|
649
679
|
|
650
680
|
Rails/LinkToBlank:
|
651
681
|
Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
|
@@ -663,7 +693,7 @@ Rails/MailerName:
|
|
663
693
|
SafeAutoCorrect: false
|
664
694
|
VersionAdded: '2.7'
|
665
695
|
Include:
|
666
|
-
- app/mailers/**/*.rb
|
696
|
+
- '**/app/mailers/**/*.rb'
|
667
697
|
|
668
698
|
Rails/MatchRoute:
|
669
699
|
Description: >-
|
@@ -673,8 +703,8 @@ Rails/MatchRoute:
|
|
673
703
|
Enabled: 'pending'
|
674
704
|
VersionAdded: '2.7'
|
675
705
|
Include:
|
676
|
-
- config/routes.rb
|
677
|
-
- config/routes/**/*.rb
|
706
|
+
- '**/config/routes.rb'
|
707
|
+
- '**/config/routes/**/*.rb'
|
678
708
|
|
679
709
|
Rails/MigrationClassName:
|
680
710
|
Description: 'The class name of the migration should match its file name.'
|
@@ -684,6 +714,15 @@ Rails/MigrationClassName:
|
|
684
714
|
Include:
|
685
715
|
- db/**/*.rb
|
686
716
|
|
717
|
+
Rails/MultipleRoutePaths:
|
718
|
+
Description: 'Checks for mapping a route with multiple paths, which is deprecated and will be removed in Rails 8.1.'
|
719
|
+
Enabled: pending
|
720
|
+
Severity: warning
|
721
|
+
VersionAdded: '2.29'
|
722
|
+
Include:
|
723
|
+
- '**/config/routes.rb'
|
724
|
+
- '**/config/routes/**/*.rb'
|
725
|
+
|
687
726
|
Rails/NegateInclude:
|
688
727
|
Description: 'Prefer `collection.exclude?(obj)` over `!collection.include?(obj)`.'
|
689
728
|
StyleGuide: 'https://rails.rubystyle.guide#exclude'
|
@@ -718,10 +757,10 @@ Rails/Output:
|
|
718
757
|
VersionAdded: '0.15'
|
719
758
|
VersionChanged: '0.19'
|
720
759
|
Include:
|
721
|
-
- app/**/*.rb
|
722
|
-
- config/**/*.rb
|
760
|
+
- '**/app/**/*.rb'
|
761
|
+
- '**/config/**/*.rb'
|
723
762
|
- db/**/*.rb
|
724
|
-
- lib/**/*.rb
|
763
|
+
- '**/lib/**/*.rb'
|
725
764
|
|
726
765
|
Rails/OutputSafety:
|
727
766
|
Description: 'The use of `html_safe` or `raw` may be a security risk.'
|
@@ -793,7 +832,7 @@ Rails/RakeEnvironment:
|
|
793
832
|
- '**/Rakefile'
|
794
833
|
- '**/*.rake'
|
795
834
|
Exclude:
|
796
|
-
- 'lib/capistrano/tasks/**/*.rake'
|
835
|
+
- '**/lib/capistrano/tasks/**/*.rake'
|
797
836
|
|
798
837
|
Rails/ReadWriteAttribute:
|
799
838
|
Description: >-
|
@@ -804,7 +843,7 @@ Rails/ReadWriteAttribute:
|
|
804
843
|
VersionAdded: '0.20'
|
805
844
|
VersionChanged: '0.29'
|
806
845
|
Include:
|
807
|
-
- app/models/**/*.rb
|
846
|
+
- '**/app/models/**/*.rb'
|
808
847
|
|
809
848
|
Rails/RedundantActiveRecordAllMethod:
|
810
849
|
Description: Detect redundant `all` used as a receiver for Active Record query methods.
|
@@ -823,7 +862,7 @@ Rails/RedundantAllowNil:
|
|
823
862
|
Enabled: true
|
824
863
|
VersionAdded: '0.67'
|
825
864
|
Include:
|
826
|
-
- app/models/**/*.rb
|
865
|
+
- '**/app/models/**/*.rb'
|
827
866
|
|
828
867
|
Rails/RedundantForeignKey:
|
829
868
|
Description: 'Checks for associations where the `:foreign_key` option is redundant.'
|
@@ -994,7 +1033,7 @@ Rails/ScopeArgs:
|
|
994
1033
|
VersionAdded: '0.19'
|
995
1034
|
VersionChanged: '2.12'
|
996
1035
|
Include:
|
997
|
-
- app/models/**/*.rb
|
1036
|
+
- '**/app/models/**/*.rb'
|
998
1037
|
|
999
1038
|
Rails/SelectMap:
|
1000
1039
|
Description: 'Checks for uses of `select(:column_name)` with `map(&:column_name)`.'
|
@@ -1058,6 +1097,15 @@ Rails/StripHeredoc:
|
|
1058
1097
|
Enabled: pending
|
1059
1098
|
VersionAdded: '2.15'
|
1060
1099
|
|
1100
|
+
Rails/StrongParametersExpect:
|
1101
|
+
Description: 'Enforces the use of `ActionController::Parameters#expect` as a method for strong parameter handling.'
|
1102
|
+
Reference: 'https://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-expect'
|
1103
|
+
Enabled: pending
|
1104
|
+
Include:
|
1105
|
+
- '**/app/controllers/**/*.rb'
|
1106
|
+
SafeAutoCorrect: false
|
1107
|
+
VersionAdded: '2.29'
|
1108
|
+
|
1061
1109
|
Rails/TableNameAssignment:
|
1062
1110
|
Description: >-
|
1063
1111
|
Do not use `self.table_name =`. Use Inflections or `table_name_prefix` instead.
|
@@ -1065,7 +1113,7 @@ Rails/TableNameAssignment:
|
|
1065
1113
|
Enabled: false
|
1066
1114
|
VersionAdded: '2.14'
|
1067
1115
|
Include:
|
1068
|
-
- app/models/**/*.rb
|
1116
|
+
- '**/app/models/**/*.rb'
|
1069
1117
|
|
1070
1118
|
Rails/ThreeStateBooleanColumn:
|
1071
1119
|
Description: 'Add a default value and a `NOT NULL` constraint to boolean columns.'
|
@@ -1149,7 +1197,7 @@ Rails/UniqueValidationWithoutIndex:
|
|
1149
1197
|
Enabled: true
|
1150
1198
|
VersionAdded: '2.5'
|
1151
1199
|
Include:
|
1152
|
-
- app/models/**/*.rb
|
1200
|
+
- '**/app/models/**/*.rb'
|
1153
1201
|
|
1154
1202
|
Rails/UnknownEnv:
|
1155
1203
|
Description: 'Use correct environment name.'
|
@@ -1168,7 +1216,7 @@ Rails/UnusedIgnoredColumns:
|
|
1168
1216
|
VersionAdded: '2.11'
|
1169
1217
|
VersionChanged: '2.25'
|
1170
1218
|
Include:
|
1171
|
-
- app/models/**/*.rb
|
1219
|
+
- '**/app/models/**/*.rb'
|
1172
1220
|
|
1173
1221
|
Rails/UnusedRenderContent:
|
1174
1222
|
Description: 'Do not specify body content for a response with a non-content status code.'
|
@@ -1182,15 +1230,15 @@ Rails/Validation:
|
|
1182
1230
|
VersionAdded: '0.9'
|
1183
1231
|
VersionChanged: '0.41'
|
1184
1232
|
Include:
|
1185
|
-
- app/models/**/*.rb
|
1233
|
+
- '**/app/models/**/*.rb'
|
1186
1234
|
|
1187
1235
|
Rails/WhereEquals:
|
1188
|
-
Description: 'Pass conditions to `where` as a hash instead of manually constructing SQL.'
|
1236
|
+
Description: 'Pass conditions to `where` and `where.not` as a hash instead of manually constructing SQL.'
|
1189
1237
|
StyleGuide: 'https://rails.rubystyle.guide/#hash-conditions'
|
1190
1238
|
Enabled: 'pending'
|
1191
1239
|
SafeAutoCorrect: false
|
1192
1240
|
VersionAdded: '2.9'
|
1193
|
-
VersionChanged: '2.
|
1241
|
+
VersionChanged: '2.26'
|
1194
1242
|
|
1195
1243
|
Rails/WhereExists:
|
1196
1244
|
Description: 'Prefer `exists?(...)` over `where(...).exists?`.'
|
@@ -1234,6 +1282,10 @@ Rails/WhereRange:
|
|
1234
1282
|
Style/AndOr:
|
1235
1283
|
EnforcedStyle: conditionals
|
1236
1284
|
|
1285
|
+
Style/CollectionCompact:
|
1286
|
+
AllowedReceivers:
|
1287
|
+
- params
|
1288
|
+
|
1237
1289
|
Style/FormatStringToken:
|
1238
1290
|
AllowedMethods:
|
1239
1291
|
- redirect
|
@@ -87,7 +87,7 @@ module RuboCop
|
|
87
87
|
|
88
88
|
options.each_pair.find do |pair|
|
89
89
|
next unless pair.key.sym_type? && pair.key.value == :foreign_key
|
90
|
-
next unless pair.value.
|
90
|
+
next unless pair.value.type?(:sym, :str)
|
91
91
|
|
92
92
|
break pair.value.value.to_s
|
93
93
|
end
|
@@ -103,7 +103,7 @@ module RuboCop
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def in_where?(node)
|
106
|
-
send_node = node.each_ancestor(:
|
106
|
+
send_node = node.each_ancestor(:call).first
|
107
107
|
return false unless send_node
|
108
108
|
|
109
109
|
return true if WHERE_METHODS.include?(send_node.method_name)
|
@@ -1,7 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RuboCop
|
4
|
-
module Cop
|
4
|
+
module Cop # rubocop:disable Style/Documentation
|
5
|
+
# The EnforceSuperclass module is also defined in `rubocop` (for backwards
|
6
|
+
# compatibility), so here we remove it before (re)defining it, to avoid
|
7
|
+
# warnings about methods in the module being redefined.
|
8
|
+
remove_const(:EnforceSuperclass) if defined?(EnforceSuperclass)
|
9
|
+
|
5
10
|
# Common functionality for enforcing a specific superclass.
|
6
11
|
module EnforceSuperclass
|
7
12
|
def self.included(base)
|