buf: github.com/bufbuild/buf/internal/buf/bufcheck/internal Index | Files | Directories

package internal

import "github.com/bufbuild/buf/internal/buf/bufcheck/internal"


Package Files

checker.go checker_builder.go config.go helper.go runner.go vars.go version_spec.go

type CheckFunc Uses

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

CheckFunc is a check function.

type Checker Uses

type Checker struct {
    // contains filtered or unexported fields

Checker provides a base embeddable checker.

func (*Checker) Categories Uses

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

Categories implements Checker.

func (*Checker) ID Uses

func (c *Checker) ID() string

ID implements Checker.

func (*Checker) MarshalJSON Uses

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

MarshalJSON implements Checker.

func (*Checker) Purpose Uses

func (c *Checker) Purpose() string

Purpose implements Checker.

type CheckerBuilder Uses

type CheckerBuilder struct {
    // contains filtered or unexported fields

CheckerBuilder is a checker builder.

func NewCheckerBuilder Uses

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

NewCheckerBuilder returns a new CheckerBuilder.

func NewNopCheckerBuilder Uses

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

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

func (*CheckerBuilder) ID Uses

func (c *CheckerBuilder) ID() string

ID returns the id.

func (*CheckerBuilder) NewChecker Uses

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 Uses

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

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

    AllowCommentIgnores bool

Config is the check config.

type ConfigBuilder Uses

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

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

    AllowCommentIgnores bool

    EnumZeroValueSuffix                  string
    RPCAllowSameRequestResponse          bool
    RPCAllowGoogleProtobufEmptyRequests  bool
    RPCAllowGoogleProtobufEmptyResponses bool
    ServiceSuffix                        string

ConfigBuilder is a config builder.

func (ConfigBuilder) NewConfig Uses

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

NewConfig returns a new Config.

type Helper Uses

type Helper struct {
    // contains filtered or unexported fields

Helper is a helper for checkers.

func NewHelper Uses

func NewHelper(id string, ignoreFunc IgnoreFunc) *Helper

NewHelper returns a new Helper for the given id.

func (*Helper) AddFileAnnotationf Uses

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 Uses

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

FileAnnotations returns the added FileAnnotations.

type IgnoreFunc Uses

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

IgnoreFunc is an ignore function.

type Runner Uses

type Runner struct {
    // contains filtered or unexported fields

Runner is a runner.

func NewRunner Uses

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 Uses

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

Check runs the Checkers.

type VersionSpec Uses

type VersionSpec struct {
    CheckerBuilders   []*CheckerBuilder
    DefaultCategories []string
    AllCategories     []string
    IDToCategories    map[string][]string

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



Package internal imports 12 packages (graph) and is imported by 8 packages. Updated 2020-10-20. Refresh now. Tools for package owners.