Back to

Package buflint

Latest Go to latest

The latest major version is .

Published: Jul 24, 2020 | License: Apache-2.0 | Module:


Package buflint contains the linting functionality.

The primary entry point to this package is the Handler.



var AllFormatStrings = append(

AllFormatStrings are all format strings.

func GetAllCheckers

func GetAllCheckers(categories ...string) ([]bufcheck.Checker, error)

GetAllCheckers gets all known checkers for the given categories.

If categories is empty, this returns all checkers as bufcheck.Checkers.

Should only be used for printing.

func PrintFileAnnotations

func PrintFileAnnotations(
	writer io.Writer,
	fileAnnotations []bufanalysis.FileAnnotation,
	formatString string,
) error

PrintFileAnnotations prints the FileAnnotations to the Writer.

Also accepts config-ignore-yaml.

type Checker

type Checker interface {
	// contains filtered or unexported methods

Checker is a checker.

type Config

type Config struct {
	// Checkers are the lint checkers to run.
	// Checkers will be sorted by first categories, then id when Configs are
	// created from this package, i.e. created wth ConfigBuilder.NewConfig.
	Checkers            []Checker
	IgnoreIDToRootPaths map[string]map[string]struct{}
	IgnoreRootPaths     map[string]struct{}
	AllowCommentIgnores bool

Config is the check config.

func NewConfig

func NewConfig(externalConfig ExternalConfig) (*Config, error)

NewConfig returns a new Config.

func (*Config) GetCheckers

func (c *Config) GetCheckers(categories ...string) ([]bufcheck.Checker, error)

GetCheckers returns the checkers for the given categories.

If categories is empty, this returns all checkers as bufcheck.Checkers.

Should only be used for printing.

type ExternalConfig

type ExternalConfig struct {
	Use    []string `json:"use,omitempty" yaml:"use,omitempty"`
	Except []string `json:"except,omitempty" yaml:"except,omitempty"`
	// IgnoreRootPaths
	Ignore []string `json:"ignore,omitempty" yaml:"ignore,omitempty"`
	// IgnoreIDOrCategoryToRootPaths
	IgnoreOnly                           map[string][]string `json:"ignore_only,omitempty" yaml:"ignore_only,omitempty"`
	EnumZeroValueSuffix                  string              `json:"enum_zero_value_suffix,omitempty" yaml:"enum_zero_value_suffix,omitempty"`
	RPCAllowSameRequestResponse          bool                `json:"rpc_allow_same_request_response,omitempty" yaml:"rpc_allow_same_request_response,omitempty"`
	RPCAllowGoogleProtobufEmptyRequests  bool                `json:"rpc_allow_google_protobuf_empty_requests,omitempty" yaml:"rpc_allow_google_protobuf_empty_requests,omitempty"`
	RPCAllowGoogleProtobufEmptyResponses bool                `json:"rpc_allow_google_protobuf_empty_responses,omitempty" yaml:"rpc_allow_google_protobuf_empty_responses,omitempty"`
	ServiceSuffix                        string              `json:"service_suffix,omitempty" yaml:"service_suffix,omitempty"`
	AllowCommentIgnores                  bool                `json:"allow_comment_ignores,omitempty" yaml:"allow_comment_ignores,omitempty"`

ExternalConfig is an external config.

type Handler

type Handler interface {
	// Check runs the lint checks.
	// The image should have source code info for this to work properly.
	// Images should be filtered with regards to imports before passing to this function.
		ctx context.Context,
		config *Config,
		image bufcore.Image,
	) ([]bufanalysis.FileAnnotation, error)

Handler handles the main lint functionality.

func NewHandler

func NewHandler(logger *zap.Logger) Handler

NewHandler returns a new Handler.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier