Linter rulesProtobufservice-naming

service-naming

Since 0.9.0

This rule checks whether the name of every service of a Protobuf file is in PascalCase.

Rule Details

The service name becomes the base of the names of the generated client and server classes, so it should follow the type naming conventions of the target languages.

The service-naming rule checks every service, and reports Service name '<name>' should be PascalCase for every name that is not in PascalCase. A name is in PascalCase when it starts with an upper-case letter and contains only letters and digits, such as PetOwner (acronyms such as HTTPServer are accepted).

When the name converted to PascalCase differs from the original and is itself valid, the message ends with a suggestion, for example , e.g. '<converted>'. To convert a name, it is split into words at underscores and other separators, at lower-to-upper case changes and before the last capital of an acronym, and the words are capitalized and joined, so pet_owner becomes PetOwner.

Configuration

This rule has no options.

Examples

Good.

syntax = "proto3";

package acme.pets.v1;

service PetService {
  rpc GetPet(GetPetRequest) returns (GetPetResponse);
}

message GetPetRequest {
  string name = 1;
}

message GetPetResponse {
  string name = 1;
}

Bad. The linter reports Service name 'pet_service' should be PascalCase, e.g. 'PetService'.

syntax = "proto3";

package acme.pets.v1;

service pet_service {
  rpc GetPet(GetPetRequest) returns (GetPetResponse);
}

message GetPetRequest {
  string name = 1;
}

message GetPetResponse {
  string name = 1;
}

When Not to Use It

You may disable this rule if the names are part of an existing API that you cannot rename. To allow a single service, add an // apigenie-lint-disable service-naming comment to it.

Compatibility

This rule is compatible with proto3 files. proto2 and editions files are rejected by the reader and are not linted.

Related rules