Documentation
¶
Index ¶
- Constants
- Variables
- func AppendError(err []error, ruleName string, pos meta.Position, sourceName string, ...) []error
- func BuildError(pos meta.Position, sourceName string, err error) error
- func CheckIsIgnored(comments []*parser.Comment, ruleName string) bool
- func Rules(cfg Config) map[string]lint.Rule
- type CommentEnum
- type CommentEnumValue
- type CommentField
- type CommentMessage
- type CommentOneOf
- type CommentRPC
- type CommentService
- type Config
- type DirectorySamePackage
- type EnumFirstValueZero
- type EnumNoAllowAlias
- type EnumPascalCase
- type EnumValuePrefix
- type EnumValueUpperSnakeCase
- type EnumZeroValueSuffix
- type Error
- type FieldLowerSnakeCase
- type FileLowerSnakeCase
- type ImportNoPublic
- type ImportNoWeak
- type ImportUsed
- type MessagePascalCase
- type OneofLowerSnakeCase
- type PackageDefined
- type PackageDirectoryMatch
- type PackageLowerSnakeCase
- type PackageNoImportCycle
- type PackageSameCSharpNamespace
- type PackageSameDirectory
- type PackageSameGoPackage
- type PackageSameJavaMultipleFiles
- type PackageSameJavaPackage
- type PackageSamePHPNamespace
- type PackageSameRubyPackage
- type PackageSameSwiftPrefix
- type PackageVersionSuffix
- type ProtoValidate
- type RPCNoClientStreaming
- type RPCNoServerStreaming
- type RPCRequestResponseUnique
- type RPCRequestStandardName
- type RPCResponseStandardName
- type RpcPascalCase
- type ServicePascalCase
- type ServiceSuffix
Constants ¶
const ( // Minimal DIRECTORY_SAME_PACKAGE = "DIRECTORY_SAME_PACKAGE" PACKAGE_DEFINED = "PACKAGE_DEFINED" PACKAGE_DIRECTORY_MATCH = "PACKAGE_DIRECTORY_MATCH" PACKAGE_SAME_DIRECTORY = "PACKAGE_SAME_DIRECTORY" // Basic ENUM_FIRST_VALUE_ZERO = "ENUM_FIRST_VALUE_ZERO" ENUM_NO_ALLOW_ALIAS = "ENUM_NO_ALLOW_ALIAS" ENUM_PASCAL_CASE = "ENUM_PASCAL_CASE" ENUM_VALUE_UPPER_SNAKE_CASE = "ENUM_VALUE_UPPER_SNAKE_CASE" FIELD_LOWER_SNAKE_CASE = "FIELD_LOWER_SNAKE_CASE" IMPORT_NO_PUBLIC = "IMPORT_NO_PUBLIC" IMPORT_NO_WEAK = "IMPORT_NO_WEAK" IMPORT_USED = "IMPORT_USED" MESSAGE_PASCAL_CASE = "MESSAGE_PASCAL_CASE" ONEOF_LOWER_SNAKE_CASE = "ONEOF_LOWER_SNAKE_CASE" PACKAGE_LOWER_SNAKE_CASE = "PACKAGE_LOWER_SNAKE_CASE" PACKAGE_SAME_CSHARP_NAMESPACE = "PACKAGE_SAME_CSHARP_NAMESPACE" PACKAGE_SAME_GO_PACKAGE = "PACKAGE_SAME_GO_PACKAGE" PACKAGE_SAME_JAVA_MULTIPLE_FILES = "PACKAGE_SAME_JAVA_MULTIPLE_FILES" PACKAGE_SAME_JAVA_PACKAGE = "PACKAGE_SAME_JAVA_PACKAGE" PACKAGE_SAME_PHP_NAMESPACE = "PACKAGE_SAME_PHP_NAMESPACE" PACKAGE_SAME_RUBY_PACKAGE = "PACKAGE_SAME_RUBY_PACKAGE" PACKAGE_SAME_SWIFT_PREFIX = "PACKAGE_SAME_SWIFT_PREFIX" RPC_PASCAL_CASE = "RPC_PASCAL_CASE" SERVICE_PASCAL_CASE = "SERVICE_PASCAL_CASE" // Default ENUM_VALUE_PREFIX = "ENUM_VALUE_PREFIX" ENUM_ZERO_VALUE_SUFFIX = "ENUM_ZERO_VALUE_SUFFIX" FILE_LOWER_SNAKE_CASE = "FILE_LOWER_SNAKE_CASE" RPC_REQUEST_RESPONSE_UNIQUE = "RPC_REQUEST_RESPONSE_UNIQUE" RPC_REQUEST_STANDARD_NAME = "RPC_REQUEST_STANDARD_NAME" RPC_RESPONSE_STANDARD_NAME = "RPC_RESPONSE_STANDARD_NAME" PACKAGE_VERSION_SUFFIX = "PACKAGE_VERSION_SUFFIX" PROTOVALIDATE = "PROTOVALIDATE" SERVICE_SUFFIX = "SERVICE_SUFFIX" // Comments COMMENT_ENUM = "COMMENT_ENUM" COMMENT_ENUM_VALUE = "COMMENT_ENUM_VALUE" COMMENT_FIELD = "COMMENT_FIELD" COMMENT_MESSAGE = "COMMENT_MESSAGE" COMMENT_ONEOF = "COMMENT_ONEOF" COMMENT_RPC = "COMMENT_RPC" COMMENT_SERVICE = "COMMENT_SERVICE" // UNARY_RPC RPC_NO_CLIENT_STREAMING = "RPC_NO_CLIENT_STREAMING" RPC_NO_SERVER_STREAMING = "RPC_NO_SERVER_STREAMING" // Uncategorized PACKAGE_NO_IMPORT_CYCLE = "PACKAGE_NO_IMPORT_CYCLE" )
Variables ¶
var ( // Minimal ErrDirectorySamePackage = errors.New("different proto files in the same directory should have the same package") ErrPackageIsNotDefined = errors.New("package is not defined") ErrPackageIsNotMatchedWithPath = errors.New("package is not matched with the path") ErrPackageSameDirectory = errors.New("different proto files in the same package should be in the same directory") // Basic ErrEnumFirstValueZero = errors.New("enum first value is not zero") ErrEnumNoAllowAlias = errors.New("enum no allow alias") ErrEnumPascalCase = errors.New("enum is not pascal case") ErrEnumValueUpperSnakeCase = errors.New("enum value is not upper snake case") ErrMessageFieldLowerSnakeCase = errors.New("message field is not lower snake case") ErrImportIsPublic = errors.New("import is public") ErrImportIsWeak = errors.New("import is weak") ErrImportIsNotUsed = errors.New("import is not used") ErrMessagePascalCase = errors.New("message is not pascal case") ErrOneofLowerSnakeCase = errors.New("oneof is not lower snake case") ErrPackageLowerSnakeCase = errors.New("package is not lower snake case") ErrPackageSameCSharpNamespace = errors.New("different proto files in the same package should have the same csharp_namespace") ErrPackageSameGoPackage = errors.New("different proto files in the same package should have the same go_package") ErrPackageSameJavaMultipleFiles = errors.New("different proto files in the same package should have the same java_multiple_files") ErrPackageSameJavaPackage = errors.New("different proto files in the same package should have the same java_package") ErrPackageSamePhpNamespace = errors.New("different proto files in the same package should have the same php_namespace") ErrPackageSameRubyPackage = errors.New("different proto files in the same package should have the same ruby_package") ErrPackageSameSwiftPrefix = errors.New("different proto files in the same package should have the same swift_prefix") ErrRpcPascalCase = errors.New("rpc is not pascal case") ErrServicePascalCase = errors.New("service is not pascal case") // Default ErrEnumValuePrefix = errors.New("enum value prefix is not valid") ErrEnumZeroValueSuffix = errors.New("enum zero value suffix is not valid") ErrFileLowerSnakeCase = errors.New("file is not lower snake case") ErrRPCRequestResponseUnique = errors.New("rpc request and response should be unique") ErrRPCRequestStandardName = errors.New("rpc request should have suffix 'Request'") ErrRPCResponseStandardName = errors.New("rpc response should have suffix 'Response'") ErrPackageVersionSuffix = errors.New("package version suffix is not valid") ErrProtoValidate = errors.New("validate proto") // TODO: This, rule, is not implemented yet ErrServiceSuffix = errors.New("service name should have suffix") // Comments ErrEnumCommentIsEmpty = errors.New("enum comment is empty") ErrEnumValueCommentIsEmpty = errors.New("enum value comment is empty") ErrMessageFieldCommentIsEmpty = errors.New("message field comment is empty") ErrMessageCommentIsEmpty = errors.New("message comment is empty") ErrOneOfCommentIsEmpty = errors.New("oneof comment is empty") ErrRPCCommentIsEmpty = errors.New("rpc comment is empty") ErrServiceCommentIsEmpty = errors.New("service comment is empty") // UNARY_RPC ErrRPCClientStreaming = errors.New("rpc client streaming is forbidden") ErrRPCServerStreaming = errors.New("rpc server streaming is forbidden") // Uncategorized ErrPackageNoImportCycle = errors.New("package has import cycle") // TODO: This, rule, is not implemented yet )
Comment errors.
var (
ErrInvalidRule = errors.New("invalid rule")
)
Functions ¶
func AppendError ¶
func AppendError( err []error, ruleName string, pos meta.Position, sourceName string, comments []*parser.Comment, ) []error
AppendError check if lint error is ignored -> add new error to slice otherwise ignore appending
func BuildError ¶
BuildError creates an Error.
func CheckIsIgnored ¶
CheckIsIgnored check if passed ruleName has to be ignored due to ignore command in comments
Types ¶
type CommentEnum ¶
type CommentEnum struct{}
CommentEnum this rule checks that enums have non-empty comments.
type CommentEnumValue ¶
type CommentEnumValue struct{}
CommentEnumValue this rule checks that enum values have non-empty comments.
type CommentField ¶
type CommentField struct{}
CommentField this rule checks that fields have non-empty comments.
type CommentMessage ¶
type CommentMessage struct{}
CommentMessage this rule checks that messages have non-empty comments.
type CommentOneOf ¶
type CommentOneOf struct{}
CommentOneOf this rule checks that oneofs have non-empty comments.
type CommentRPC ¶
type CommentRPC struct{}
CommentRPC this rule checks that RPCs have non-empty comments.
type CommentService ¶
type CommentService struct{}
CommentService this rule checks that services have non-empty comments.
type Config ¶
type Config struct {
PackageDirectoryMatchRoot string
EnumZeroValueSuffix string
ServiceSuffix string
}
Config is the configuration for the rules.
type DirectorySamePackage ¶
type DirectorySamePackage struct {
// contains filtered or unexported fields
}
DirectorySamePackage this rule checks that all files in a given directory are in the same package.
type EnumFirstValueZero ¶
type EnumFirstValueZero struct{}
EnumFirstValueZero this rule enforces that the first enum value is the zero value, which is a proto3 requirement on build, but isn't required in proto2 on build. The rule enforces that the requirement is also followed in proto2.
type EnumNoAllowAlias ¶
type EnumNoAllowAlias struct{}
EnumNoAllowAlias this rule checks that enums are PascalCase.
type EnumPascalCase ¶
type EnumPascalCase struct{}
EnumPascalCase this rule checks that enums are PascalCase.
type EnumValuePrefix ¶
type EnumValuePrefix struct {
}
EnumValuePrefix this rule requires that all enum value names are prefixed with the enum name.
type EnumValueUpperSnakeCase ¶
type EnumValueUpperSnakeCase struct{}
EnumValueUpperSnakeCase this rule checks that enum values are UPPER_SNAKE_CASE.
type EnumZeroValueSuffix ¶
type EnumZeroValueSuffix struct {
Suffix string `json:"suffix" yaml:"suffix" ENV:"ENUM_ZERO_VALUE_SUFFIX"`
}
EnumZeroValueSuffix this rule requires that all enum values have a zero value with a defined suffix. By default, it verifies that the zero value of all enums ends in _UNSPECIFIED, but the suffix is configurable.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is an error with meta information.
type FieldLowerSnakeCase ¶
type FieldLowerSnakeCase struct{}
FieldLowerSnakeCase this rule checks that field names are lower_snake_case.
type FileLowerSnakeCase ¶
type FileLowerSnakeCase struct {
}
FileLowerSnakeCase this rule says that all .proto files must be named as lower_snake_case.proto. This is the widely accepted standard.
type ImportNoPublic ¶
type ImportNoPublic struct{}
ImportNoPublic this rule outlaws declaring imports as public. If you didn't know that was possible, forget what you just learned in this sentence.
type ImportNoWeak ¶
type ImportNoWeak struct{}
ImportNoWeak similar to the IMPORT_NO_PUBLIC rule, this rule outlaws declaring imports as weak. If you didn't know that was possible, forget what you just learned in this sentence.
type ImportUsed ¶
type ImportUsed struct{}
ImportUsed this rule checks that all the imports declared across your Protobuf files are actually used.
type MessagePascalCase ¶
type MessagePascalCase struct{}
MessagePascalCase this rule checks that messages are PascalCase.
type OneofLowerSnakeCase ¶
type OneofLowerSnakeCase struct{}
OneofLowerSnakeCase this rule checks that oneof names are lower_snake_case.
type PackageDefined ¶
type PackageDefined struct{}
PackageDefined this rule checks that all files have a package declaration.
type PackageDirectoryMatch ¶
type PackageDirectoryMatch struct {
Root string `json:"root" yaml:"root" env:"PACKAGE_DIRECTORY_MATCH_ROOT"`
}
PackageDirectoryMatch is a rule for checking consistency of directory and package names.
type PackageLowerSnakeCase ¶
type PackageLowerSnakeCase struct{}
PackageLowerSnakeCase his rule checks that packages are lower_snake_case.
type PackageNoImportCycle ¶
type PackageNoImportCycle struct {
// contains filtered or unexported fields
}
PackageNoImportCycle this is an extra uncategorized rule that detects package import cycles. The Protobuf compiler outlaws circular file imports, but it's still possible to introduce package cycles, such as these:
type PackageSameCSharpNamespace ¶ added in v0.1.5
type PackageSameCSharpNamespace struct {
// contains filtered or unexported fields
}
PackageSameCSharpNamespace checks that all files with a given package have the same value for the csharp_namespace option.
type PackageSameDirectory ¶
type PackageSameDirectory struct {
// contains filtered or unexported fields
}
PackageSameDirectory this rule checks that all files with a given package are in the same directory.
type PackageSameGoPackage ¶ added in v0.1.5
type PackageSameGoPackage struct {
// contains filtered or unexported fields
}
PackageSameGoPackage checks that all files with a given package have the same value for the go_package option.
type PackageSameJavaMultipleFiles ¶ added in v0.1.5
type PackageSameJavaMultipleFiles struct {
// contains filtered or unexported fields
}
PackageSameJavaMultipleFiles checks that all files with a given package have the same value for the java_multiple_files option.
type PackageSameJavaPackage ¶ added in v0.1.5
type PackageSameJavaPackage struct {
// contains filtered or unexported fields
}
PackageSameJavaPackage checks that all files with a given package have the same value for the java_package option.
type PackageSamePHPNamespace ¶ added in v0.1.5
type PackageSamePHPNamespace struct {
// contains filtered or unexported fields
}
PackageSamePHPNamespace checks that all files with a given package have the same value for the php_namespace option.
type PackageSameRubyPackage ¶ added in v0.1.5
type PackageSameRubyPackage struct {
// contains filtered or unexported fields
}
PackageSameRubyPackage checks that all files with a given package have the same value for the ruby_package option.
type PackageSameSwiftPrefix ¶ added in v0.1.5
type PackageSameSwiftPrefix struct {
// contains filtered or unexported fields
}
PackageSameSwiftPrefix checks that all files with a given package have the same value for the swift_prefix option.
type PackageVersionSuffix ¶
type PackageVersionSuffix struct{}
PackageVersionSuffix this rule enforces that the last component of a package must be a version of the form v\d+, v\d+test.*, v\d+(alpha|beta)\d*, or v\d+p\d+(alpha|beta)\d*, where numbers are >=1.
type ProtoValidate ¶
type ProtoValidate struct{}
ProtoValidate this rule requires that all protovalidate constraints specified are valid.
type RPCNoClientStreaming ¶
type RPCNoClientStreaming struct {
}
RPCNoClientStreaming this rule checks that RPCs aren't client streaming.
type RPCNoServerStreaming ¶
type RPCNoServerStreaming struct {
}
RPCNoServerStreaming this rule checks that RPCs aren't server streaming.
type RPCRequestResponseUnique ¶
type RPCRequestResponseUnique struct {
}
RPCRequestResponseUnique checks that RPCs request and response types are only used in one RPC.
type RPCRequestStandardName ¶
type RPCRequestStandardName struct {
}
RPCRequestStandardName checks that RPC request type names are RPCNameRequest or ServiceNameRPCNameRequest.
type RPCResponseStandardName ¶
type RPCResponseStandardName struct {
}
RPCResponseStandardName checks that RPC response type names are RPCNameResponse or ServiceNameRPCNameResponse.
type RpcPascalCase ¶
type RpcPascalCase struct{}
RpcPascalCase this rule checks that RPCs are PascalCase.
type ServicePascalCase ¶
type ServicePascalCase struct{}
ServicePascalCase this rule checks that services are PascalCase.
type ServiceSuffix ¶
type ServiceSuffix struct {
Suffix string
}
ServiceSuffix this rule enforces that all services are suffixed with Service.
Source Files
¶
- builder.go
- check_lint_ignore.go
- comment_enum.go
- comment_enum_value.go
- comment_field_message.go
- comment_message.go
- comment_one_of.go
- comment_rpc.go
- comment_service.go
- directory_same_package.go
- enum_first_value_zero.go
- enum_no_allow_alias.go
- enum_pascal_case.go
- enum_value_prefix.go
- enum_value_upper_snake_case.go
- enum_zero_value_suffix.go
- error.go
- errors.go
- file_lower_snake_case.go
- import_no_public.go
- import_no_weak.go
- import_used.go
- message_field_lower_snake_case.go
- message_pascal_case.go
- oneof_lower_snake_case.go
- package_defined.go
- package_directory_match.go
- package_lower_snake_case.go
- package_no_import_cycle.go
- package_same_csharp_namespace.go
- package_same_directory.go
- package_same_go_package.go
- package_same_java_multiple_files.go
- package_same_java_package.go
- package_same_php_namespace.go
- package_same_ruby_package.go
- package_same_swift_prefix.go
- package_version_suffix.go
- protovalidate.go
- rpc_no_client_streaming.go
- rpc_no_server_streaming.go
- rpc_pascal_case.go
- rpc_request_response_unique.go
- rpc_request_standard_name.go
- rpc_response_standard_name.go
- service_pascal_case.go
- service_suffix.go