rubocop-rails 2.30.2 → 2.30.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: 69854cebe11dde8160c57b94c6ebbe60e7df48c1357aae64b932f73bb2f230ad
4
- data.tar.gz: 04b388703ccde52554cb01f0e04a50291beada4dec9199fbb46b3dd750d8a4ff
3
+ metadata.gz: a45ebdeef3a184afbb85ff1e1685fa978198ee00cf3bbbc0f1cbfa04b56f9dc7
4
+ data.tar.gz: 2d06943201b3836891ed9f8c0bd9a5e2bebd90de7736351add71af9460e271b7
5
5
  SHA512:
6
- metadata.gz: 79fda1fbb14ab98b4472576b7cb776294f3c46eb56c3b0751e47c5fba308615b4f1579a41ea3b14a8c2fb22e19e693ea1e615fe48c5d9fff6f8c857ef887a53f
7
- data.tar.gz: f219f779b57f3ecd44937c02e85872058b453bdd7ce5c83cc1d6ac05175b2c93c01d2548a02c9b46ca26bc2dca6af116611a9d9595d81b53e5a165e47a8b6cf4
6
+ metadata.gz: ed82ce027a4bee9e6dfa16dd763fa856d7b19b96356b918d469ef1274ef0c5a4e8ea5e949c6aaed84ee6d0f290ca838e34e352929640294a6bd4d579c0145cdd
7
+ data.tar.gz: 7e11061742bc02b64742e4219ccfea80d5befb27572cb043d7ebc57c7a616f2fd2c8b829ac08dfad6b644f23d8a0f096c8b571cc5b8e9ecf34e7769f1f551fb4
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
- Note: 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.
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
 
data/config/default.yml CHANGED
@@ -77,6 +77,20 @@ Lint/SafeNavigationChain:
77
77
  - try!
78
78
  - in?
79
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
+
80
94
  Rails:
81
95
  Enabled: true
82
96
  DocumentationBaseURL: https://docs.rubocop.org/rubocop-rails
@@ -353,11 +367,13 @@ Rails/Delegate:
353
367
  Description: 'Prefer delegate method for delegations.'
354
368
  Enabled: true
355
369
  VersionAdded: '0.21'
356
- VersionChanged: '0.50'
370
+ VersionChanged: '2.30'
357
371
  # When set to true, using the target object as a prefix of the
358
372
  # method name without using the `delegate` method will be a
359
373
  # violation. When set to false, this case is legal.
360
374
  EnforceForPrefixed: true
375
+ Exclude:
376
+ - app/controllers/**/*.rb
361
377
 
362
378
  Rails/DelegateAllowBlank:
363
379
  Description: 'Do not use allow_blank as an option to delegate.'
@@ -103,7 +103,7 @@ module RuboCop
103
103
  end
104
104
 
105
105
  def in_where?(node)
106
- send_node = node.each_ancestor(:send, :csend).first
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)
@@ -22,9 +22,9 @@ module RuboCop
22
22
  ].freeze
23
23
 
24
24
  def_node_matcher :create_table_with_block?, <<~PATTERN
25
- (block
25
+ (any_block
26
26
  (send nil? :create_table ...)
27
- (args (arg _var))
27
+ { _ | (args (arg _var)) }
28
28
  _)
29
29
  PATTERN
30
30
  end
@@ -15,6 +15,9 @@ module RuboCop
15
15
  # without using the `delegate` method will be a violation.
16
16
  # When set to `false`, this case is legal.
17
17
  #
18
+ # It is disabled for controllers in order to keep controller actions
19
+ # explicitly defined.
20
+ #
18
21
  # @example
19
22
  # # bad
20
23
  # def bar
@@ -60,7 +60,7 @@ module RuboCop
60
60
  PATTERN
61
61
 
62
62
  def on_block(node)
63
- return if node.each_ancestor(:block, :numblock).any?
63
+ return if node.each_ancestor(:any_block).any?
64
64
 
65
65
  pluck_candidate?(node) do |argument, key|
66
66
  next if key.regexp_type? || !use_one_block_argument?(argument)
@@ -40,7 +40,7 @@ module RuboCop
40
40
 
41
41
  def on_send(node)
42
42
  association_with_reflection(node) do |reflection_class_name|
43
- return if reflection_class_name.value.send_type? && reflection_class_name.value.receiver.nil?
43
+ return if reflection_class_name.value.send_type? && !reflection_class_name.value.receiver&.const_type?
44
44
  return if reflection_class_name.value.lvar_type? && str_assigned?(reflection_class_name)
45
45
 
46
46
  add_offense(reflection_class_name) do |corrector|
@@ -90,7 +90,7 @@ module RuboCop
90
90
  end
91
91
 
92
92
  def nested_relative_date(node, &callback)
93
- return if node.nil? || node.block_type?
93
+ return if node.nil? || node.any_block_type?
94
94
 
95
95
  node.each_child_node do |child|
96
96
  nested_relative_date(child, &callback)
@@ -218,7 +218,7 @@ module RuboCop
218
218
  return unless (last_argument = node.last_argument)
219
219
 
220
220
  drop_table_call(node) do
221
- unless node.parent.block_type? || last_argument.block_pass_type?
221
+ unless node.parent.any_block_type? || last_argument.block_pass_type?
222
222
  add_offense(node, message: format(MSG, action: 'drop_table(without block)'))
223
223
  end
224
224
  end
@@ -182,7 +182,7 @@ module RuboCop
182
182
  def right_assignment_node(assignment)
183
183
  node = assignment.node.child_nodes.first
184
184
 
185
- return node unless node&.block_type?
185
+ return node unless node&.any_block_type?
186
186
 
187
187
  node.send_node
188
188
  end
@@ -305,7 +305,7 @@ module RuboCop
305
305
 
306
306
  node = assignable_node(node)
307
307
  method, sibling_index = find_method_with_sibling_index(node.parent)
308
- return false unless method&.type?(:def, :block)
308
+ return false unless method&.type?(:def, :any_block)
309
309
 
310
310
  method.children.size == node.sibling_index + sibling_index
311
311
  end
@@ -99,7 +99,7 @@ module RuboCop
99
99
  return false unless transaction_method_name?(node.method_name)
100
100
  return false unless (parent = node.parent)
101
101
 
102
- parent.block_type? && parent.body
102
+ parent.any_block_type? && parent.body
103
103
  end
104
104
 
105
105
  def statement(statement_node)
@@ -113,7 +113,7 @@ module RuboCop
113
113
  end
114
114
 
115
115
  def nested_block?(statement_node)
116
- name = statement_node.ancestors.find(&:block_type?).children.first.method_name
116
+ name = statement_node.ancestors.find(&:any_block_type?).children.first.method_name
117
117
  !transaction_method_name?(name)
118
118
  end
119
119
 
@@ -52,7 +52,7 @@ module RuboCop
52
52
  MSG = 'Use `distinct` before `pluck`.'
53
53
  RESTRICT_ON_SEND = %i[uniq].freeze
54
54
 
55
- def_node_matcher :uniq_before_pluck, '[!^block $(send $(send _ :pluck ...) :uniq ...)]'
55
+ def_node_matcher :uniq_before_pluck, '[!^any_block $(send $(send _ :pluck ...) :uniq ...)]'
56
56
 
57
57
  def on_send(node)
58
58
  uniq_before_pluck(node) do |uniq_node, pluck_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.2'
7
+ STRING = '2.30.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.30.2
4
+ version: 2.30.3
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-02-24 00:00:00.000000000 Z
12
+ date: 2025-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport