diff options
Diffstat (limited to 'rubocop/code_reuse_helpers.rb')
-rw-r--r-- | rubocop/code_reuse_helpers.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/rubocop/code_reuse_helpers.rb b/rubocop/code_reuse_helpers.rb index 45cfa7ba78d..2769da2389c 100644 --- a/rubocop/code_reuse_helpers.rb +++ b/rubocop/code_reuse_helpers.rb @@ -76,10 +76,15 @@ module RuboCop in_app_directory?(node, 'controllers') end + # Returns true if the given node resides in app/graphql or ee/app/graphql. + def in_graphql?(node) + in_app_directory?(node, 'graphql') + end + # Returns true if the given node resides in app/graphql/types, # ee/app/graphql/types, or ee/app/graphql/ee/types. def in_graphql_types?(node) - in_app_directory?(node, 'graphql/types') || in_app_directory?(node, 'graphql/ee/types') + in_graphql_directory?(node, 'types') end # Returns true if the given node resides in lib/api or ee/lib/api. @@ -113,6 +118,13 @@ module RuboCop ) end + # Returns true if the given node resides in app/graphql/{directory}, + # ee/app/graphql/{directory}, or ee/app/graphql/ee/{directory}. + def in_graphql_directory?(node, directory) + in_app_directory?(node, "graphql/#{directory}") || + in_app_directory?(node, "graphql/ee/#{directory}") + end + # Returns the receiver name of a send node. # # For the AST node `(send (const nil? :Foo) ...)` this would return |