rules

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg config.LintConfig) ([]core.Rule, map[string][]string, error)

New returns a map of rules and a map of ignore only rules by configuration.

Types

type CommentEnum

type CommentEnum struct{}

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

func (*CommentEnum) Message

func (c *CommentEnum) Message() string

Message implements lint.Rule.

func (*CommentEnum) Validate

func (c *CommentEnum) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type CommentEnumValue

type CommentEnumValue struct{}

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

func (*CommentEnumValue) Message

func (c *CommentEnumValue) Message() string

Message implements lint.Rule.

func (*CommentEnumValue) Validate

func (c *CommentEnumValue) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type CommentField

type CommentField struct{}

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

func (*CommentField) Message

func (c *CommentField) Message() string

Message implements lint.Rule.

func (*CommentField) Validate

func (c *CommentField) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type CommentMessage

type CommentMessage struct{}

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

func (*CommentMessage) Message

func (c *CommentMessage) Message() string

Message implements lint.Rule.

func (*CommentMessage) Validate

func (c *CommentMessage) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type CommentOneof

type CommentOneof struct{}

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

func (*CommentOneof) Message

func (c *CommentOneof) Message() string

Message implements lint.Rule.

func (*CommentOneof) Validate

func (c *CommentOneof) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type CommentRPC

type CommentRPC struct{}

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

func (*CommentRPC) Message

func (c *CommentRPC) Message() string

Message implements lint.Rule.

func (*CommentRPC) Validate

func (c *CommentRPC) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type CommentService

type CommentService struct{}

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

func (*CommentService) Message

func (c *CommentService) Message() string

Message implements lint.Rule.

func (*CommentService) Validate

func (c *CommentService) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

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) Message

func (d *DirectorySamePackage) Message() string

Message implements lint.Rule.

func (*DirectorySamePackage) Validate

func (d *DirectorySamePackage) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (c *EnumFirstValueZero) Message() string

Message implements lint.Rule.

func (*EnumFirstValueZero) Validate

func (c *EnumFirstValueZero) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type EnumNoAllowAlias

type EnumNoAllowAlias struct{}

EnumNoAllowAlias this rule checks that enums are PascalCase.

func (*EnumNoAllowAlias) Message

func (e *EnumNoAllowAlias) Message() string

Message implements lint.Rule.

func (*EnumNoAllowAlias) Validate

func (e *EnumNoAllowAlias) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type EnumPascalCase

type EnumPascalCase struct{}

EnumPascalCase this rule checks that enums are PascalCase.

func (*EnumPascalCase) Message

func (c *EnumPascalCase) Message() string

Message implements lint.Rule.

func (*EnumPascalCase) Validate

func (c *EnumPascalCase) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (e *EnumValuePrefix) Message() string

Message implements lint.Rule.

func (*EnumValuePrefix) Validate

func (e *EnumValuePrefix) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type EnumValueUpperSnakeCase

type EnumValueUpperSnakeCase struct{}

EnumValueUpperSnakeCase this rule checks that enum values are UPPER_SNAKE_CASE.

func (*EnumValueUpperSnakeCase) Message

func (c *EnumValueUpperSnakeCase) Message() string

Message implements lint.Rule.

func (*EnumValueUpperSnakeCase) Validate

func (c *EnumValueUpperSnakeCase) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (e *EnumZeroValueSuffix) Message() string

Message implements lint.Rule.

func (*EnumZeroValueSuffix) Validate

func (e *EnumZeroValueSuffix) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type FieldLowerSnakeCase

type FieldLowerSnakeCase struct{}

FieldLowerSnakeCase this rule checks that field names are lower_snake_case.

func (*FieldLowerSnakeCase) Message

func (c *FieldLowerSnakeCase) Message() string

Message implements lint.Rule.

func (*FieldLowerSnakeCase) Validate

func (c *FieldLowerSnakeCase) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (f *FileLowerSnakeCase) Message() string

Message implements lint.Rule.

func (*FileLowerSnakeCase) Validate

func (f *FileLowerSnakeCase) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (i *ImportNoPublic) Message() string

Message implements lint.Rule.

func (*ImportNoPublic) Validate

func (i *ImportNoPublic) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (i *ImportNoWeak) Message() string

Message implements lint.Rule.

func (*ImportNoWeak) Validate

func (i *ImportNoWeak) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type ImportUsed

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

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

func (*ImportUsed) Message

func (i *ImportUsed) Message() string

Message implements lint.Rule.

func (*ImportUsed) Validate

func (i *ImportUsed) Validate(checkingProto core.ProtoInfo) ([]core.Issue, error)

Validate implements core.Rule.

type MessagePascalCase

type MessagePascalCase struct{}

MessagePascalCase this rule checks that messages are PascalCase.

func (*MessagePascalCase) Message

func (c *MessagePascalCase) Message() string

Message implements lint.Rule.

func (*MessagePascalCase) Validate

func (c *MessagePascalCase) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type OneofLowerSnakeCase

type OneofLowerSnakeCase struct{}

OneofLowerSnakeCase this rule checks that oneof names are lower_snake_case.

func (*OneofLowerSnakeCase) Message

func (c *OneofLowerSnakeCase) Message() string

Message implements lint.Rule.

func (*OneofLowerSnakeCase) Validate

func (c *OneofLowerSnakeCase) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type PackageDefined

type PackageDefined struct{}

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

func (*PackageDefined) Message

func (p *PackageDefined) Message() string

Message implements lint.Rule.

func (*PackageDefined) Validate

func (p *PackageDefined) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (d *PackageDirectoryMatch) Message() string

Message implements lint.Rule.

func (*PackageDirectoryMatch) Validate

func (d *PackageDirectoryMatch) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type PackageLowerSnakeCase

type PackageLowerSnakeCase struct{}

PackageLowerSnakeCase his rule checks that packages are lower_snake_case.

func (*PackageLowerSnakeCase) Message

func (c *PackageLowerSnakeCase) Message() string

Message implements lint.Rule.

func (*PackageLowerSnakeCase) Validate

func (c *PackageLowerSnakeCase) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (p *PackageNoImportCycle) Message() string

Message implements lint.Rule.

func (*PackageNoImportCycle) Validate

func (p *PackageNoImportCycle) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type PackageSameCsharpNamespace

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) Message

func (p *PackageSameCsharpNamespace) Message() string

Message implements lint.Rule.

func (*PackageSameCsharpNamespace) Validate

func (p *PackageSameCsharpNamespace) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (d *PackageSameDirectory) Message() string

Message implements lint.Rule.

func (*PackageSameDirectory) Validate

func (d *PackageSameDirectory) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type PackageSameGoPackage

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) Message

func (p *PackageSameGoPackage) Message() string

Message implements lint.Rule.

func (*PackageSameGoPackage) Validate

func (p *PackageSameGoPackage) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type PackageSameJavaMultipleFiles

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) Message

func (p *PackageSameJavaMultipleFiles) Message() string

Message implements lint.Rule.

func (*PackageSameJavaMultipleFiles) Validate

func (p *PackageSameJavaMultipleFiles) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type PackageSameJavaPackage

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) Message

func (p *PackageSameJavaPackage) Message() string

Message implements lint.Rule.

func (*PackageSameJavaPackage) Validate

func (p *PackageSameJavaPackage) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type PackageSamePHPNamespace

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) Message

func (p *PackageSamePHPNamespace) Message() string

Message implements lint.Rule.

func (*PackageSamePHPNamespace) Validate

func (p *PackageSamePHPNamespace) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type PackageSameRubyPackage

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) Message

func (p *PackageSameRubyPackage) Message() string

Message implements lint.Rule.

func (*PackageSameRubyPackage) Validate

func (p *PackageSameRubyPackage) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type PackageSameSwiftPrefix

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) Message

func (p *PackageSameSwiftPrefix) Message() string

Message implements lint.Rule.

func (*PackageSameSwiftPrefix) Validate

func (p *PackageSameSwiftPrefix) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (p *PackageVersionSuffix) Message() string

Message implements lint.Rule.

func (*PackageVersionSuffix) Validate

func (p *PackageVersionSuffix) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type ProtoValidate

type ProtoValidate struct{}

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

func (*ProtoValidate) Message

func (p *ProtoValidate) Message() string

Message implements lint.Rule.

func (*ProtoValidate) Validate

func (p *ProtoValidate) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (r *RPCNoClientStreaming) Message() string

Message implements lint.Rule.

func (*RPCNoClientStreaming) Validate

func (r *RPCNoClientStreaming) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type RPCNoServerStreaming

type RPCNoServerStreaming struct {
}

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

func (*RPCNoServerStreaming) Message

func (r *RPCNoServerStreaming) Message() string

Message implements lint.Rule.

func (*RPCNoServerStreaming) Validate

func (r *RPCNoServerStreaming) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type RPCPascalCase

type RPCPascalCase struct{}

RPCPascalCase this rule checks that RPCs are PascalCase.

func (*RPCPascalCase) Message

func (c *RPCPascalCase) Message() string

Message implements lint.Rule.

func (*RPCPascalCase) Validate

func (c *RPCPascalCase) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (r *RPCRequestResponseUnique) Message() string

Message implements lint.Rule.

func (*RPCRequestResponseUnique) Validate

func (r *RPCRequestResponseUnique) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type RPCRequestStandardName

type RPCRequestStandardName struct {
}

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

func (*RPCRequestStandardName) Message

func (r *RPCRequestStandardName) Message() string

Message implements lint.Rule.

func (*RPCRequestStandardName) Validate

func (r *RPCRequestStandardName) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type RPCResponseStandardName

type RPCResponseStandardName struct {
}

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

func (*RPCResponseStandardName) Message

func (r *RPCResponseStandardName) Message() string

Message implements lint.Rule.

func (*RPCResponseStandardName) Validate

func (r *RPCResponseStandardName) Validate(protoInfo core.ProtoInfo) ([]core.Issue, error)

Validate implements lint.Rule.

type ServicePascalCase

type ServicePascalCase struct{}

ServicePascalCase this rule checks that services are PascalCase.

func (*ServicePascalCase) Message

func (c *ServicePascalCase) Message() string

Message implements lint.Rule.

func (*ServicePascalCase) Validate

func (c *ServicePascalCase) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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) Message

func (s *ServiceSuffix) Message() string

Message implements lint.Rule.

func (*ServiceSuffix) Validate

func (s *ServiceSuffix) Validate(protoInfo core.ProtoInfo) ([]core.Issue, 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