Add rubocop cop Graphql/EnumNames
What does this MR do and why?
Adds a new rubocop cops to enforce GraphQL enum naming conventions:
Graphql/EnumNames
: Checks the class name and the graphql_name
Screenshots or screen recordings
N/A
How to set up and validate locally
Comment out Exclude
d file paths in the rubocop todo files for Graphql/EnumNames
(.rubocop_todo/graphql/enum_names.yml
) and run:
bundle exec rubocop {app/graphql,ee/app/graphql}
Result
Inspecting 1238 files
............................................................................................................................................................................................................................................................................................................................................................C..............C....................................................C.....CC.............................................CCC...................CC......................................................................................C.....C...................C....C.......................C...................................................C..C....CCC.........CCC..........C.......C....................................................................................................................................................................................................................................................................................................................................C..CCC.C...............................C...C.................C............................................................................................................................
Offenses:
app/graphql/types/access_level_enum.rb:5:18: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'AccessLevelEnum'
^^^^^^^^^^^^^^^^^
app/graphql/types/availability_enum.rb:5:18: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'AvailabilityEnum'
^^^^^^^^^^^^^^^^^^
app/graphql/types/ci/pipeline_config_source_enum.rb:5:5: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class PipelineConfigSourceEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/ci/pipeline_scope_enum.rb:5:5: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class PipelineScopeEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/ci/pipeline_status_enum.rb:5:5: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class PipelineStatusEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/container_expiration_policy_cadence_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class ContainerExpirationPolicyCadenceEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/container_expiration_policy_keep_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class ContainerExpirationPolicyKeepEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/container_expiration_policy_older_than_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class ContainerExpirationPolicyOlderThanEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/data_visualization_palette/color_enum.rb:6:20: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'DataVisualizationColorEnum'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/data_visualization_palette/weight_enum.rb:6:20: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'DataVisualizationWeightEnum'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/merge_strategy_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class MergeStrategyEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/milestone_state_enum.rb:5:18: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'MilestoneStateEnum'
^^^^^^^^^^^^^^^^^^^^
app/graphql/types/packages/cleanup/keep_duplicated_package_files_enum.rb:7:22: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'PackagesCleanupKeepDuplicatedPackageFilesEnum'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/packages/conan/metadatum_file_type_enum.rb:7:22: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'ConanMetadatumFileTypeEnum'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/packages/package_type_enum.rb:5:5: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class PackageTypeEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/security/report_type_enum.rb:6:20: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'SecurityReportTypeEnum'
^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/snippets/blob_action_enum.rb:6:20: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'SnippetBlobActionEnum'
^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/snippets/type_enum.rb:5:5: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class TypeEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/snippets/visibility_scopes_enum.rb:5:5: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class VisibilityScopesEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/sort_direction_enum.rb:5:18: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'SortDirectionEnum'
^^^^^^^^^^^^^^^^^^^
app/graphql/types/todo_action_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class TodoActionEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/todo_state_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class TodoStateEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/todo_target_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class TodoTargetEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/user_callout_feature_name_enum.rb:5:18: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'UserCalloutFeatureNameEnum'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/graphql/types/visibility_levels_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class VisibilityLevelsEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/app/graphql/types/dast_scan_type_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class DastScanTypeEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/app/graphql/types/dast_site_profile_validation_status_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class DastSiteProfileValidationStatusEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/app/graphql/types/dast_site_validation_status_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class DastSiteValidationStatusEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/app/graphql/types/dast_site_validation_strategy_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class DastSiteValidationStrategyEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/app/graphql/types/dast_target_type_enum.rb:4:3: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class DastTargetTypeEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/app/graphql/types/geo/replication_state_enum.rb:5:5: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class ReplicationStateEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/app/graphql/types/geo/verification_state_enum.rb:5:5: C: Graphql/EnumNames: A graphql_name must be defined for a GraphQL enum. See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
class VerificationStateEnum < BaseEnum ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee/app/graphql/types/incident_management/oncall_rotation_length_unit_enum.rb:6:20: C: Graphql/EnumNames: The graphql_name must not contain the string "Enum". See https://docs.gitlab.com/ee/development/api_graphql_styleguide.html#enums
graphql_name 'OncallRotationUnitEnum'
^^^^^^^^^^^^^^^^^^^^^^^^
1238 files inspected, 33 offenses detected
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #31587 (closed)
Related to !102765 (merged)
Edited by Fabian Schneider