Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-14 03:09:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-14 03:09:32 +0300
commit804348d39bc1815441c6c4d901a2cf32d5136f9a (patch)
treea3ec6279260b84faa6561dfc21dc411a2834387d /rubocop
parent75f2fd2ba85fea64ee1a42f704c4872282f55eb5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/gitlab/strong_memoize_attr.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/rubocop/cop/gitlab/strong_memoize_attr.rb b/rubocop/cop/gitlab/strong_memoize_attr.rb
index 0b3de9d7863..0de581f8ccd 100644
--- a/rubocop/cop/gitlab/strong_memoize_attr.rb
+++ b/rubocop/cop/gitlab/strong_memoize_attr.rb
@@ -34,11 +34,13 @@ module RuboCop
class StrongMemoizeAttr < RuboCop::Cop::Base
extend RuboCop::Cop::AutoCorrector
- MSG = 'Use `strong_memoize_attr`, instead of using `strong_memoize` directly.'
+ STRONG_MEMOIZE_MSG = 'Use `strong_memoize_attr`, instead of using `strong_memoize` directly.'
+ STRONG_MEMOIZE_WITH_MSG =
+ 'Use `strong_memoize_attr`, instead of using `strong_memoize_with` without parameters.'
def_node_matcher :strong_memoize?, <<~PATTERN
(block
- $(send nil? :strong_memoize
+ $(send nil? {:strong_memoize | :strong_memoize_with}
(sym _)
)
(args)
@@ -58,7 +60,14 @@ module RuboCop
corrector = autocorrect_pure_definitions(node.parent, body) if node.parent.def_type?
- add_offense(send_node, &corrector)
+ message = case send_node.method_name
+ when :strong_memoize
+ STRONG_MEMOIZE_MSG
+ when :strong_memoize_with
+ STRONG_MEMOIZE_WITH_MSG
+ end
+
+ add_offense(send_node, message: message, &corrector)
end
private