Class: RuboCop::Cop::GraphQL::ExtractInputType
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::GraphQL::ExtractInputType
- Includes:
- GraphQL::NodePattern
- Defined in:
- lib/rubocop/cop/graphql/extract_input_type.rb
Constant Summary collapse
- MSG =
"Consider moving arguments to a new input type"
Instance Method Summary collapse
Methods included from GraphQL::NodePattern
#argument?, #field?, #field_definition?, #field_definition_with_body?
Instance Method Details
#on_class(node) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubocop/cop/graphql/extract_input_type.rb', line 29 def on_class(node) schema_member = RuboCop::GraphQL::SchemaMember.new(node) if (body = schema_member.body) arguments = body.select { |node| argument?(node) } excess_arguments = arguments.count - cop_config["MaxArguments"] return unless excess_arguments.positive? arguments.last(excess_arguments).each do |excess_argument| add_offense(excess_argument) end end end |