summaryrefslogtreecommitdiff
path: root/rubocop
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-22 21:08:40 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-22 21:08:40 +0000
commit5f66b796766f79f48b5c53a38aa9bfb7f951143b (patch)
tree21c8329f92fed0463f6fd33f2ff512ab7e446f56 /rubocop
parentb486760a6332905cd2ac94b3fade5cbc6a55d21e (diff)
downloadgitlab-ce-5f66b796766f79f48b5c53a38aa9bfb7f951143b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/gitlab/strong_memoize_attr.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/rubocop/cop/gitlab/strong_memoize_attr.rb b/rubocop/cop/gitlab/strong_memoize_attr.rb
index c98aa4765fa..6bae3960854 100644
--- a/rubocop/cop/gitlab/strong_memoize_attr.rb
+++ b/rubocop/cop/gitlab/strong_memoize_attr.rb
@@ -39,7 +39,7 @@ module RuboCop
def_node_matcher :strong_memoize?, <<~PATTERN
(block
$(send nil? :strong_memoize
- (sym $_)
+ (sym _)
)
(args)
$_
@@ -47,21 +47,20 @@ module RuboCop
PATTERN
def on_block(node)
- send_node, attr_name, body = strong_memoize?(node)
+ send_node, body = strong_memoize?(node)
return unless send_node
- corrector = autocorrect_pure_definitions(node.parent, attr_name, body) if node.parent.def_type?
+ corrector = autocorrect_pure_definitions(node.parent, body) if node.parent.def_type?
add_offense(send_node, &corrector)
end
private
- def autocorrect_pure_definitions(def_node, attr_name, body)
+ def autocorrect_pure_definitions(def_node, body)
proc do |corrector|
method_name = def_node.method_name
- attr_suffix = ", :#{attr_name}" if attr_name != method_name
- replacement = "\n#{indent(def_node)}strong_memoize_attr :#{method_name}#{attr_suffix}"
+ replacement = "\n#{indent(def_node)}strong_memoize_attr :#{method_name}"
corrector.insert_after(def_node, replacement)
corrector.replace(def_node.body, body.source)