buflint

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: Apache-2.0 Imports: 9 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

This section is empty.

Functions

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.

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{}
}

Config is the check 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 ConfigBuilder

type ConfigBuilder struct {
	Use                                  []string
	Except                               []string
	IgnoreIDOrCategoryToRootPaths        map[string][]string
	IgnoreRootPaths                      []string
	EnumZeroValueSuffix                  string
	RPCAllowSameRequestResponse          bool
	RPCAllowGoogleProtobufEmptyRequests  bool
	RPCAllowGoogleProtobufEmptyResponses bool
	ServiceSuffix                        string
}

ConfigBuilder is a config builder.

func (ConfigBuilder) NewConfig

func (b ConfigBuilder) NewConfig() (*Config, error)

NewConfig returns a new Config.

type Handler

type Handler interface {
	// LintCheck 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.
	//
	// Annotations will use the image file paths, if these should be relative, use
	// FixAnnotationFilenames.
	LintCheck(
		ctx context.Context,
		lintConfig *Config,
		image bufpb.Image,
	) ([]*analysis.Annotation, error)
}

Handler handles the main lint functionality.

func NewHandler

func NewHandler(
	logger *zap.Logger,
	lintRunner Runner,
) Handler

NewHandler returns a new Handler.

type Runner

type Runner interface {
	// Check runs lint checkers, returning a system error if any system error occurs
	// or returning the annotations otherwise.
	//
	// Annotations will be sorted, but Filenames will not have the roots as a prefix, instead
	// they will be relative to the roots. This should be fixed for linter outputs if image
	// mode is not used.
	Check(context.Context, *Config, []protodesc.File) ([]*analysis.Annotation, error)
}

Runner is a runner.

func NewRunner

func NewRunner(logger *zap.Logger) Runner

NewRunner returns a new Runner.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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