internal

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckFunc

type CheckFunc func(id string, ignoreFunc IgnoreFunc, previousFiles []protosource.File, files []protosource.File) ([]bufanalysis.FileAnnotation, error)

CheckFunc is a check function.

type Config

type Config struct {
	// Rules are the rules to run.
	//
	// Rules will be sorted by first categories, then id when Configs are
	// created from this package, i.e. created wth ConfigBuilder.NewConfig.
	Rules []*Rule

	IgnoreRootPaths     map[string]struct{}
	IgnoreIDToRootPaths map[string]map[string]struct{}

	AllowCommentIgnores    bool
	IgnoreUnstablePackages bool
}

Config is the check config.

type ConfigBuilder

type ConfigBuilder struct {
	Use    []string
	Except []string

	IgnoreRootPaths               []string
	IgnoreIDOrCategoryToRootPaths map[string][]string

	AllowCommentIgnores    bool
	IgnoreUnstablePackages bool

	EnumZeroValueSuffix                  string
	RPCAllowSameRequestResponse          bool
	RPCAllowGoogleProtobufEmptyRequests  bool
	RPCAllowGoogleProtobufEmptyResponses bool
	ServiceSuffix                        string
}

ConfigBuilder is a config builder.

func (ConfigBuilder) NewConfig

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

NewConfig returns a new Config.

type Helper

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

Helper is a helper for rules.

func NewHelper

func NewHelper(id string, ignoreFunc IgnoreFunc) *Helper

NewHelper returns a new Helper for the given id.

func (*Helper) AddFileAnnotationf added in v0.6.0

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

AddFileAnnotationf adds a FileAnnotation 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) FileAnnotations added in v0.6.0

func (h *Helper) FileAnnotations() []bufanalysis.FileAnnotation

FileAnnotations returns the added FileAnnotations.

type IgnoreFunc added in v0.15.0

type IgnoreFunc func(id string, descriptor protosource.Descriptor, location protosource.Location) bool

IgnoreFunc is an ignore function.

type Rule added in v0.34.0

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

Rule provides a base embeddable rule.

func (*Rule) Categories added in v0.34.0

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

Categories implements Rule.

func (*Rule) ID added in v0.34.0

func (c *Rule) ID() string

ID implements Rule.

func (*Rule) MarshalJSON added in v0.34.0

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

MarshalJSON implements Rule.

func (*Rule) Purpose added in v0.34.0

func (c *Rule) Purpose() string

Purpose implements Rule.

type RuleBuilder added in v0.34.0

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

RuleBuilder is a rule builder.

func NewNopRuleBuilder added in v0.34.0

func NewNopRuleBuilder(
	id string,
	purpose string,
	checkFunc CheckFunc,
) *RuleBuilder

NewNopRuleBuilder returns a new RuleBuilder for the direct purpose and CheckFunc.

func NewRuleBuilder added in v0.34.0

func NewRuleBuilder(
	id string,
	newPurpose func(ConfigBuilder) (string, error),
	newCheck func(ConfigBuilder) (CheckFunc, error),
) *RuleBuilder

NewRuleBuilder returns a new RuleBuilder.

func (*RuleBuilder) ID added in v0.34.0

func (c *RuleBuilder) ID() string

ID returns the id.

func (*RuleBuilder) NewRule added in v0.34.0

func (c *RuleBuilder) NewRule(configBuilder ConfigBuilder, categories []string) (*Rule, error)

NewRule returns a new Rule.

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

Categories is an actual copy from the ruleBuilder.

type Runner

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

Runner is a runner.

func NewRunner

func NewRunner(logger *zap.Logger, ignorePrefix string) *Runner

NewRunner returns a new Runner.

ignorePrefix should be empty if comment ignores are not allowed

func (*Runner) Check

func (r *Runner) Check(ctx context.Context, config *Config, previousFiles []protosource.File, files []protosource.File) ([]bufanalysis.FileAnnotation, error)

Check runs the Rules.

type VersionSpec added in v0.26.0

type VersionSpec struct {
	RuleBuilders      []*RuleBuilder
	DefaultCategories []string
	AllCategories     []string
	IDToCategories    map[string][]string
}

VersionSpec specifies the rules, ids, and categories for a given version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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