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