Commit b94326d2 authored by Max Woolf's avatar Max Woolf Committed by Peter Leitzen

Replaces problematic language within cop

AuthorizeTypes cop makes use of the term
"whitelist" which has connotations about value
mapped to racial terms.

https://about.gitlab.com/handbook/communication/#top-misused-terms
parent d3306a77
......@@ -8,7 +8,7 @@ module RuboCop
'https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#type-authorization'
# We want to exclude our own basetypes and scalars
WHITELISTED_TYPES = %w[BaseEnum BaseScalar BasePermissionType MutationType
ALLOWED_TYPES = %w[BaseEnum BaseScalar BasePermissionType MutationType
QueryType GraphQL::Schema BaseUnion].freeze
def_node_search :authorize?, <<~PATTERN
......@@ -16,21 +16,21 @@ module RuboCop
PATTERN
def on_class(node)
return if whitelisted?(class_constant(node))
return if whitelisted?(superclass_constant(node))
return if allowed?(class_constant(node))
return if allowed?(superclass_constant(node))
add_offense(node, location: :expression) unless authorize?(node)
end
private
def whitelisted?(class_node)
def allowed?(class_node)
class_const = class_node&.const_name
return false unless class_const
return true if class_const.end_with?('Enum')
WHITELISTED_TYPES.any? { |whitelisted| class_node.const_name.include?(whitelisted) }
ALLOWED_TYPES.any? { |allowed| class_node.const_name.include?(allowed) }
end
def class_constant(node)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment