bufcheckserverutil

package
v1.42.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Before

func Before(
	ctx context.Context,
	request check.Request,
) (context.Context, check.Request, error)

Before should be attached to each check.Spec that uses the functionality in this package.

func NewBreakingEnumPairRuleHandler

func NewBreakingEnumPairRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		enum bufprotosource.Enum,
		previousEnum bufprotosource.Enum,
	) error,
) check.RuleHandler

NewBreakingEnumPairRuleHandler returns a new check.RuleHandler for the given function.

func NewBreakingEnumValuePairRuleHandler

func NewBreakingEnumValuePairRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		nameToEnumValue map[string]bufprotosource.EnumValue,
		previousNameToEnumValue map[string]bufprotosource.EnumValue,
	) error,
) check.RuleHandler

NewBreakingEnumValuePairRuleHandler returns a new check.RuleHandler for the given function.

func NewBreakingFieldPairRuleHandler

func NewBreakingFieldPairRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		field bufprotosource.Field,
		previousField bufprotosource.Field,
	) error,
) check.RuleHandler

NewBreakingFieldPairRuleHandler returns a new check.RuleHandler for the given function.

func NewBreakingFilePairRuleHandler

func NewBreakingFilePairRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		file bufprotosource.File,
		previousFile bufprotosource.File,
	) error,
) check.RuleHandler

NewBreakingFilePairRuleHandler returns a new check.RuleHandler for the given function.

func NewBreakingMessagePairRuleHandler

func NewBreakingMessagePairRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		message bufprotosource.Message,
		previousMessage bufprotosource.Message,
	) error,
) check.RuleHandler

NewBreakingMessagePairRuleHandler returns a new check.RuleHandler for the given function.

func NewBreakingMethodPairRuleHandler

func NewBreakingMethodPairRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		method bufprotosource.Method,
		previousMethod bufprotosource.Method,
	) error,
) check.RuleHandler

NewBreakingMethodPairRuleHandler returns a new check.RuleHandler for the given function.

func NewBreakingServicePairRuleHandler

func NewBreakingServicePairRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		service bufprotosource.Service,
		previousService bufprotosource.Service,
	) error,
) check.RuleHandler

NewBreakingServicePairRuleHandler returns a new check.RuleHandler for the given function.

func NewLintDirPathToFilesRuleHandler

func NewLintDirPathToFilesRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		dirPath string,
		dirFiles []bufprotosource.File,
	) error,
) check.RuleHandler

NewLintDirPathToFilesRuleHandler returns a new check.RuleHandler for the given function.

The dirFiles slice will only have files for the given directory. The dirFiles slice does not include imports.

func NewLintEnumRuleHandler

func NewLintEnumRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		enum bufprotosource.Enum,
	) error,
) check.RuleHandler

NewLintEnumRuleHandler returns a new check.RuleHandler for the given function.

The function will be called for each Enum within each File in the request.

Files that are imports are skipped.

func NewLintEnumValueRuleHandler

func NewLintEnumValueRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		enumValue bufprotosource.EnumValue,
	) error,
) check.RuleHandler

NewLintEnumValueRuleHandler returns a new check.RuleHandler for the given function.

The function will be called for each EnumValue within each File in the request.

Files that are imports are skipped.

func NewLintFieldRuleHandler

func NewLintFieldRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		field bufprotosource.Field,
	) error,
) check.RuleHandler

NewLintFieldRuleHandler returns a new check.RuleHandler for the given function.

The function will be called for each Field within each File in the request.

Files that are imports are skipped.

func NewLintFileImportRuleHandler

func NewLintFileImportRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		fileImport bufprotosource.FileImport,
	) error,
) check.RuleHandler

NewLintFileImportRuleHandler returns a new check.RuleHandler for the given function.

The function will be called for each FileImport within each File in the request.

Files that are imports are skipped.

func NewLintFileRuleHandler

func NewLintFileRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		file bufprotosource.File,
	) error,
) check.RuleHandler

NewLintFilesRuleHandler returns a new check.RuleHandler for the given function.

The function will be called for each File in the request.

Files that are imports are skipped.

func NewLintFilesRuleHandler

func NewLintFilesRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		files []bufprotosource.File,
	) error,
) check.RuleHandler

NewLintFilesRuleHandler returns a new check.RuleHandler for the given function.

The files slice does not include imports.

func NewLintMessageRuleHandler

func NewLintMessageRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		message bufprotosource.Message,
	) error,
) check.RuleHandler

NewLintMessageRuleHandler returns a new check.RuleHandler for the given function.

The function will be called for each Message within each File in the request.

Files that are imports are skipped.

func NewLintMethodRuleHandler

func NewLintMethodRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		method bufprotosource.Method,
	) error,
) check.RuleHandler

NewLintMethodRuleHandler returns a new check.RuleHandler for the given function.

The function will be called for each Method within each File in the request.

Files that are imports are skipped.

func NewLintOneofRuleHandler

func NewLintOneofRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		oneof bufprotosource.Oneof,
	) error,
) check.RuleHandler

NewLintOneofRuleHandler returns a new check.RuleHandler for the given function.

The function will be called for each Oneof within each File in the request.

Files that are imports are skipped.

func NewLintPackageToFilesRuleHandler

func NewLintPackageToFilesRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		pkg string,
		pkgFiles []bufprotosource.File,
	) error,
) check.RuleHandler

NewLintPackageToFilesRuleHandler returns a new check.RuleHandler for the given function.

The pkgFiles slice will only have files for the given package. The pkgFiles slice does not include imports.

func NewLintServiceRuleHandler

func NewLintServiceRuleHandler(
	f func(
		responseWriter ResponseWriter,
		request Request,
		service bufprotosource.Service,
	) error,
) check.RuleHandler

NewLintServiceRuleHandler returns a new check.RuleHandler for the given function.

The function will be called for each Service within each File in the request.

Files that are imports are skipped.

func NewMultiHandler

func NewMultiHandler(handlers ...check.RuleHandler) check.RuleHandler

NewMultiHandler returns a new check.RuleHandler combined from multiple handlers.

func NewRuleHandler

func NewRuleHandler(
	f func(
		ctx context.Context,
		responseWriter ResponseWriter,
		request Request,
	) error,
) check.RuleHandler

NewRuleHandler returns a new check.RuleHandler for the given function.

Types

type Request

type Request interface {
	check.Request

	// ProtosourceFiles returns the check.Files as bufprotosource.Files.
	ProtosourceFiles() []bufprotosource.File
	// AgainstProtosourceFiles returns the check.AgainstFiles as bufprotosource.Files.
	AgainstProtosourceFiles() []bufprotosource.File
}

Request is a check.Request that also includes bufprotosource functionality.

type ResponseWriter

type ResponseWriter interface {
	check.ResponseWriter

	// AddProtosourceAnnotation adds a check.Annotation for bufprotosource.Locations.
	AddProtosourceAnnotation(
		location bufprotosource.Location,
		againstLocation bufprotosource.Location,
		format string,
		args ...any,
	)
}

ResponseWriter is a check.ResponseWriter that also includes bufprotosource functionality.

type RuleSpecBuilder

type RuleSpecBuilder struct {
	// Required.
	ID string
	// Required.
	Purpose string
	// Required.
	Type           check.RuleType
	Deprecated     bool
	ReplacementIDs []string
	// Required.
	Handler check.RuleHandler
}

RuleSpecBuilder matches check.RuleSpec but without categories.

We have very similar RuleSpecs across our versions of our lint rules, however their categories do change across versions. This allows us to share the basic RuleSpec shape across versions.

func (*RuleSpecBuilder) Build

func (b *RuleSpecBuilder) Build(isDefault bool, categoryIDs []string) *check.RuleSpec

Build builds the RuleSpec for the categories.

Not making categories variadic in case we want to add extra parameters later easily.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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