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:
Diffstat (limited to 'rubocop/cop/gitlab/const_get_inherit_false.rb')
-rw-r--r--rubocop/cop/gitlab/const_get_inherit_false.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/rubocop/cop/gitlab/const_get_inherit_false.rb b/rubocop/cop/gitlab/const_get_inherit_false.rb
index 3d3bbc4c8d3..e44097a8d9e 100644
--- a/rubocop/cop/gitlab/const_get_inherit_false.rb
+++ b/rubocop/cop/gitlab/const_get_inherit_false.rb
@@ -6,7 +6,9 @@ module RuboCop
# Cop that encourages usage of inherit=false for 2nd argument when using const_get.
#
# See https://gitlab.com/gitlab-org/gitlab/issues/27678
- class ConstGetInheritFalse < RuboCop::Cop::Cop
+ class ConstGetInheritFalse < RuboCop::Cop::Base
+ extend RuboCop::Cop::AutoCorrector
+
MSG = 'Use inherit=false when using const_get.'
def_node_matcher :const_get?, <<~PATTERN
@@ -17,11 +19,7 @@ module RuboCop
return unless const_get?(node)
return if second_argument(node)&.false_type?
- add_offense(node, location: :selector)
- end
-
- def autocorrect(node)
- lambda do |corrector|
+ add_offense(node.loc.selector) do |corrector|
if arg = second_argument(node)
corrector.replace(arg.source_range, 'false')
else