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 +4 -4
- data/README.md +2 -1
- data/config/default.yml +17 -1
- data/lib/rubocop/cop/mixin/active_record_helper.rb +1 -1
- data/lib/rubocop/cop/mixin/active_record_migrations_helper.rb +2 -2
- data/lib/rubocop/cop/rails/delegate.rb +3 -0
- data/lib/rubocop/cop/rails/pluck.rb +1 -1
- data/lib/rubocop/cop/rails/reflection_class_name.rb +1 -1
- data/lib/rubocop/cop/rails/relative_date_constant.rb +1 -1
- data/lib/rubocop/cop/rails/reversible_migration.rb +1 -1
- data/lib/rubocop/cop/rails/save_bang.rb +2 -2
- data/lib/rubocop/cop/rails/transaction_exit_statement.rb +2 -2
- data/lib/rubocop/cop/rails/uniq_before_pluck.rb +1 -1
- data/lib/rubocop/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a45ebdeef3a184afbb85ff1e1685fa978198ee00cf3bbbc0f1cbfa04b56f9dc7
|
4
|
+
data.tar.gz: 2d06943201b3836891ed9f8c0bd9a5e2bebd90de7736351add71af9460e271b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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: '
|
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(:
|
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)
|
@@ -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(:
|
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
|
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|
|
@@ -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.
|
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&.
|
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, :
|
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.
|
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(&:
|
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, '[!^
|
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|
|
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.
|
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-
|
12
|
+
date: 2025-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|