rules

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildError

func BuildError(pos meta.Position, sourceName string, err error) error

BuildError creates an Error.

func Rules

func Rules(cfg Config) map[string]lint.Rule

Rules returns all rules.

Types

type CommentEnum

type CommentEnum struct{}

CommentEnum this rule checks that enums have non-empty comments.

func (*CommentEnum) Validate

func (c *CommentEnum) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type CommentEnumValue

type CommentEnumValue struct{}

CommentEnumValue this rule checks that enum values have non-empty comments.

func (*CommentEnumValue) Validate

func (c *CommentEnumValue) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type CommentField

type CommentField struct{}

CommentField this rule checks that fields have non-empty comments.

func (*CommentField) Validate

func (c *CommentField) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type CommentMessage

type CommentMessage struct{}

CommentMessage this rule checks that messages have non-empty comments.

func (*CommentMessage) Validate

func (c *CommentMessage) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type CommentOneOf

type CommentOneOf struct{}

CommentOneOf this rule checks that oneofs have non-empty comments.

func (*CommentOneOf) Validate

func (c *CommentOneOf) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type CommentRPC

type CommentRPC struct{}

CommentRPC this rule checks that RPCs have non-empty comments.

func (*CommentRPC) Validate

func (c *CommentRPC) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type CommentService

type CommentService struct{}

CommentService this rule checks that services have non-empty comments.

func (*CommentService) Validate

func (c *CommentService) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type Config

type Config struct {
	PackageDirectoryMatchRoot string
	EnumZeroValueSuffixPrefix string
	ServiceSuffixSuffix       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.

func (*DirectorySamePackage) Validate

func (d *DirectorySamePackage) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (*EnumFirstValueZero) Validate

func (c *EnumFirstValueZero) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type EnumNoAllowAlias

type EnumNoAllowAlias struct{}

EnumNoAllowAlias this rule checks that enums are PascalCase.

func (EnumNoAllowAlias) Validate

func (e EnumNoAllowAlias) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type EnumPascalCase

type EnumPascalCase struct{}

EnumPascalCase this rule checks that enums are PascalCase.

func (*EnumPascalCase) Validate

func (c *EnumPascalCase) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type EnumValuePrefix

type EnumValuePrefix struct {
}

EnumValuePrefix this rule requires that all enum value names are prefixed with the enum name.

func (EnumValuePrefix) Validate

func (e EnumValuePrefix) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type EnumValueUpperSnakeCase

type EnumValueUpperSnakeCase struct{}

EnumValueUpperSnakeCase this rule checks that enum values are UPPER_SNAKE_CASE.

func (*EnumValueUpperSnakeCase) Validate

func (c *EnumValueUpperSnakeCase) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (EnumZeroValueSuffix) Validate

func (e EnumZeroValueSuffix) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is an error with meta information.

func (Error) Error

func (e Error) Error() string

Error implements error.

func (Error) Unwrap

func (e Error) Unwrap() error

Unwrap implements error.

type FieldLowerSnakeCase

type FieldLowerSnakeCase struct{}

FieldLowerSnakeCase this rule checks that field names are lower_snake_case.

func (*FieldLowerSnakeCase) Validate

func (c *FieldLowerSnakeCase) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (FileLowerSnakeCase) Validate

func (f FileLowerSnakeCase) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (ImportNoPublic) Validate

func (i ImportNoPublic) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (ImportNoWeak) Validate

func (i ImportNoWeak) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type ImportUsed

type ImportUsed struct{}

ImportUsed this rule checks that all the imports declared across your Protobuf files are actually used.

func (ImportUsed) Validate

func (i ImportUsed) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type MessagePascalCase

type MessagePascalCase struct{}

MessagePascalCase this rule checks that messages are PascalCase.

func (*MessagePascalCase) Validate

func (c *MessagePascalCase) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type OneofLowerSnakeCase

type OneofLowerSnakeCase struct{}

OneofLowerSnakeCase this rule checks that oneof names are lower_snake_case.

func (*OneofLowerSnakeCase) Validate

func (c *OneofLowerSnakeCase) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type PackageDefined

type PackageDefined struct{}

PackageDefined this rule checks that all files have a package declaration.

func (*PackageDefined) Validate

func (p *PackageDefined) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (*PackageDirectoryMatch) Validate

func (d *PackageDirectoryMatch) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type PackageLowerSnakeCase

type PackageLowerSnakeCase struct{}

PackageLowerSnakeCase his rule checks that packages are lower_snake_case.

func (*PackageLowerSnakeCase) Validate

func (c *PackageLowerSnakeCase) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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:

func (*PackageNoImportCycle) Validate

func (p *PackageNoImportCycle) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (*PackageSameCSharpNamespace) Validate added in v0.1.5

func (p *PackageSameCSharpNamespace) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (*PackageSameDirectory) Validate

func (d *PackageSameDirectory) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (*PackageSameGoPackage) Validate added in v0.1.5

func (p *PackageSameGoPackage) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (*PackageSameJavaMultipleFiles) Validate added in v0.1.5

func (p *PackageSameJavaMultipleFiles) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (*PackageSameJavaPackage) Validate added in v0.1.5

func (p *PackageSameJavaPackage) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (*PackageSamePHPNamespace) Validate added in v0.1.5

func (p *PackageSamePHPNamespace) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (*PackageSameRubyPackage) Validate added in v0.1.5

func (p *PackageSameRubyPackage) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (*PackageSameSwiftPrefix) Validate added in v0.1.5

func (p *PackageSameSwiftPrefix) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

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.

func (PackageVersionSuffix) Validate

func (p PackageVersionSuffix) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type ProtoValidate

type ProtoValidate struct{}

ProtoValidate this rule requires that all protovalidate constraints specified are valid.

func (*ProtoValidate) Validate

func (p *ProtoValidate) Validate(protoInfo lint.ProtoInfo) []error

Validate checks that all protovalidate constraints specified are valid.

type RPCNoClientStreaming

type RPCNoClientStreaming struct {
}

RPCNoClientStreaming this rule checks that RPCs aren't client streaming.

func (RPCNoClientStreaming) Validate

func (R RPCNoClientStreaming) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type RPCNoServerStreaming

type RPCNoServerStreaming struct {
}

RPCNoServerStreaming this rule checks that RPCs aren't server streaming.

func (RPCNoServerStreaming) Validate

func (R RPCNoServerStreaming) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type RPCRequestResponseUnique

type RPCRequestResponseUnique struct {
}

RPCRequestResponseUnique checks that RPCs request and response types are only used in one RPC.

func (RPCRequestResponseUnique) Validate

func (R RPCRequestResponseUnique) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type RPCRequestStandardName

type RPCRequestStandardName struct {
}

RPCRequestStandardName checks that RPC request type names are RPCNameRequest or ServiceNameRPCNameRequest.

func (RPCRequestStandardName) Validate

func (R RPCRequestStandardName) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type RPCResponseStandardName

type RPCResponseStandardName struct {
}

RPCResponseStandardName checks that RPC response type names are RPCNameResponse or ServiceNameRPCNameResponse.

func (RPCResponseStandardName) Validate

func (R RPCResponseStandardName) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type RpcPascalCase

type RpcPascalCase struct{}

RpcPascalCase this rule checks that RPCs are PascalCase.

func (*RpcPascalCase) Validate

func (c *RpcPascalCase) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type ServicePascalCase

type ServicePascalCase struct{}

ServicePascalCase this rule checks that services are PascalCase.

func (*ServicePascalCase) Validate

func (c *ServicePascalCase) Validate(protoInfo lint.ProtoInfo) []error

Validate implements lint.Rule.

type ServiceSuffix

type ServiceSuffix struct {
	Suffix string
}

ServiceSuffix this rule enforces that all services are suffixed with Service.

func (ServiceSuffix) Validate

func (s ServiceSuffix) Validate(protoInfo lint.ProtoInfo) []error

Validate enforces that all services are suffixed with Service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL