Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c5729733
Commit
c5729733
authored
Nov 25, 2019
by
Brett Walker
Committed by
Sean McGivern
Nov 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rubocop should ignore GraphQL enums
when checking for authorization
parent
655e07d1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
11 deletions
+14
-11
app/graphql/types/issuable_sort_enum.rb
app/graphql/types/issuable_sort_enum.rb
+0
-2
app/graphql/types/issue_sort_enum.rb
app/graphql/types/issue_sort_enum.rb
+0
-2
app/graphql/types/issue_state_enum.rb
app/graphql/types/issue_state_enum.rb
+0
-3
app/graphql/types/merge_request_state_enum.rb
app/graphql/types/merge_request_state_enum.rb
+0
-3
rubocop/cop/graphql/authorize_types.rb
rubocop/cop/graphql/authorize_types.rb
+4
-1
spec/rubocop/cop/graphql/authorize_types_spec.rb
spec/rubocop/cop/graphql/authorize_types_spec.rb
+10
-0
No files found.
app/graphql/types/issuable_sort_enum.rb
View file @
c5729733
# frozen_string_literal: true
# frozen_string_literal: true
module
Types
module
Types
# rubocop: disable Graphql/AuthorizeTypes
class
IssuableSortEnum
<
SortEnum
class
IssuableSortEnum
<
SortEnum
graphql_name
'IssuableSort'
graphql_name
'IssuableSort'
description
'Values for sorting issuables'
description
'Values for sorting issuables'
end
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
app/graphql/types/issue_sort_enum.rb
View file @
c5729733
# frozen_string_literal: true
# frozen_string_literal: true
module
Types
module
Types
# rubocop: disable Graphql/AuthorizeTypes
class
IssueSortEnum
<
IssuableSortEnum
class
IssueSortEnum
<
IssuableSortEnum
graphql_name
'IssueSort'
graphql_name
'IssueSort'
description
'Values for sorting issues'
description
'Values for sorting issues'
...
@@ -10,7 +9,6 @@ module Types
...
@@ -10,7 +9,6 @@ module Types
value
'DUE_DATE_DESC'
,
'Due date by descending order'
,
value:
'due_date_desc'
value
'DUE_DATE_DESC'
,
'Due date by descending order'
,
value:
'due_date_desc'
value
'RELATIVE_POSITION_ASC'
,
'Relative position by ascending order'
,
value:
'relative_position_asc'
value
'RELATIVE_POSITION_ASC'
,
'Relative position by ascending order'
,
value:
'relative_position_asc'
end
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
Types
::
IssueSortEnum
.
prepend_if_ee
(
'::EE::Types::IssueSortEnum'
)
Types
::
IssueSortEnum
.
prepend_if_ee
(
'::EE::Types::IssueSortEnum'
)
app/graphql/types/issue_state_enum.rb
View file @
c5729733
# frozen_string_literal: true
# frozen_string_literal: true
module
Types
module
Types
# rubocop: disable Graphql/AuthorizeTypes
# This is a BaseEnum through IssuableEnum, so it does not need authorization
class
IssueStateEnum
<
IssuableStateEnum
class
IssueStateEnum
<
IssuableStateEnum
graphql_name
'IssueState'
graphql_name
'IssueState'
description
'State of a GitLab issue'
description
'State of a GitLab issue'
end
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
app/graphql/types/merge_request_state_enum.rb
View file @
c5729733
# frozen_string_literal: true
# frozen_string_literal: true
module
Types
module
Types
# rubocop: disable Graphql/AuthorizeTypes
# This is a BaseEnum through IssuableEnum, so it does not need authorization
class
MergeRequestStateEnum
<
IssuableStateEnum
class
MergeRequestStateEnum
<
IssuableStateEnum
graphql_name
'MergeRequestState'
graphql_name
'MergeRequestState'
description
'State of a GitLab merge request'
description
'State of a GitLab merge request'
value
'merged'
value
'merged'
end
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
rubocop/cop/graphql/authorize_types.rb
View file @
c5729733
...
@@ -34,7 +34,10 @@ module RuboCop
...
@@ -34,7 +34,10 @@ module RuboCop
end
end
def
whitelisted?
(
class_node
)
def
whitelisted?
(
class_node
)
return
false
unless
class_node
&
.
const_name
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
)
}
WHITELISTED_TYPES
.
any?
{
|
whitelisted
|
class_node
.
const_name
.
include?
(
whitelisted
)
}
end
end
...
...
spec/rubocop/cop/graphql/authorize_types_spec.rb
View file @
c5729733
...
@@ -79,5 +79,15 @@ describe RuboCop::Cop::Graphql::AuthorizeTypes do
...
@@ -79,5 +79,15 @@ describe RuboCop::Cop::Graphql::AuthorizeTypes do
end
end
TYPE
TYPE
end
end
it
'does not add an offense for Enums'
do
expect_no_offenses
(
<<~
TYPE
)
module Types
class ATypeEnum < AnotherEnum
field :a_thing
end
end
TYPE
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment