buflint

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package buflint contains the linting functionality.

The primary entry point to this package is the Handler.

Index

Constants

This section is empty.

Variables

View Source
var AllFormatStrings = append(
	bufanalysis.AllFormatStrings,
	"config-ignore-yaml",
)

AllFormatStrings are all format strings.

Functions

func GetAllCheckersV1Beta1 added in v0.26.0

func GetAllCheckersV1Beta1() ([]bufcheck.Checker, error)

GetAllCheckersV1Beta1 gets all known checkers.

Should only be used for printing.

func PrintFileAnnotations added in v0.19.0

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

PrintFileAnnotations prints the FileAnnotations to the Writer.

Also accepts config-ignore-yaml.

Types

type Checker

type Checker interface {
	bufcheck.Checker
	// 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 NewConfigV1Beta1 added in v0.25.0

func NewConfigV1Beta1(externalConfig ExternalConfigV1Beta1) (*Config, error)

NewConfigV1Beta1 returns a new Config.

func (*Config) GetCheckers

func (c *Config) GetCheckers() []bufcheck.Checker

GetCheckers returns the checkers.

type ExternalConfigV1Beta1 added in v0.25.0

type ExternalConfigV1Beta1 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"`
}

ExternalConfigV1Beta1 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.
	Check(
		ctx context.Context,
		config *Config,
		image bufimage.Image,
	) ([]bufanalysis.FileAnnotation, error)
}

Handler handles the main lint functionality.

func NewHandler

func NewHandler(logger *zap.Logger) Handler

NewHandler returns a new Handler.

Directories

Path Synopsis
internal
buflintbuild
Package buflintbuild contains the CheckerBuilders used by buflintv*.
Package buflintbuild contains the CheckerBuilders used by buflintv*.
buflintcheck
Package buflintcheck impelements the check functions.
Package buflintcheck impelements the check functions.
buflintv1beta1
Package buflintv1beta1 contains the VersionSpec for v1beta1.
Package buflintv1beta1 contains the VersionSpec for v1beta1.

Jump to

Keyboard shortcuts

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