rubocop-rails 2.30.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a45ebdeef3a184afbb85ff1e1685fa978198ee00cf3bbbc0f1cbfa04b56f9dc7
4
- data.tar.gz: 2d06943201b3836891ed9f8c0bd9a5e2bebd90de7736351add71af9460e271b7
3
+ metadata.gz: '009a04a87f7692e278ce16b061ff93814ada6644691ce2fdd4ac4c7659e68c4d'
4
+ data.tar.gz: 313e26b30279cf9ebba24f5f99bc78b2b44433b24bc3522a6d4261de1cf72282
5
5
  SHA512:
6
- metadata.gz: ed82ce027a4bee9e6dfa16dd763fa856d7b19b96356b918d469ef1274ef0c5a4e8ea5e949c6aaed84ee6d0f290ca838e34e352929640294a6bd4d579c0145cdd
7
- data.tar.gz: 7e11061742bc02b64742e4219ccfea80d5befb27572cb043d7ebc57c7a616f2fd2c8b829ac08dfad6b644f23d8a0f096c8b571cc5b8e9ecf34e7769f1f551fb4
6
+ metadata.gz: 1f7397609be46c75da8ff050ed1325db850c39df7d097d9faeb6984162b706ed92e203f151a30a68aa41b3af8fcdd63b7e76c51ebdcfe31980129a853d7cd8a3
7
+ data.tar.gz: 46006ebeb148838e1ae7f3dc56614b261fc90779c5e3772e163c9431034a89dbc614ef1cb1b913d5236fbc2b04708643fc27b593d8c0c4147898271c045cb4c7
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
@@ -121,8 +121,8 @@ Rails/ActionFilter:
121
121
  - action
122
122
  - filter
123
123
  Include:
124
- - app/controllers/**/*.rb
125
- - app/mailers/**/*.rb
124
+ - '**/app/controllers/**/*.rb'
125
+ - '**/app/mailers/**/*.rb'
126
126
 
127
127
  Rails/ActionOrder:
128
128
  Description: 'Enforce consistent ordering of controller actions.'
@@ -137,7 +137,7 @@ Rails/ActionOrder:
137
137
  - update
138
138
  - destroy
139
139
  Include:
140
- - app/controllers/**/*.rb
140
+ - '**/app/controllers/**/*.rb'
141
141
 
142
142
  Rails/ActiveRecordAliases:
143
143
  Description: >-
@@ -154,7 +154,7 @@ Rails/ActiveRecordCallbacksOrder:
154
154
  Enabled: 'pending'
155
155
  VersionAdded: '2.7'
156
156
  Include:
157
- - app/models/**/*.rb
157
+ - '**/app/models/**/*.rb'
158
158
 
159
159
  Rails/ActiveRecordOverride:
160
160
  Description: >-
@@ -165,7 +165,7 @@ Rails/ActiveRecordOverride:
165
165
  VersionAdded: '0.67'
166
166
  VersionChanged: '2.18'
167
167
  Include:
168
- - app/models/**/*.rb
168
+ - '**/app/models/**/*.rb'
169
169
 
170
170
  Rails/ActiveSupportAliases:
171
171
  Description: >-
@@ -252,7 +252,7 @@ Rails/AttributeDefaultBlockValue:
252
252
  Enabled: pending
253
253
  VersionAdded: '2.9'
254
254
  Include:
255
- - 'app/models/**/*'
255
+ - '**/app/models/**/*'
256
256
 
257
257
  Rails/BelongsTo:
258
258
  Description: >-
@@ -311,8 +311,8 @@ Rails/ContentTag:
311
311
  # https://puma.io/puma/Puma/DSL.html#tag-instance_method
312
312
  # No helpers are used in normal models and configs.
313
313
  Exclude:
314
- - app/models/**/*.rb
315
- - config/**/*.rb
314
+ - '**/app/models/**/*.rb'
315
+ - '**/config/**/*.rb'
316
316
 
317
317
  Rails/CreateTableWithTimestamps:
318
318
  Description: >-
@@ -373,7 +373,7 @@ Rails/Delegate:
373
373
  # violation. When set to false, this case is legal.
374
374
  EnforceForPrefixed: true
375
375
  Exclude:
376
- - app/controllers/**/*.rb
376
+ - '**/app/controllers/**/*.rb'
377
377
 
378
378
  Rails/DelegateAllowBlank:
379
379
  Description: 'Do not use allow_blank as an option to delegate.'
@@ -444,7 +444,7 @@ Rails/EnumHash:
444
444
  Enabled: true
445
445
  VersionAdded: '2.3'
446
446
  Include:
447
- - app/models/**/*.rb
447
+ - '**/app/models/**/*.rb'
448
448
 
449
449
  Rails/EnumSyntax:
450
450
  Description: 'Use positional arguments over keyword arguments when defining enums.'
@@ -452,14 +452,14 @@ Rails/EnumSyntax:
452
452
  Severity: warning
453
453
  VersionAdded: '2.26'
454
454
  Include:
455
- - app/models/**/*.rb
455
+ - '**/app/models/**/*.rb'
456
456
 
457
457
  Rails/EnumUniqueness:
458
458
  Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
459
459
  Enabled: true
460
460
  VersionAdded: '0.46'
461
461
  Include:
462
- - app/models/**/*.rb
462
+ - '**/app/models/**/*.rb'
463
463
 
464
464
  Rails/EnvLocal:
465
465
  Description: 'Use `Rails.env.local?` instead of `Rails.env.development? || Rails.env.test?`.'
@@ -478,11 +478,11 @@ Rails/EnvironmentVariableAccess:
478
478
  VersionAdded: '2.10'
479
479
  VersionChanged: '2.24'
480
480
  Include:
481
- - app/**/*.rb
482
- - config/initializers/**/*.rb
483
- - lib/**/*.rb
481
+ - '**/app/**/*.rb'
482
+ - '**/config/initializers/**/*.rb'
483
+ - '**/lib/**/*.rb'
484
484
  Exclude:
485
- - lib/**/*.rake
485
+ - '**/lib/**/*.rake'
486
486
  AllowReads: false
487
487
  AllowWrites: false
488
488
 
@@ -494,11 +494,11 @@ Rails/Exit:
494
494
  Enabled: true
495
495
  VersionAdded: '0.41'
496
496
  Include:
497
- - app/**/*.rb
498
- - config/**/*.rb
499
- - lib/**/*.rb
497
+ - '**/app/**/*.rb'
498
+ - '**/config/**/*.rb'
499
+ - '**/lib/**/*.rb'
500
500
  Exclude:
501
- - lib/**/*.rake
501
+ - '**/lib/**/*.rake'
502
502
 
503
503
  Rails/ExpandedDateRange:
504
504
  Description: 'Checks for expanded date range.'
@@ -560,7 +560,7 @@ Rails/HasAndBelongsToMany:
560
560
  Enabled: true
561
561
  VersionAdded: '0.12'
562
562
  Include:
563
- - app/models/**/*.rb
563
+ - '**/app/models/**/*.rb'
564
564
 
565
565
  Rails/HasManyOrHasOneDependent:
566
566
  Description: 'Define the dependent option to the has_many and has_one associations.'
@@ -568,14 +568,14 @@ Rails/HasManyOrHasOneDependent:
568
568
  Enabled: true
569
569
  VersionAdded: '0.50'
570
570
  Include:
571
- - app/models/**/*.rb
571
+ - '**/app/models/**/*.rb'
572
572
 
573
573
  Rails/HelperInstanceVariable:
574
574
  Description: 'Do not use instance variables in helpers.'
575
575
  Enabled: true
576
576
  VersionAdded: '2.0'
577
577
  Include:
578
- - app/helpers/**/*.rb
578
+ - '**/app/helpers/**/*.rb'
579
579
 
580
580
  Rails/HttpPositionalArguments:
581
581
  Description: 'Use keyword arguments instead of positional arguments in http method calls.'
@@ -606,7 +606,7 @@ Rails/I18nLazyLookup:
606
606
  - lazy
607
607
  - explicit
608
608
  Include:
609
- - 'app/controllers/**/*.rb'
609
+ - '**/app/controllers/**/*.rb'
610
610
 
611
611
  Rails/I18nLocaleAssignment:
612
612
  Description: 'Prefer the usage of `I18n.with_locale` instead of manually updating `I18n.locale` value.'
@@ -635,8 +635,8 @@ Rails/IgnoredSkipActionFilterOption:
635
635
  Enabled: true
636
636
  VersionAdded: '0.63'
637
637
  Include:
638
- - app/controllers/**/*.rb
639
- - app/mailers/**/*.rb
638
+ - '**/app/controllers/**/*.rb'
639
+ - '**/app/mailers/**/*.rb'
640
640
 
641
641
  Rails/IndexBy:
642
642
  Description: 'Prefer `index_by` over `each_with_object`, `to_h`, or `map`.'
@@ -665,7 +665,7 @@ Rails/InverseOf:
665
665
  VersionAdded: '0.52'
666
666
  IgnoreScopes: false
667
667
  Include:
668
- - app/models/**/*.rb
668
+ - '**/app/models/**/*.rb'
669
669
 
670
670
  Rails/LexicallyScopedActionFilter:
671
671
  Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the class."
@@ -674,8 +674,8 @@ Rails/LexicallyScopedActionFilter:
674
674
  Safe: false
675
675
  VersionAdded: '0.52'
676
676
  Include:
677
- - app/controllers/**/*.rb
678
- - app/mailers/**/*.rb
677
+ - '**/app/controllers/**/*.rb'
678
+ - '**/app/mailers/**/*.rb'
679
679
 
680
680
  Rails/LinkToBlank:
681
681
  Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
@@ -693,7 +693,7 @@ Rails/MailerName:
693
693
  SafeAutoCorrect: false
694
694
  VersionAdded: '2.7'
695
695
  Include:
696
- - app/mailers/**/*.rb
696
+ - '**/app/mailers/**/*.rb'
697
697
 
698
698
  Rails/MatchRoute:
699
699
  Description: >-
@@ -703,8 +703,8 @@ Rails/MatchRoute:
703
703
  Enabled: 'pending'
704
704
  VersionAdded: '2.7'
705
705
  Include:
706
- - config/routes.rb
707
- - config/routes/**/*.rb
706
+ - '**/config/routes.rb'
707
+ - '**/config/routes/**/*.rb'
708
708
 
709
709
  Rails/MigrationClassName:
710
710
  Description: 'The class name of the migration should match its file name.'
@@ -720,8 +720,8 @@ Rails/MultipleRoutePaths:
720
720
  Severity: warning
721
721
  VersionAdded: '2.29'
722
722
  Include:
723
- - config/routes.rb
724
- - config/routes/**/*.rb
723
+ - '**/config/routes.rb'
724
+ - '**/config/routes/**/*.rb'
725
725
 
726
726
  Rails/NegateInclude:
727
727
  Description: 'Prefer `collection.exclude?(obj)` over `!collection.include?(obj)`.'
@@ -757,10 +757,10 @@ Rails/Output:
757
757
  VersionAdded: '0.15'
758
758
  VersionChanged: '0.19'
759
759
  Include:
760
- - app/**/*.rb
761
- - config/**/*.rb
760
+ - '**/app/**/*.rb'
761
+ - '**/config/**/*.rb'
762
762
  - db/**/*.rb
763
- - lib/**/*.rb
763
+ - '**/lib/**/*.rb'
764
764
 
765
765
  Rails/OutputSafety:
766
766
  Description: 'The use of `html_safe` or `raw` may be a security risk.'
@@ -832,7 +832,7 @@ Rails/RakeEnvironment:
832
832
  - '**/Rakefile'
833
833
  - '**/*.rake'
834
834
  Exclude:
835
- - 'lib/capistrano/tasks/**/*.rake'
835
+ - '**/lib/capistrano/tasks/**/*.rake'
836
836
 
837
837
  Rails/ReadWriteAttribute:
838
838
  Description: >-
@@ -843,7 +843,7 @@ Rails/ReadWriteAttribute:
843
843
  VersionAdded: '0.20'
844
844
  VersionChanged: '0.29'
845
845
  Include:
846
- - app/models/**/*.rb
846
+ - '**/app/models/**/*.rb'
847
847
 
848
848
  Rails/RedundantActiveRecordAllMethod:
849
849
  Description: Detect redundant `all` used as a receiver for Active Record query methods.
@@ -862,7 +862,7 @@ Rails/RedundantAllowNil:
862
862
  Enabled: true
863
863
  VersionAdded: '0.67'
864
864
  Include:
865
- - app/models/**/*.rb
865
+ - '**/app/models/**/*.rb'
866
866
 
867
867
  Rails/RedundantForeignKey:
868
868
  Description: 'Checks for associations where the `:foreign_key` option is redundant.'
@@ -1033,7 +1033,7 @@ Rails/ScopeArgs:
1033
1033
  VersionAdded: '0.19'
1034
1034
  VersionChanged: '2.12'
1035
1035
  Include:
1036
- - app/models/**/*.rb
1036
+ - '**/app/models/**/*.rb'
1037
1037
 
1038
1038
  Rails/SelectMap:
1039
1039
  Description: 'Checks for uses of `select(:column_name)` with `map(&:column_name)`.'
@@ -1102,7 +1102,7 @@ Rails/StrongParametersExpect:
1102
1102
  Reference: 'https://api.rubyonrails.org/classes/ActionController/Parameters.html#method-i-expect'
1103
1103
  Enabled: pending
1104
1104
  Include:
1105
- - app/controllers/**/*.rb
1105
+ - '**/app/controllers/**/*.rb'
1106
1106
  SafeAutoCorrect: false
1107
1107
  VersionAdded: '2.29'
1108
1108
 
@@ -1113,7 +1113,7 @@ Rails/TableNameAssignment:
1113
1113
  Enabled: false
1114
1114
  VersionAdded: '2.14'
1115
1115
  Include:
1116
- - app/models/**/*.rb
1116
+ - '**/app/models/**/*.rb'
1117
1117
 
1118
1118
  Rails/ThreeStateBooleanColumn:
1119
1119
  Description: 'Add a default value and a `NOT NULL` constraint to boolean columns.'
@@ -1197,7 +1197,7 @@ Rails/UniqueValidationWithoutIndex:
1197
1197
  Enabled: true
1198
1198
  VersionAdded: '2.5'
1199
1199
  Include:
1200
- - app/models/**/*.rb
1200
+ - '**/app/models/**/*.rb'
1201
1201
 
1202
1202
  Rails/UnknownEnv:
1203
1203
  Description: 'Use correct environment name.'
@@ -1216,7 +1216,7 @@ Rails/UnusedIgnoredColumns:
1216
1216
  VersionAdded: '2.11'
1217
1217
  VersionChanged: '2.25'
1218
1218
  Include:
1219
- - app/models/**/*.rb
1219
+ - '**/app/models/**/*.rb'
1220
1220
 
1221
1221
  Rails/UnusedRenderContent:
1222
1222
  Description: 'Do not specify body content for a response with a non-content status code.'
@@ -1230,7 +1230,7 @@ Rails/Validation:
1230
1230
  VersionAdded: '0.9'
1231
1231
  VersionChanged: '0.41'
1232
1232
  Include:
1233
- - app/models/**/*.rb
1233
+ - '**/app/models/**/*.rb'
1234
1234
 
1235
1235
  Rails/WhereEquals:
1236
1236
  Description: 'Pass conditions to `where` and `where.not` as a hash instead of manually constructing SQL.'
@@ -29,8 +29,8 @@ module RuboCop
29
29
  end
30
30
 
31
31
  def database_from_env
32
- url = ENV['DATABASE_URL'].presence
33
- return unless url
32
+ url = ENV.fetch('DATABASE_URL', '')
33
+ return if url.blank?
34
34
 
35
35
  case url
36
36
  when %r{\A(mysql2|trilogy)://}
@@ -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)
@@ -58,7 +58,7 @@ module RuboCop
58
58
  end
59
59
 
60
60
  def set_new_arg_name(transformed_argname, corrector)
61
- return if block_node.numblock_type?
61
+ return unless block_node.block_type?
62
62
 
63
63
  corrector.replace(block_node.arguments, "|#{transformed_argname}|")
64
64
  end
@@ -84,6 +84,7 @@ module RuboCop
84
84
  end
85
85
 
86
86
  alias on_numblock on_block
87
+ alias on_itblock on_block
87
88
 
88
89
  def on_send(node)
89
90
  on_bad_map_to_h(node) do |*match|
@@ -5,14 +5,14 @@ module RuboCop
5
5
  module Rails
6
6
  # Prevents usage of `"*"` on an Arel::Table column reference.
7
7
  #
8
- # Using `arel_table["*"]` causes the outputted string to be a literal
9
- # quoted asterisk (e.g. <tt>`my_model`.`*`</tt>). This causes the
10
- # database to look for a column named <tt>`*`</tt> (or `"*"`) as opposed
8
+ # Using `arel_table["\*"]` causes the outputted string to be a literal
9
+ # quoted asterisk (e.g. `my_model`.`*`). This causes the
10
+ # database to look for a column named `\*` (or `"*"`) as opposed
11
11
  # to expanding the column list as one would likely expect.
12
12
  #
13
13
  # @safety
14
- # This cop's autocorrection is unsafe because it turns a quoted `*` into
15
- # an SQL `*`, unquoted. `*` is a valid column name in certain databases
14
+ # This cop's autocorrection is unsafe because it turns a quoted `\*` into
15
+ # an SQL `*`, unquoted. `\*` is a valid column name in certain databases
16
16
  # supported by Rails, and even though it is usually a mistake,
17
17
  # it might denote legitimate access to a column named `*`.
18
18
  #
@@ -45,12 +45,10 @@ module RuboCop
45
45
  return if node.parent&.block_type?
46
46
 
47
47
  interpolated_string_passed_to_debug(node) do |arguments|
48
- message = format(MSG)
49
-
50
48
  range = replacement_range(node)
51
49
  replacement = replacement_source(node, arguments)
52
50
 
53
- add_offense(range, message: message) do |corrector|
51
+ add_offense(range) do |corrector|
54
52
  corrector.replace(range, replacement)
55
53
  end
56
54
  end
@@ -37,6 +37,9 @@ module RuboCop
37
37
  (numblock
38
38
  (call _ :to_h) $1
39
39
  (array $_ (lvar :_1)))
40
+ (itblock
41
+ (call _ :to_h) $:it
42
+ (array $_ (lvar :it)))
40
43
  }
41
44
  PATTERN
42
45
 
@@ -50,6 +53,9 @@ module RuboCop
50
53
  (numblock
51
54
  (call _ {:map :collect}) $1
52
55
  (array $_ (lvar :_1)))
56
+ (itblock
57
+ (call _ {:map :collect}) $:it
58
+ (array $_ (lvar :it)))
53
59
  }
54
60
  :to_h)
55
61
  PATTERN
@@ -66,6 +72,9 @@ module RuboCop
66
72
  (numblock
67
73
  (call _ {:map :collect}) $1
68
74
  (array $_ (lvar :_1)))
75
+ (itblock
76
+ (call _ {:map :collect}) $:it
77
+ (array $_ (lvar :it)))
69
78
  }
70
79
  )
71
80
  PATTERN
@@ -40,6 +40,9 @@ module RuboCop
40
40
  (numblock
41
41
  (call _ :to_h) $1
42
42
  (array (lvar :_1) $_))
43
+ (itblock
44
+ (call _ :to_h) $:it
45
+ (array (lvar :it) $_))
43
46
  }
44
47
  PATTERN
45
48
 
@@ -53,6 +56,9 @@ module RuboCop
53
56
  (numblock
54
57
  (call _ {:map :collect}) $1
55
58
  (array (lvar :_1) $_))
59
+ (itblock
60
+ (call _ {:map :collect}) $:it
61
+ (array (lvar :it) $_))
56
62
  }
57
63
  :to_h)
58
64
  PATTERN
@@ -69,6 +75,9 @@ module RuboCop
69
75
  (numblock
70
76
  (call _ {:map :collect}) $1
71
77
  (array (lvar :_1) $_))
78
+ (itblock
79
+ (call _ {:map :collect}) $:it
80
+ (array (lvar :it) $_))
72
81
  }
73
82
  )
74
83
  PATTERN
@@ -23,7 +23,6 @@ module RuboCop
23
23
 
24
24
  MSG = "Do not write to stdout. Use Rails's logger if you want to log."
25
25
  RESTRICT_ON_SEND = %i[ap p pp pretty_print print puts binwrite syswrite write write_nonblock].freeze
26
- ALLOWED_TYPES = %i[send csend block numblock].freeze
27
26
 
28
27
  def_node_matcher :output?, <<~PATTERN
29
28
  (send nil? {:ap :p :pp :pretty_print :print :puts} ...)
@@ -40,7 +39,7 @@ module RuboCop
40
39
  PATTERN
41
40
 
42
41
  def on_send(node)
43
- return if ALLOWED_TYPES.include?(node.parent&.type)
42
+ return if node.parent&.call_type? || node.block_node
44
43
  return if !output?(node) && !io_output?(node)
45
44
 
46
45
  range = offense_range(node)
@@ -59,6 +59,7 @@ module RuboCop
59
59
  (any_block (call _ {:map :collect}) $_argument (send lvar :[] $_key))
60
60
  PATTERN
61
61
 
62
+ # rubocop:disable Metrics/AbcSize
62
63
  def on_block(node)
63
64
  return if node.each_ancestor(:any_block).any?
64
65
 
@@ -68,20 +69,25 @@ module RuboCop
68
69
  match = if node.block_type?
69
70
  block_argument = argument.children.first.source
70
71
  use_block_argument_in_key?(block_argument, key)
71
- else # numblock
72
- argument == 1 && use_block_argument_in_key?('_1', key)
72
+ elsif node.numblock_type?
73
+ use_block_argument_in_key?('_1', key)
74
+ else # itblock
75
+ use_block_argument_in_key?('it', key)
73
76
  end
74
77
  next unless match
75
78
 
76
79
  register_offense(node, key)
77
80
  end
78
81
  end
82
+ # rubocop:enable Metrics/AbcSize
79
83
  alias on_numblock on_block
84
+ alias on_itblock on_block
80
85
 
81
86
  private
82
87
 
83
88
  def use_one_block_argument?(argument)
84
- return true if argument == 1 # Checks for numbered argument `_1`.
89
+ # Checks for numbered argument `_1` or `it block parameter.
90
+ return true if [1, :it].include?(argument)
85
91
 
86
92
  argument.respond_to?(:one?) && argument.one?
87
93
  end
@@ -85,18 +85,22 @@ module RuboCop
85
85
  end
86
86
 
87
87
  alias on_numblock on_block
88
+ alias on_itblock on_block
88
89
 
89
90
  private
90
91
 
91
92
  def autocorrect(corrector, send_node, node)
92
93
  corrector.remove(send_node.receiver)
93
94
  corrector.remove(send_node.loc.dot)
94
- corrector.remove(block_argument_range(send_node)) unless node.numblock_type?
95
+ corrector.remove(block_argument_range(send_node)) if node.block_type?
95
96
  end
96
97
 
98
+ # rubocop:disable Metrics/AbcSize
97
99
  def redundant_receiver?(send_nodes, node)
98
100
  proc = if node.numblock_type?
99
101
  ->(n) { n.receiver.lvar_type? && n.receiver.source == '_1' }
102
+ elsif node.itblock_type?
103
+ ->(n) { n.receiver.lvar_type? && n.receiver.source == 'it' }
100
104
  else
101
105
  return false if node.arguments.empty?
102
106
 
@@ -106,6 +110,7 @@ module RuboCop
106
110
 
107
111
  send_nodes.all?(&proc)
108
112
  end
113
+ # rubocop:enable Metrics/AbcSize
109
114
 
110
115
  def block_argument_range(node)
111
116
  block_node = node.each_ancestor(:block).first
@@ -76,7 +76,7 @@ module RuboCop
76
76
  def autocorrect(corrector, class_config)
77
77
  class_value = class_config.value
78
78
  replacement = const_or_string(class_value)
79
- return unless replacement.present?
79
+ return unless replacement
80
80
 
81
81
  corrector.replace(class_value, replacement.source.inspect)
82
82
  end
@@ -205,6 +205,7 @@ module RuboCop
205
205
  end
206
206
 
207
207
  alias on_numblock on_block
208
+ alias on_itblock on_block
208
209
 
209
210
  private
210
211
 
@@ -39,7 +39,7 @@ module RuboCop
39
39
 
40
40
  # @!method comment_present?(node)
41
41
  def_node_matcher :comment_present?, <<~PATTERN
42
- (hash <(pair {(sym :comment) (str "comment")} (_ [present?])) ...>)
42
+ (hash <(pair {(sym :comment) (str "comment")} !{nil (str blank?)}) ...>)
43
43
  PATTERN
44
44
 
45
45
  # @!method add_column?(node)
@@ -45,7 +45,7 @@ module RuboCop
45
45
 
46
46
  return if required_options?(options_node)
47
47
 
48
- def_node = node.each_ancestor(:def, :defs).first
48
+ def_node = node.each_ancestor(:any_def).first
49
49
  table_node = table_node(node)
50
50
  return if def_node && (table_node.nil? || change_column_null?(def_node, table_node, column_node))
51
51
 
@@ -135,7 +135,9 @@ module RuboCop
135
135
  end
136
136
 
137
137
  def attach_timezone_specifier?(date)
138
- date.respond_to?(:value) && TIMEZONE_SPECIFIER.match?(date.value.to_s)
138
+ return false unless date.respond_to?(:value)
139
+
140
+ !date.value.to_s.valid_encoding? || TIMEZONE_SPECIFIER.match?(date.value.to_s)
139
141
  end
140
142
 
141
143
  def build_message(klass, method_name, node)
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Rails
5
5
  # This module holds the RuboCop Rails version information.
6
6
  module Version
7
- STRING = '2.30.3'
7
+ STRING = '2.32.0'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
data/lib/rubocop-rails.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  require 'rubocop'
4
4
  require 'rack/utils'
5
5
  require 'active_support/inflector'
6
- require 'active_support/core_ext/object/blank'
7
6
 
8
7
  require_relative 'rubocop/rails'
9
8
  require_relative 'rubocop/rails/version'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.30.3
4
+ version: 2.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -9,7 +9,7 @@ authors:
9
9
  - Yuji Nakayama
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2025-03-03 00:00:00.000000000 Z
12
+ date: 2025-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -59,7 +59,7 @@ dependencies:
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 1.72.1
62
+ version: 1.75.0
63
63
  - - "<"
64
64
  - !ruby/object:Gem::Version
65
65
  version: '2.0'
@@ -69,7 +69,7 @@ dependencies:
69
69
  requirements:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 1.72.1
72
+ version: 1.75.0
73
73
  - - "<"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.0'
@@ -79,7 +79,7 @@ dependencies:
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 1.38.0
82
+ version: 1.44.0
83
83
  - - "<"
84
84
  - !ruby/object:Gem::Version
85
85
  version: '2.0'
@@ -89,7 +89,7 @@ dependencies:
89
89
  requirements:
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: 1.38.0
92
+ version: 1.44.0
93
93
  - - "<"
94
94
  - !ruby/object:Gem::Version
95
95
  version: '2.0'
@@ -264,7 +264,7 @@ metadata:
264
264
  homepage_uri: https://docs.rubocop.org/rubocop-rails/
265
265
  changelog_uri: https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md
266
266
  source_code_uri: https://github.com/rubocop/rubocop-rails/
267
- documentation_uri: https://docs.rubocop.org/rubocop-rails/2.30/
267
+ documentation_uri: https://docs.rubocop.org/rubocop-rails/2.32/
268
268
  bug_tracker_uri: https://github.com/rubocop/rubocop-rails/issues
269
269
  rubygems_mfa_required: 'true'
270
270
  default_lint_roller_plugin: RuboCop::Rails::Plugin