diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-20 02:18:09 +0300 |
commit | 6ed4ec3e0b1340f96b7c043ef51d1b33bbe85fde (patch) | |
tree | dc4d20fe6064752c0bd323187252c77e0a89144b /rubocop/cop/gitlab/const_get_inherit_false.rb | |
parent | 9868dae7fc0655bd7ce4a6887d4e6d487690eeed (diff) |
Add latest changes from gitlab-org/gitlab@15-4-stable-eev15.4.0-rc42
Diffstat (limited to 'rubocop/cop/gitlab/const_get_inherit_false.rb')
-rw-r--r-- | rubocop/cop/gitlab/const_get_inherit_false.rb | 10 |
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 |