rubocop-rails 2.26.2 → 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 +45 -7
- data/config/default.yml +87 -49
- 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/add_column_index.rb +1 -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 +1 -0
- 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/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_syntax.rb +2 -0
- data/lib/rubocop/cop/rails/env_local.rb +26 -3
- data/lib/rubocop/cop/rails/file_path.rb +61 -9
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +7 -0
- 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/pluralization_grammar.rb +1 -1
- data/lib/rubocop/cop/rails/presence.rb +1 -1
- data/lib/rubocop/cop/rails/present.rb +1 -1
- data/lib/rubocop/cop/rails/redundant_active_record_all_method.rb +1 -1
- data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +6 -1
- data/lib/rubocop/cop/rails/reflection_class_name.rb +2 -2
- data/lib/rubocop/cop/rails/relative_date_constant.rb +1 -1
- data/lib/rubocop/cop/rails/reversible_migration.rb +4 -1
- data/lib/rubocop/cop/rails/root_pathname_methods.rb +6 -1
- 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 +1 -1
- 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/where_range.rb +1 -1
- data/lib/rubocop/cop/rails_cops.rb +3 -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 +28 -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,24 +46,61 @@ 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
|
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: >-
|
@@ -234,7 +252,7 @@ Rails/AttributeDefaultBlockValue:
|
|
234
252
|
Enabled: pending
|
235
253
|
VersionAdded: '2.9'
|
236
254
|
Include:
|
237
|
-
- 'app/models/**/*'
|
255
|
+
- '**/app/models/**/*'
|
238
256
|
|
239
257
|
Rails/BelongsTo:
|
240
258
|
Description: >-
|
@@ -293,8 +311,8 @@ Rails/ContentTag:
|
|
293
311
|
# https://puma.io/puma/Puma/DSL.html#tag-instance_method
|
294
312
|
# No helpers are used in normal models and configs.
|
295
313
|
Exclude:
|
296
|
-
- app/models/**/*.rb
|
297
|
-
- config/**/*.rb
|
314
|
+
- '**/app/models/**/*.rb'
|
315
|
+
- '**/config/**/*.rb'
|
298
316
|
|
299
317
|
Rails/CreateTableWithTimestamps:
|
300
318
|
Description: >-
|
@@ -349,11 +367,13 @@ Rails/Delegate:
|
|
349
367
|
Description: 'Prefer delegate method for delegations.'
|
350
368
|
Enabled: true
|
351
369
|
VersionAdded: '0.21'
|
352
|
-
VersionChanged: '
|
370
|
+
VersionChanged: '2.30'
|
353
371
|
# When set to true, using the target object as a prefix of the
|
354
372
|
# method name without using the `delegate` method will be a
|
355
373
|
# violation. When set to false, this case is legal.
|
356
374
|
EnforceForPrefixed: true
|
375
|
+
Exclude:
|
376
|
+
- '**/app/controllers/**/*.rb'
|
357
377
|
|
358
378
|
Rails/DelegateAllowBlank:
|
359
379
|
Description: 'Do not use allow_blank as an option to delegate.'
|
@@ -424,7 +444,7 @@ Rails/EnumHash:
|
|
424
444
|
Enabled: true
|
425
445
|
VersionAdded: '2.3'
|
426
446
|
Include:
|
427
|
-
- app/models/**/*.rb
|
447
|
+
- '**/app/models/**/*.rb'
|
428
448
|
|
429
449
|
Rails/EnumSyntax:
|
430
450
|
Description: 'Use positional arguments over keyword arguments when defining enums.'
|
@@ -432,14 +452,14 @@ Rails/EnumSyntax:
|
|
432
452
|
Severity: warning
|
433
453
|
VersionAdded: '2.26'
|
434
454
|
Include:
|
435
|
-
- app/models/**/*.rb
|
455
|
+
- '**/app/models/**/*.rb'
|
436
456
|
|
437
457
|
Rails/EnumUniqueness:
|
438
458
|
Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
|
439
459
|
Enabled: true
|
440
460
|
VersionAdded: '0.46'
|
441
461
|
Include:
|
442
|
-
- app/models/**/*.rb
|
462
|
+
- '**/app/models/**/*.rb'
|
443
463
|
|
444
464
|
Rails/EnvLocal:
|
445
465
|
Description: 'Use `Rails.env.local?` instead of `Rails.env.development? || Rails.env.test?`.'
|
@@ -458,11 +478,11 @@ Rails/EnvironmentVariableAccess:
|
|
458
478
|
VersionAdded: '2.10'
|
459
479
|
VersionChanged: '2.24'
|
460
480
|
Include:
|
461
|
-
- app/**/*.rb
|
462
|
-
- config/initializers/**/*.rb
|
463
|
-
- lib/**/*.rb
|
481
|
+
- '**/app/**/*.rb'
|
482
|
+
- '**/config/initializers/**/*.rb'
|
483
|
+
- '**/lib/**/*.rb'
|
464
484
|
Exclude:
|
465
|
-
- lib/**/*.rake
|
485
|
+
- '**/lib/**/*.rake'
|
466
486
|
AllowReads: false
|
467
487
|
AllowWrites: false
|
468
488
|
|
@@ -474,11 +494,11 @@ Rails/Exit:
|
|
474
494
|
Enabled: true
|
475
495
|
VersionAdded: '0.41'
|
476
496
|
Include:
|
477
|
-
- app/**/*.rb
|
478
|
-
- config/**/*.rb
|
479
|
-
- lib/**/*.rb
|
497
|
+
- '**/app/**/*.rb'
|
498
|
+
- '**/config/**/*.rb'
|
499
|
+
- '**/lib/**/*.rb'
|
480
500
|
Exclude:
|
481
|
-
- lib/**/*.rake
|
501
|
+
- '**/lib/**/*.rake'
|
482
502
|
|
483
503
|
Rails/ExpandedDateRange:
|
484
504
|
Description: 'Checks for expanded date range.'
|
@@ -540,7 +560,7 @@ Rails/HasAndBelongsToMany:
|
|
540
560
|
Enabled: true
|
541
561
|
VersionAdded: '0.12'
|
542
562
|
Include:
|
543
|
-
- app/models/**/*.rb
|
563
|
+
- '**/app/models/**/*.rb'
|
544
564
|
|
545
565
|
Rails/HasManyOrHasOneDependent:
|
546
566
|
Description: 'Define the dependent option to the has_many and has_one associations.'
|
@@ -548,14 +568,14 @@ Rails/HasManyOrHasOneDependent:
|
|
548
568
|
Enabled: true
|
549
569
|
VersionAdded: '0.50'
|
550
570
|
Include:
|
551
|
-
- app/models/**/*.rb
|
571
|
+
- '**/app/models/**/*.rb'
|
552
572
|
|
553
573
|
Rails/HelperInstanceVariable:
|
554
574
|
Description: 'Do not use instance variables in helpers.'
|
555
575
|
Enabled: true
|
556
576
|
VersionAdded: '2.0'
|
557
577
|
Include:
|
558
|
-
- app/helpers/**/*.rb
|
578
|
+
- '**/app/helpers/**/*.rb'
|
559
579
|
|
560
580
|
Rails/HttpPositionalArguments:
|
561
581
|
Description: 'Use keyword arguments instead of positional arguments in http method calls.'
|
@@ -586,7 +606,7 @@ Rails/I18nLazyLookup:
|
|
586
606
|
- lazy
|
587
607
|
- explicit
|
588
608
|
Include:
|
589
|
-
- 'app/controllers/**/*.rb'
|
609
|
+
- '**/app/controllers/**/*.rb'
|
590
610
|
|
591
611
|
Rails/I18nLocaleAssignment:
|
592
612
|
Description: 'Prefer the usage of `I18n.with_locale` instead of manually updating `I18n.locale` value.'
|
@@ -615,8 +635,8 @@ Rails/IgnoredSkipActionFilterOption:
|
|
615
635
|
Enabled: true
|
616
636
|
VersionAdded: '0.63'
|
617
637
|
Include:
|
618
|
-
- app/controllers/**/*.rb
|
619
|
-
- app/mailers/**/*.rb
|
638
|
+
- '**/app/controllers/**/*.rb'
|
639
|
+
- '**/app/mailers/**/*.rb'
|
620
640
|
|
621
641
|
Rails/IndexBy:
|
622
642
|
Description: 'Prefer `index_by` over `each_with_object`, `to_h`, or `map`.'
|
@@ -645,7 +665,7 @@ Rails/InverseOf:
|
|
645
665
|
VersionAdded: '0.52'
|
646
666
|
IgnoreScopes: false
|
647
667
|
Include:
|
648
|
-
- app/models/**/*.rb
|
668
|
+
- '**/app/models/**/*.rb'
|
649
669
|
|
650
670
|
Rails/LexicallyScopedActionFilter:
|
651
671
|
Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the class."
|
@@ -654,8 +674,8 @@ Rails/LexicallyScopedActionFilter:
|
|
654
674
|
Safe: false
|
655
675
|
VersionAdded: '0.52'
|
656
676
|
Include:
|
657
|
-
- app/controllers/**/*.rb
|
658
|
-
- app/mailers/**/*.rb
|
677
|
+
- '**/app/controllers/**/*.rb'
|
678
|
+
- '**/app/mailers/**/*.rb'
|
659
679
|
|
660
680
|
Rails/LinkToBlank:
|
661
681
|
Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
|
@@ -673,7 +693,7 @@ Rails/MailerName:
|
|
673
693
|
SafeAutoCorrect: false
|
674
694
|
VersionAdded: '2.7'
|
675
695
|
Include:
|
676
|
-
- app/mailers/**/*.rb
|
696
|
+
- '**/app/mailers/**/*.rb'
|
677
697
|
|
678
698
|
Rails/MatchRoute:
|
679
699
|
Description: >-
|
@@ -683,8 +703,8 @@ Rails/MatchRoute:
|
|
683
703
|
Enabled: 'pending'
|
684
704
|
VersionAdded: '2.7'
|
685
705
|
Include:
|
686
|
-
- config/routes.rb
|
687
|
-
- config/routes/**/*.rb
|
706
|
+
- '**/config/routes.rb'
|
707
|
+
- '**/config/routes/**/*.rb'
|
688
708
|
|
689
709
|
Rails/MigrationClassName:
|
690
710
|
Description: 'The class name of the migration should match its file name.'
|
@@ -694,6 +714,15 @@ Rails/MigrationClassName:
|
|
694
714
|
Include:
|
695
715
|
- db/**/*.rb
|
696
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
|
+
|
697
726
|
Rails/NegateInclude:
|
698
727
|
Description: 'Prefer `collection.exclude?(obj)` over `!collection.include?(obj)`.'
|
699
728
|
StyleGuide: 'https://rails.rubystyle.guide#exclude'
|
@@ -728,10 +757,10 @@ Rails/Output:
|
|
728
757
|
VersionAdded: '0.15'
|
729
758
|
VersionChanged: '0.19'
|
730
759
|
Include:
|
731
|
-
- app/**/*.rb
|
732
|
-
- config/**/*.rb
|
760
|
+
- '**/app/**/*.rb'
|
761
|
+
- '**/config/**/*.rb'
|
733
762
|
- db/**/*.rb
|
734
|
-
- lib/**/*.rb
|
763
|
+
- '**/lib/**/*.rb'
|
735
764
|
|
736
765
|
Rails/OutputSafety:
|
737
766
|
Description: 'The use of `html_safe` or `raw` may be a security risk.'
|
@@ -803,7 +832,7 @@ Rails/RakeEnvironment:
|
|
803
832
|
- '**/Rakefile'
|
804
833
|
- '**/*.rake'
|
805
834
|
Exclude:
|
806
|
-
- 'lib/capistrano/tasks/**/*.rake'
|
835
|
+
- '**/lib/capistrano/tasks/**/*.rake'
|
807
836
|
|
808
837
|
Rails/ReadWriteAttribute:
|
809
838
|
Description: >-
|
@@ -814,7 +843,7 @@ Rails/ReadWriteAttribute:
|
|
814
843
|
VersionAdded: '0.20'
|
815
844
|
VersionChanged: '0.29'
|
816
845
|
Include:
|
817
|
-
- app/models/**/*.rb
|
846
|
+
- '**/app/models/**/*.rb'
|
818
847
|
|
819
848
|
Rails/RedundantActiveRecordAllMethod:
|
820
849
|
Description: Detect redundant `all` used as a receiver for Active Record query methods.
|
@@ -833,7 +862,7 @@ Rails/RedundantAllowNil:
|
|
833
862
|
Enabled: true
|
834
863
|
VersionAdded: '0.67'
|
835
864
|
Include:
|
836
|
-
- app/models/**/*.rb
|
865
|
+
- '**/app/models/**/*.rb'
|
837
866
|
|
838
867
|
Rails/RedundantForeignKey:
|
839
868
|
Description: 'Checks for associations where the `:foreign_key` option is redundant.'
|
@@ -1004,7 +1033,7 @@ Rails/ScopeArgs:
|
|
1004
1033
|
VersionAdded: '0.19'
|
1005
1034
|
VersionChanged: '2.12'
|
1006
1035
|
Include:
|
1007
|
-
- app/models/**/*.rb
|
1036
|
+
- '**/app/models/**/*.rb'
|
1008
1037
|
|
1009
1038
|
Rails/SelectMap:
|
1010
1039
|
Description: 'Checks for uses of `select(:column_name)` with `map(&:column_name)`.'
|
@@ -1068,6 +1097,15 @@ Rails/StripHeredoc:
|
|
1068
1097
|
Enabled: pending
|
1069
1098
|
VersionAdded: '2.15'
|
1070
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
|
+
|
1071
1109
|
Rails/TableNameAssignment:
|
1072
1110
|
Description: >-
|
1073
1111
|
Do not use `self.table_name =`. Use Inflections or `table_name_prefix` instead.
|
@@ -1075,7 +1113,7 @@ Rails/TableNameAssignment:
|
|
1075
1113
|
Enabled: false
|
1076
1114
|
VersionAdded: '2.14'
|
1077
1115
|
Include:
|
1078
|
-
- app/models/**/*.rb
|
1116
|
+
- '**/app/models/**/*.rb'
|
1079
1117
|
|
1080
1118
|
Rails/ThreeStateBooleanColumn:
|
1081
1119
|
Description: 'Add a default value and a `NOT NULL` constraint to boolean columns.'
|
@@ -1159,7 +1197,7 @@ Rails/UniqueValidationWithoutIndex:
|
|
1159
1197
|
Enabled: true
|
1160
1198
|
VersionAdded: '2.5'
|
1161
1199
|
Include:
|
1162
|
-
- app/models/**/*.rb
|
1200
|
+
- '**/app/models/**/*.rb'
|
1163
1201
|
|
1164
1202
|
Rails/UnknownEnv:
|
1165
1203
|
Description: 'Use correct environment name.'
|
@@ -1178,7 +1216,7 @@ Rails/UnusedIgnoredColumns:
|
|
1178
1216
|
VersionAdded: '2.11'
|
1179
1217
|
VersionChanged: '2.25'
|
1180
1218
|
Include:
|
1181
|
-
- app/models/**/*.rb
|
1219
|
+
- '**/app/models/**/*.rb'
|
1182
1220
|
|
1183
1221
|
Rails/UnusedRenderContent:
|
1184
1222
|
Description: 'Do not specify body content for a response with a non-content status code.'
|
@@ -1192,7 +1230,7 @@ Rails/Validation:
|
|
1192
1230
|
VersionAdded: '0.9'
|
1193
1231
|
VersionChanged: '0.41'
|
1194
1232
|
Include:
|
1195
|
-
- app/models/**/*.rb
|
1233
|
+
- '**/app/models/**/*.rb'
|
1196
1234
|
|
1197
1235
|
Rails/WhereEquals:
|
1198
1236
|
Description: 'Pass conditions to `where` and `where.not` as a hash instead of manually constructing SQL.'
|
@@ -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)
|