service-suffix
Since 0.9.0 · In the rulesets: Recommended at warning, Strict at error, All at error
This rule checks whether the name of every service ends with a suffix, Service by default.
Rule details
A common suffix makes services easy to tell apart from messages in the Protobuf files and in the generated code, where the service name becomes the base of the client and server classes.
The service-suffix rule reports Service name '<service>' should end with '<suffix>' for every
service whose name does not end with the suffix. The comparison is case-sensitive.
Turn the rule off if the service names are part of an existing API that you cannot rename.
Configuration
The configuration block can be a string or an object.
If it is a string, its value is the suffix.
If it is an object, it must contain only the suffix property, whose value is the suffix.
The suffix cannot be empty.
Configuration example. The following two examples are equivalent. They specify that service
names must end with API.
version: "1.0"
commands:
lint:
protobuf:
rules:
service-suffix: [warning, API]
version: "1.0"
commands:
lint:
protobuf:
rules:
service-suffix:
- warning
- suffix: API
Examples
Good. With the default configuration.
syntax = "proto3";
package acme.pets.v1;
service PetStoreService {
rpc GetPet(GetPetRequest) returns (GetPetResponse);
}
message GetPetRequest {
string name = 1;
}
message GetPetResponse {
string name = 1;
}
Bad. With the default configuration, the linter reports
Service name 'PetStore' should end with 'Service'.
syntax = "proto3";
package acme.pets.v1;
service PetStore {
rpc GetPet(GetPetRequest) returns (GetPetResponse);
}
message GetPetRequest {
string name = 1;
}
message GetPetResponse {
string name = 1;
}
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.protobuf has the details.
commands:
lint:
protobuf:
rules:
service-suffix: off