-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathargument_description.rb
More file actions
37 lines (32 loc) · 867 Bytes
/
argument_description.rb
File metadata and controls
37 lines (32 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true
module RuboCop
module Cop
module GraphQL
# This cop checks if each field has a description.
#
# @example
# # good
#
# class BanUser < BaseMutation
# argument :uuid, ID, required: true, description: "UUID of the user to ban"
# end
#
# # bad
#
# class BanUser < BaseMutation
# argument :uuid, ID, required: true
# end
#
class ArgumentDescription < Base
include RuboCop::GraphQL::NodePattern
MSG = "Missing argument description"
RESTRICT_ON_SEND = %i[argument].freeze
def on_send(node)
return unless argument?(node)
argument = RuboCop::GraphQL::Argument.new(node)
add_offense(node) unless argument.description
end
end
end
end
end