rubocop-rails 2.34.1 → 2.34.3

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: 0d751c9891e698f0916a8e58e8cb6b30c4c267b1c069e7b57e01160bb121b49c
4
- data.tar.gz: 5ae0f4177bd644cc89d683e1a3176eb6434fe69195c043fe5dc057be52ddff0d
3
+ metadata.gz: cceb6a56dba516cdc368294a42ff59397a70f758801e5a1285df315a9d4abc8f
4
+ data.tar.gz: 555f1da6ed7abe2a2be37867c5405abaa16007b77be36e68c67b2a79d11865c9
5
5
  SHA512:
6
- metadata.gz: 44b7345a990e2ccf25ed3c4e4f1de3ae8cfe46bf0ea6841c9d5f43a24e04f881729d9c9ce4cce15dc71430dcb30a6684f16c05a299a5b040b37f1ffd22f9ea4e
7
- data.tar.gz: 3cf9f62438b49c1c3c2c075bebb3f7a21c61ebc53236be6b1498c1d07cc63e3c021c6c266e19b6080345023a1f6f985146b4119358908704573c49d2a9763111
6
+ metadata.gz: 25a1c6aecce64df1814142ee6a4a0dfb6014ddc9f7a4fdb4c9f59035277a63512163bab201202f9b90fcfbaeae6bf7c87479326f4415f853beaf6fd7c3e64486
7
+ data.tar.gz: 5eec318843c618ae00bf370ef17060d90b5978e427812a90d4b8f7015ab25af5a09a3adee9e973dd821a5ad67d4ba0f503af11a067ceb30a3e81823cfbab2b93
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-25 Bozhidar Batsov
1
+ Copyright (c) 2012-26 Bozhidar Batsov
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -68,6 +68,7 @@ module RuboCop
68
68
  extend AutoCorrector
69
69
 
70
70
  MSG = 'Use `%<prefer>s` instead of `%<current>s`.'
71
+ INDEX_ACCESS_METHODS = %i[[] []=].freeze
71
72
 
72
73
  def_node_matcher :redundant_receiver_and_other, <<~PATTERN
73
74
  {
@@ -140,7 +141,7 @@ module RuboCop
140
141
  end
141
142
 
142
143
  def ignore_chain_node?(node)
143
- node.method?('[]') || node.method?('[]=') || node.arithmetic_operation? || node.comparison_method?
144
+ index_access_method?(node) || node.assignment? || node.arithmetic_operation? || node.comparison_method?
144
145
  end
145
146
 
146
147
  def message(node, replacement)
@@ -190,6 +191,10 @@ module RuboCop
190
191
  replaced += "(#{chain.arguments.map(&:source).join(', ')})" if chain.arguments?
191
192
  left_sibling ? "(#{replaced})" : replaced
192
193
  end
194
+
195
+ def index_access_method?(node)
196
+ INDEX_ACCESS_METHODS.include?(node.method_name)
197
+ end
193
198
  end
194
199
  end
195
200
  end
@@ -45,18 +45,26 @@ module RuboCop
45
45
  private
46
46
 
47
47
  def find_select_node(node, column_name)
48
- node.descendants.detect do |select_candidate|
48
+ select_method_nodes = node.descendants.select do |select_candidate|
49
49
  next if !select_candidate.call_type? || !select_candidate.method?(:select)
50
50
 
51
51
  match_column_name?(select_candidate, column_name)
52
52
  end
53
+
54
+ return unless select_method_nodes.one?
55
+
56
+ select_method_nodes.first
53
57
  end
54
58
 
55
59
  # rubocop:disable Metrics/AbcSize
56
60
  def autocorrect(corrector, select_node, node, preferred_method)
57
- corrector.remove(select_node.parent.loc.dot)
58
- corrector.remove(select_node.loc.selector.begin.join(select_node.source_range.end))
59
- corrector.replace(node.loc.selector.begin.join(node.source_range.end), preferred_method)
61
+ if (parent = select_node.parent).loc?(:dot)
62
+ corrector.remove(parent.loc.dot)
63
+ corrector.remove(select_node.loc.selector.begin.join(select_node.source_range.end))
64
+ corrector.replace(node.loc.selector.begin.join(node.source_range.end), preferred_method)
65
+ else
66
+ corrector.replace(node, "#{select_node.receiver.source}.#{preferred_method}")
67
+ end
60
68
  end
61
69
  # rubocop:enable Metrics/AbcSize
62
70
 
@@ -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.34.1'
7
+ STRING = '2.34.3'
8
8
 
9
9
  def self.document_version
10
10
  STRING.match('\d+\.\d+').to_s
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.34.1
4
+ version: 2.34.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -287,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
287
  - !ruby/object:Gem::Version
288
288
  version: '0'
289
289
  requirements: []
290
- rubygems_version: 4.0.0.dev
290
+ rubygems_version: 4.0.3
291
291
  specification_version: 4
292
292
  summary: Automatic Rails code style checking tool.
293
293
  test_files: []