internal

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCheckersForCategories

func GetCheckersForCategories(checkers []bufcheck.Checker, allKnownCategories []string, categories []string) ([]bufcheck.Checker, error)

GetCheckersForCategories filters the given Checkers to the categories.

allKnownCategories is all known categories.

Types

type CheckFunc

type CheckFunc func(id string, previousFiles []protodesc.File, files []protodesc.File) ([]*analysis.Annotation, error)

CheckFunc is a check function.

type Checker

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

Checker provides a base embeddable checker.

func (*Checker) Categories

func (c *Checker) Categories() []string

Categories implements Checker.

func (*Checker) ID

func (c *Checker) ID() string

ID implements Checker.

func (*Checker) MarshalJSON

func (c *Checker) MarshalJSON() ([]byte, error)

MarshalJSON implements Checker.

func (*Checker) Purpose

func (c *Checker) Purpose() string

Purpose implements Checker.

type CheckerBuilder

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

CheckerBuilder is a checker builder.

func NewCheckerBuilder

func NewCheckerBuilder(
	id string,
	newPurpose func(ConfigBuilder) (string, error),
	newCheck func(ConfigBuilder) (CheckFunc, error),
) *CheckerBuilder

NewCheckerBuilder returns a new CheckerBuilder.

func NewNopCheckerBuilder

func NewNopCheckerBuilder(
	id string,
	purpose string,
	checkFunc CheckFunc,
) *CheckerBuilder

NewNopCheckerBuilder returns a new CheckerBuilder for the direct purpose and CheckFunc.

func (*CheckerBuilder) ID

func (c *CheckerBuilder) ID() string

ID returns the id.

func (*CheckerBuilder) NewChecker

func (c *CheckerBuilder) NewChecker(configBuilder ConfigBuilder, categories []string) (*Checker, error)

NewChecker returns a new Checker.

Categories will be sorted and Purpose will be prepended with "Checks that " and appended with ".".

Categories is an actual copy from the checkerBuilder.

type Config

type Config struct {
	// Checkers are the 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.

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(
	checkerBuilders []*CheckerBuilder,
	idToCategories map[string][]string,
	defaultCategories []string,
) (*Config, error)

NewConfig returns a new Config.

type Helper

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

Helper is a helper for checkers.

func NewHelper

func NewHelper(id string) *Helper

NewHelper returns a new Helper for the given id.

func (*Helper) AddAnnotationf

func (h *Helper) AddAnnotationf(
	descriptor protodesc.Descriptor,
	location protodesc.Location,
	format string,
	args ...interface{},
)

AddAnnotationf adds an annotation with the id as the Type.

If descriptor is nil, no filename information is added. If location is nil, no line or column information will be added.

func (*Helper) Annotations

func (h *Helper) Annotations() []*analysis.Annotation

Annotations returns the added annotations.

type Runner

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

Runner is a runner.

func NewRunner

func NewRunner(logger *zap.Logger) *Runner

NewRunner returns a new Runner.

func (*Runner) Check

func (r *Runner) Check(ctx context.Context, config *Config, previousFiles []protodesc.File, files []protodesc.File) ([]*analysis.Annotation, error)

Check runs the Checkers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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