From 32a9dcc3df3d171ed0c43dfd62f381c9cca6ca7a Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Fri, 18 Nov 2022 18:01:49 +0100 Subject: [PATCH 1/7] add protolint yaml file --- .protolint.yml | 174 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 .protolint.yml diff --git a/.protolint.yml b/.protolint.yml new file mode 100644 index 0000000000..64eb9b2078 --- /dev/null +++ b/.protolint.yml @@ -0,0 +1,174 @@ +--- +# Lint directives. +lint: + # # Linter files to ignore. + # ignores: + # - id: MESSAGE_NAMES_UPPER_CAMEL_CASE + # files: + # # NOTE: UNIX paths will be properly accepted by both UNIX and Windows. + # - _example/proto/simple.proto + # - id: ENUM_NAMES_UPPER_CAMEL_CASE + # files: + # - path/to/foo.proto + + # # Linter files to walk. + # files: + # # The specific files to exclude. + # exclude: + # # NOTE: UNIX paths will be properly accepted by both UNIX and Windows. + # - path/to/file + + # # Linter directories to walk. + # directories: + # # The specific directories to exclude. + # exclude: + # # NOTE: UNIX paths will be properly accepted by both UNIX and Windows. + # - path/to/dir + + # Linter rules. + # Run `protolint list` to see all available rules. + rules: + # Determines whether or not to include the default set of linters. + no_default: true + + # Set the default to all linters. This option works the other way around as no_default does. + # If you want to enable this option, delete the comment out below and no_default. + # all_default: true + + # The specific linters to add. + add: + - FIELD_NAMES_LOWER_SNAKE_CASE + - MESSAGE_NAMES_UPPER_CAMEL_CASE + - MAX_LINE_LENGTH + - INDENT + # - SERVICE_NAMES_END_WITH + - FIELD_NAMES_EXCLUDE_PREPOSITIONS + - MESSAGE_NAMES_EXCLUDE_PREPOSITIONS + - FILE_NAMES_LOWER_SNAKE_CASE + - IMPORTS_SORTED + - PACKAGE_NAME_LOWER_CASE + - ORDER + - MESSAGES_HAVE_COMMENT + - SERVICES_HAVE_COMMENT + - RPCS_HAVE_COMMENT + - FIELDS_HAVE_COMMENT + - PROTO3_FIELDS_AVOID_REQUIRED + - PROTO3_GROUPS_AVOID + - REPEATED_FIELD_NAMES_PLURALIZED + - ENUMS_HAVE_COMMENT + - ENUM_FIELDS_HAVE_COMMENT + - SYNTAX_CONSISTENT + - RPC_NAMES_UPPER_CAMEL_CASE + # - FILE_HAS_COMMENT + - QUOTE_CONSISTENT + + # The specific linters to remove. + remove: + - RPC_NAMES_UPPER_CAMEL_CASE + + # Linter rules option. + rules_option: + # MAX_LINE_LENGTH rule option. + max_line_length: + # Enforces a maximum line length + max_chars: 80 + # Specifies the character count for tab characters + tab_chars: 2 + + # INDENT rule option. + indent: + # Available styles are 4(4-spaces), 2(2-spaces) or tab. + style: 2 + # Specifies if it should stop considering and inserting new lines at the appropriate positions + # when the inner elements are on the same line. Default is false. + not_insert_newline: true + + # # FILE_NAMES_LOWER_SNAKE_CASE rule option. + # file_names_lower_snake_case: + # excludes: + # - ../proto/invalidFileName.proto + + # QUOTE_CONSISTENT rule option. + quote_consistent: + # Available quote are "double" or "single". + quote: double + + # ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH rule option. + enum_field_names_zero_value_end_with: + suffix: INVALID + + # SERVICE_NAMES_END_WITH rule option. + service_names_end_with: + text: Service + + # FIELD_NAMES_EXCLUDE_PREPOSITIONS rule option. + field_names_exclude_prepositions: + # The specific prepositions to determine if the field name includes. + prepositions: + - for + - at + - of + # The specific keywords including prepositions to ignore. E.g. end_of_support is a term you would like to use, and skip checking. + excludes: + - end_of_support + + # REPEATED_FIELD_NAMES_PLURALIZED rule option. + ## The spec for each rules follows the implementation of https://github.com/gertd/go-pluralize. + ## Plus, you can refer to this rule's test code. + repeated_field_names_pluralized: + uncountable_rules: + - paper + irregular_rules: + Irregular: Regular + + # MESSAGE_NAMES_EXCLUDE_PREPOSITIONS rule option. + message_names_exclude_prepositions: + # The specific prepositions to determine if the message name includes. + prepositions: + - With + - For + - Of + # The specific keywords including prepositions to ignore. E.g. EndOfSupport is a term you would like to use, and skip checking. + excludes: + - EndOfSupport + - + # RPC_NAMES_CASE rule option. + rpc_names_case: + # The specific convention the name should conforms to. + ## Available conventions are "lower_camel_case", "upper_snake_case", or "lower_snake_case". + convention: upper_snake_case + + # MESSAGES_HAVE_COMMENT rule option. + messages_have_comment: + # Comments need to begin with the name of the thing being described. default is false. + should_follow_golang_style: true + + # SERVICES_HAVE_COMMENT rule option. + services_have_comment: + # Comments need to begin with the name of the thing being described. default is false. + should_follow_golang_style: true + + # RPCS_HAVE_COMMENT rule option. + rpcs_have_comment: + # Comments need to begin with the name of the thing being described. default is false. + should_follow_golang_style: true + + # FIELDS_HAVE_COMMENT rule option. + fields_have_comment: + # Comments need to begin with the name of the thing being described. default is false. + should_follow_golang_style: false + + # ENUMS_HAVE_COMMENT rule option. + enums_have_comment: + # Comments need to begin with the name of the thing being described. default is false. + should_follow_golang_style: true + + # ENUM_FIELDS_HAVE_COMMENT rule option. + enum_fields_have_comment: + # Comments need to begin with the name of the thing being described. default is false. + should_follow_golang_style: true + + # # SYNTAX_CONSISTENT rule option. + # syntax_consistent: + # # Default is proto3. + # version: proto2 From 3e22451ca6159cab3f10b2c4cfcdd268563db415 Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Fri, 18 Nov 2022 18:20:55 +0100 Subject: [PATCH 2/7] do not demand repeated field names to be plural --- .protolint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.protolint.yml b/.protolint.yml index 64eb9b2078..099651e675 100644 --- a/.protolint.yml +++ b/.protolint.yml @@ -54,7 +54,7 @@ lint: - FIELDS_HAVE_COMMENT - PROTO3_FIELDS_AVOID_REQUIRED - PROTO3_GROUPS_AVOID - - REPEATED_FIELD_NAMES_PLURALIZED + # - REPEATED_FIELD_NAMES_PLURALIZED - ENUMS_HAVE_COMMENT - ENUM_FIELDS_HAVE_COMMENT - SYNTAX_CONSISTENT From 4baa1e1664b36da925bfa8a6561d0eb98fdb8516 Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Sat, 19 Nov 2022 13:17:30 +0100 Subject: [PATCH 3/7] Make max line length 120 characters --- .protolint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.protolint.yml b/.protolint.yml index 099651e675..edc3f1d31a 100644 --- a/.protolint.yml +++ b/.protolint.yml @@ -71,7 +71,7 @@ lint: # MAX_LINE_LENGTH rule option. max_line_length: # Enforces a maximum line length - max_chars: 80 + max_chars: 120 # Specifies the character count for tab characters tab_chars: 2 From 1133df8fad88d6f01acdc8b9f276899df3c73cf8 Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Sat, 19 Nov 2022 13:24:23 +0100 Subject: [PATCH 4/7] Adjust protolint yaml reflecting PR comments --- .protolint.yml | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.protolint.yml b/.protolint.yml index edc3f1d31a..736dad276e 100644 --- a/.protolint.yml +++ b/.protolint.yml @@ -62,9 +62,9 @@ lint: # - FILE_HAS_COMMENT - QUOTE_CONSISTENT - # The specific linters to remove. - remove: - - RPC_NAMES_UPPER_CAMEL_CASE + # # The specific linters to remove. + # remove: + # - RPC_NAMES_UPPER_CAMEL_CASE # Linter rules option. rules_option: @@ -97,9 +97,9 @@ lint: enum_field_names_zero_value_end_with: suffix: INVALID - # SERVICE_NAMES_END_WITH rule option. - service_names_end_with: - text: Service + # # SERVICE_NAMES_END_WITH rule option. + # service_names_end_with: + # text: Service # FIELD_NAMES_EXCLUDE_PREPOSITIONS rule option. field_names_exclude_prepositions: @@ -108,18 +108,18 @@ lint: - for - at - of - # The specific keywords including prepositions to ignore. E.g. end_of_support is a term you would like to use, and skip checking. - excludes: - - end_of_support - - # REPEATED_FIELD_NAMES_PLURALIZED rule option. - ## The spec for each rules follows the implementation of https://github.com/gertd/go-pluralize. - ## Plus, you can refer to this rule's test code. - repeated_field_names_pluralized: - uncountable_rules: - - paper - irregular_rules: - Irregular: Regular + # # The specific keywords including prepositions to ignore. E.g. end_of_support is a term you would like to use, and skip checking. + # excludes: + # - end_of_support + + # # REPEATED_FIELD_NAMES_PLURALIZED rule option. + # ## The spec for each rules follows the implementation of https://github.com/gertd/go-pluralize. + # ## Plus, you can refer to this rule's test code. + # repeated_field_names_pluralized: + # uncountable_rules: + # - paper + # irregular_rules: + # Irregular: Regular # MESSAGE_NAMES_EXCLUDE_PREPOSITIONS rule option. message_names_exclude_prepositions: @@ -132,11 +132,11 @@ lint: excludes: - EndOfSupport - - # RPC_NAMES_CASE rule option. - rpc_names_case: - # The specific convention the name should conforms to. - ## Available conventions are "lower_camel_case", "upper_snake_case", or "lower_snake_case". - convention: upper_snake_case + # # RPC_NAMES_CASE rule option. + # rpc_names_case: + # # The specific convention the name should conforms to. + # ## Available conventions are "lower_camel_case", "upper_snake_case", or "lower_snake_case". + # convention: upper_snake_case # MESSAGES_HAVE_COMMENT rule option. messages_have_comment: @@ -156,7 +156,7 @@ lint: # FIELDS_HAVE_COMMENT rule option. fields_have_comment: # Comments need to begin with the name of the thing being described. default is false. - should_follow_golang_style: false + should_follow_golang_style: true # ENUMS_HAVE_COMMENT rule option. enums_have_comment: From c18d2f28bcf0751968056ddd9e24fbc55ed3afe3 Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Sat, 19 Nov 2022 13:55:58 +0100 Subject: [PATCH 5/7] Specify protolint yaml in super-linter config --- .github/workflows/super-linter.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml index f65bd714d1..d53827d98b 100644 --- a/.github/workflows/super-linter.yml +++ b/.github/workflows/super-linter.yml @@ -29,6 +29,7 @@ jobs: YAML_CONFIG_FILE: .yamllint VALIDATE_ALL_CODEBASE: false MARKDOWN_CONFIG_FILE: .markdownlint.yml + PROTOBUF_CONFIG_FILE: .protolint.yaml VALIDATE_NATURAL_LANGUAGE: false VALIDATE_OPENAPI: false VALIDATE_JSCPD: false From 18c3c236876a28bb62a34b5d9b9da878431d4cee Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Sat, 19 Nov 2022 13:59:17 +0100 Subject: [PATCH 6/7] fix typo in .yml --- .github/workflows/super-linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml index d53827d98b..37cf5b9150 100644 --- a/.github/workflows/super-linter.yml +++ b/.github/workflows/super-linter.yml @@ -29,7 +29,7 @@ jobs: YAML_CONFIG_FILE: .yamllint VALIDATE_ALL_CODEBASE: false MARKDOWN_CONFIG_FILE: .markdownlint.yml - PROTOBUF_CONFIG_FILE: .protolint.yaml + PROTOBUF_CONFIG_FILE: .protolint.yml VALIDATE_NATURAL_LANGUAGE: false VALIDATE_OPENAPI: false VALIDATE_JSCPD: false From 69baaf883dbea6e999da4035b54c5528fa0bc3cd Mon Sep 17 00:00:00 2001 From: MalteHerrmann Date: Mon, 21 Nov 2022 10:28:26 +0100 Subject: [PATCH 7/7] Comment out linter rule to allow message to be called EndOfSupport --- .protolint.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.protolint.yml b/.protolint.yml index 736dad276e..e965156298 100644 --- a/.protolint.yml +++ b/.protolint.yml @@ -128,10 +128,10 @@ lint: - With - For - Of - # The specific keywords including prepositions to ignore. E.g. EndOfSupport is a term you would like to use, and skip checking. - excludes: - - EndOfSupport - - + # # The specific keywords including prepositions to ignore. E.g. EndOfSupport is a term you would like to use, and skip checking. + # excludes: + # - EndOfSupport + # # RPC_NAMES_CASE rule option. # rpc_names_case: # # The specific convention the name should conforms to.