summaryrefslogtreecommitdiff
path: root/rubocop
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2019-01-16 18:10:38 +0000
committerRémy Coutable <remy@rymai.me>2019-01-16 18:10:38 +0000
commit941f95ec7c3014dd6d12151434cb502379854402 (patch)
tree93f6197dfdbbeee987056df584d499400af34a53 /rubocop
parente058ab10127673dd1f69dd6bf9447339dd8c1c63 (diff)
parent9722158c15300dd4507cbb49b4230ab36b36ae65 (diff)
downloadgitlab-ce-941f95ec7c3014dd6d12151434cb502379854402.tar.gz
Merge branch 'fix-rubocop-ee-module-injection-detection' into 'master'
Fix detecting nested EE constants in RuboCop See merge request gitlab-org/gitlab-ce!24430
Diffstat (limited to 'rubocop')
-rw-r--r--rubocop/cop/inject_enterprise_edition_module.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/rubocop/cop/inject_enterprise_edition_module.rb b/rubocop/cop/inject_enterprise_edition_module.rb
index c8b8aca51ab..1d37b1bd12d 100644
--- a/rubocop/cop/inject_enterprise_edition_module.rb
+++ b/rubocop/cop/inject_enterprise_edition_module.rb
@@ -11,9 +11,13 @@ module RuboCop
METHODS = Set.new(%i[include extend prepend]).freeze
- def_node_matcher :ee_const?, <<~PATTERN
- (const (const _ :EE) _)
- PATTERN
+ def ee_const?(node)
+ line = node.location.expression.source_line
+
+ # We use `match?` here instead of RuboCop's AST matching, as this makes
+ # it far easier to handle nested constants such as `EE::Foo::Bar::Baz`.
+ line.match?(/(\s|\()(::)?EE::/)
+ end
def on_send(node)
return unless METHODS.include?(node.children[1])