Commit a6887fac authored by Markus Koller's avatar Markus Koller

Merge branch '322093-disable-graphql-authorizetypes-cop-for-input-types' into 'master'

Disable Graphql/AuthorizeTypes cop for Input Types

See merge request gitlab-org/gitlab!54643
parents 58c84f49 13f59d3d
......@@ -2,7 +2,6 @@
module Types
module Boards
# rubocop: disable Graphql/AuthorizeTypes
class BoardIssueInputBaseType < BaseInputObject
argument :label_name, GraphQL::STRING_TYPE.to_list_type,
required: false,
......@@ -28,7 +27,6 @@ module Types
required: false,
description: 'Filter by reaction emoji.'
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
......
......@@ -2,7 +2,6 @@
module Types
module Boards
# rubocop: disable Graphql/AuthorizeTypes
class NegatedBoardIssueInputType < BoardIssueInputBaseType
end
......@@ -17,7 +16,6 @@ module Types
required: false,
description: 'Search query for issue title or description.'
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
......
......@@ -3,7 +3,6 @@
module Types
module CiConfiguration
module Sast
# rubocop: disable Graphql/AuthorizeTypes
class AnalyzersEntityInputType < BaseInputObject
graphql_name 'SastCiConfigurationAnalyzersEntityInput'
description 'Represents the analyzers entity in SAST CI configuration'
......
......@@ -3,7 +3,6 @@
module Types
module CiConfiguration
module Sast
# rubocop: disable Graphql/AuthorizeTypes
class EntityInputType < BaseInputObject
graphql_name 'SastCiConfigurationEntityInput'
description 'Represents an entity in SAST CI configuration'
......
......@@ -3,7 +3,7 @@
module Types
module CiConfiguration
module Sast
class InputType < BaseInputObject # rubocop:disable Graphql/AuthorizeTypes
class InputType < BaseInputObject
graphql_name 'SastCiConfigurationInput'
description 'Represents a CI configuration of SAST'
......
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
class CommitActionType < BaseInputObject
argument :action, type: Types::CommitActionModeEnum, required: true,
description: 'The action to perform, create, delete, move, update, chmod.'
......@@ -18,5 +17,4 @@ module Types
argument :encoding, type: Types::CommitEncodingEnum, required: false,
description: 'Encoding of the file. Default is text.'
end
# rubocop: enable Graphql/AuthorizeTypes
end
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
class DiffPathsInputType < BaseInputObject
argument :old_path, GraphQL::STRING_TYPE, required: false,
description: 'The path of the file on the start sha.'
argument :new_path, GraphQL::STRING_TYPE, required: false,
description: 'The path of the file on the head sha.'
end
# rubocop: enable Graphql/AuthorizeTypes
end
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
class JiraUsersMappingInputType < BaseInputObject
graphql_name 'JiraUsersMappingInputType'
......@@ -14,5 +13,4 @@ module Types
required: false,
description: 'Id of the GitLab user.'
end
# rubocop: enable Graphql/AuthorizeTypes
end
......@@ -2,7 +2,6 @@
module Types
module Notes
# rubocop: disable Graphql/AuthorizeTypes
class DiffImagePositionInputType < DiffPositionBaseInputType
graphql_name 'DiffImagePositionInput'
......@@ -15,6 +14,5 @@ module Types
argument :height, GraphQL::INT_TYPE, required: true,
description: copy_field_description(Types::Notes::DiffPositionType, :height)
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
......@@ -2,7 +2,6 @@
module Types
module Notes
# rubocop: disable Graphql/AuthorizeTypes
class DiffPositionBaseInputType < BaseInputObject
argument :head_sha, GraphQL::STRING_TYPE, required: true,
description: copy_field_description(Types::DiffRefsType, :head_sha)
......@@ -17,6 +16,5 @@ module Types
description: 'The paths of the file that was changed. ' \
'Both of the properties of this input are optional, but at least one of them is required'
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
......@@ -2,7 +2,6 @@
module Types
module Notes
# rubocop: disable Graphql/AuthorizeTypes
class DiffPositionInputType < DiffPositionBaseInputType
graphql_name 'DiffPositionInput'
......@@ -11,6 +10,5 @@ module Types
argument :new_line, GraphQL::INT_TYPE, required: false,
description: copy_field_description(Types::Notes::DiffPositionType, :new_line)
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
......@@ -3,8 +3,6 @@
module Types
module Notes
# InputType used for updateImageDiffNote mutation.
#
# rubocop: disable Graphql/AuthorizeTypes
class UpdateDiffImagePositionInputType < BaseInputObject
graphql_name 'UpdateDiffImagePositionInput'
......@@ -32,6 +30,5 @@ module Types
end
end
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
class RangeInputType < BaseInputObject
def self.[](type, closed = true)
@subtypes ||= {}
......@@ -25,5 +24,4 @@ module Types
to_h
end
end
# rubocop: enable Graphql/AuthorizeTypes
end
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
class ReleaseAssetLinkInputType < BaseInputObject
graphql_name 'ReleaseAssetLinkInput'
description 'Fields that are available when modifying a release asset link'
......
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
class ReleaseAssetsInputType < BaseInputObject
graphql_name 'ReleaseAssetsInput'
description 'Fields that are available when modifying release assets'
......
......@@ -2,7 +2,7 @@
module Types
module Snippets
class BlobActionInputType < BaseInputObject # rubocop:disable Graphql/AuthorizeTypes
class BlobActionInputType < BaseInputObject
graphql_name 'SnippetBlobActionInputType'
description 'Represents an action to perform over a snippet file'
......
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
class TimeframeInputType < RangeInputType[::Types::DateType]
graphql_name 'Timeframe'
description 'A time-frame defined as a closed inclusive range of two dates'
end
# rubocop: enable Graphql/AuthorizeTypes
end
......@@ -2,7 +2,6 @@
module Types
module AlertManagement
# rubocop: disable Graphql/AuthorizeTypes
class PayloadAlertFieldInputType < BaseInputObject
graphql_name 'AlertManagementPayloadAlertFieldInput'
description 'Field that are available while modifying the custom mapping attributes for an HTTP integration'
......
......@@ -2,7 +2,6 @@
module Types
module ComplianceManagement
# rubocop: disable Graphql/AuthorizeTypes
class ComplianceFrameworkInputType < BaseInputObject
graphql_name 'ComplianceFrameworkInput'
......
......@@ -2,7 +2,6 @@
module Types
module EpicTree
# rubocop: disable Graphql/AuthorizeTypes
class EpicTreeNodeInputType < BaseInputObject
graphql_name 'EpicTreeNodeFieldsInputType'
description 'A node of an epic tree.'
......@@ -27,6 +26,5 @@ module Types
required: false,
description: 'ID of the new parent epic.'
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
......@@ -2,7 +2,6 @@
module Types
module IncidentManagement
# rubocop: disable Graphql/AuthorizeTypes
class OncallRotationDateInputType < BaseInputObject
graphql_name 'OncallRotationDateInputType'
description 'Date input type for on-call rotation'
......@@ -27,6 +26,5 @@ module Types
raise Gitlab::Graphql::Errors::ArgumentError, 'Date & time is invalid'
end
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
......@@ -2,7 +2,6 @@
module Types
module IncidentManagement
# rubocop: disable Graphql/AuthorizeTypes
class OncallRotationLengthInputType < BaseInputObject
graphql_name 'OncallRotationLengthInputType'
description 'The rotation length of the on-call rotation'
......@@ -15,6 +14,5 @@ module Types
required: true,
description: 'The unit of the rotation length of the on-call rotation.'
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
......@@ -2,7 +2,6 @@
module Types
module IncidentManagement
# rubocop: disable Graphql/AuthorizeTypes
class OncallUserInputType < BaseInputObject
graphql_name 'OncallUserInputType'
description 'The rotation user and color palette'
......@@ -19,6 +18,5 @@ module Types
required: false,
description: 'A value of DataVisualizationWeightEnum. The color weight to assign to for the on-call user.'
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
......@@ -9,7 +9,7 @@ module RuboCop
# We want to exclude our own basetypes and scalars
ALLOWED_TYPES = %w[BaseEnum BaseScalar BasePermissionType MutationType
QueryType GraphQL::Schema BaseUnion].freeze
QueryType GraphQL::Schema BaseUnion BaseInputObject].freeze
def_node_search :authorize?, <<~PATTERN
(send nil? :authorize ...)
......@@ -29,8 +29,9 @@ module RuboCop
return false unless class_const
return true if class_const.end_with?('Enum')
return true if class_const.end_with?('InputType')
ALLOWED_TYPES.any? { |allowed| class_node.const_name.include?(allowed) }
ALLOWED_TYPES.any? { |allowed| class_const.include?(allowed) }
end
def class_constant(node)
......
......@@ -63,4 +63,34 @@ RSpec.describe RuboCop::Cop::Graphql::AuthorizeTypes do
end
TYPE
end
it 'does not add an offense for subtypes of BaseUnion' do
expect_no_offenses(<<~TYPE)
module Types
class AType < BaseUnion
possible_types Types::Foo, Types::Bar
end
end
TYPE
end
it 'does not add an offense for subtypes of BaseInputObject' do
expect_no_offenses(<<~TYPE)
module Types
class AType < BaseInputObject
argument :a_thing
end
end
TYPE
end
it 'does not add an offense for InputTypes' do
expect_no_offenses(<<~TYPE)
module Types
class AInputType < SomeObjectType
argument :a_thing
end
end
TYPE
end
end
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