Skip to content

Draft: Add rubocop-graphql enabling all bundled cop rules

Peter Leitzen requested to merge pl-rubocop-graphql-test into master

What does this MR do and why?

Sneak preview of https://gitlab.com/gitlab-org/gitlab-styles/-/merge_requests/95.

Let's see how https://gitlab.com/gitlab-org/gitlab/-/jobs/1748279921 goes.

🆕 👮

--- before	2021-11-04 14:20:11.404375749 +0100
+++ after	2021-11-04 14:20:19.464747793 +0100
@@ -1,4 +1,4 @@
-# Available cops (797) + config for /home/peter/devel/gitlab/gdk-ee/gitlab: 
+# Available cops (811) + config for /home/peter/devel/gitlab/gdk-ee/gitlab: 
 # Department 'API' (2):
 # Supports --auto-correct
 API/Base:
@@ -527,6 +527,98 @@
   - "/home/peter/devel/gitlab/gdk-ee/gitlab/lib/**/*.rake"
   - "/home/peter/devel/gitlab/gdk-ee/gitlab/spec/**/*"
 
+# Department 'GraphQL' (14):
+GraphQL/ArgumentDescription:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: Ensures all arguments have a description
+
+GraphQL/ArgumentName:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: This cop checks whether argument names are snake_case
+
+GraphQL/ExtractInputType:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: Suggests using input type instead of many arguments
+  MaxArguments: 2
+
+GraphQL/ExtractType:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: Suggests extracting fields with common prefixes to the separate type
+  MaxFields: 2
+  Prefixes:
+  - is
+  - with
+  - avg
+  - min
+  - max
+
+# Supports --auto-correct
+GraphQL/FieldDefinitions:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: Checks consistency of field definitions
+  EnforcedStyle: group_definitions
+  SupportedStyles:
+  - group_definitions
+  - define_resolver_after_definition
+
+GraphQL/FieldDescription:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: Ensures all fields have a description
+
+# Supports --auto-correct
+GraphQL/FieldHashKey:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: Checks :hash_key option is used for appropriate fields
+
+# Supports --auto-correct
+GraphQL/FieldMethod:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: Checks :method option is used for appropriate fields
+
+# Supports --auto-correct
+GraphQL/FieldName:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: This cop checks whether field names are snake_case
+  SafeAutoCorrect: false
+
+GraphQL/LegacyDsl:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: Checks that types are defined with class-based API
+
+GraphQL/ObjectDescription:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: Ensures all types have a description
+  Exclude:
+  - "/home/peter/devel/gitlab/gdk-ee/gitlab/**/*_schema.rb"
+  - "/home/peter/devel/gitlab/gdk-ee/gitlab/**/base_*.rb"
+
+# Supports --auto-correct
+GraphQL/OrderedArguments:
+  Enabled: true
+
+# Supports --auto-correct
+GraphQL/OrderedFields:
+  Enabled: true
+
+GraphQL/ResolverMethodLength:
+  Enabled: true
+  VersionAdded: '0.80'
+  Description: Checks resolver methods are not too long
+  Max: 10
+  CountComments: false
+  ExcludedMethods: []
+
 # Department 'Graphql' (7):
 Graphql/AuthorizeTypes:
   Enabled: true

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Peter Leitzen

Merge request reports