uncalled

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2022 License: BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package uncalled defines an Analyzer that checks for missing calls.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAnalyzer

func NewAnalyzer(options ...Option) *analysis.Analyzer

NewAnalyzer returns a new Analyzer configured with options that checks for missing calls.

Types

type Config

type Config struct {
	// DisableAll disables all rules.
	DisableAll bool `yaml:"disable-all" mapstructure:"disable-all"`

	// Disabled disables the given rules.
	Disabled []string

	// Enabled enables specific rules, in combination with disable all.
	Enabled []string

	// Rules are the rules to process, disabled rules will be skipped.
	Rules []Rule
	// contains filtered or unexported fields
}

Config represents the configuration for uncalled Analyzer.

type Expect

type Expect struct {
	// Call is the call to expect on this result.
	// Methods called on the result should start with a "."
	// for example .Err
	Call string

	// Args are the arguments passed to the method.
	// Currently on the count matters.
	Args []string
}

Expect represents a result call expectation.

type Option

type Option func(*analyzer) error

Option represents an Analyzer option.

func ConfigFile

func ConfigFile(file string) Option

ConfigFile is an Analyzer option which loads and merges a config from file to our default config. Default: embedded config.

func ConfigOpt

func ConfigOpt(cfg *Config) Option

ConfigOpt is an Analyzer option which merges in cfg to our default config. Default: embedded config.

func LogLevel added in v0.5.0

func LogLevel(level string) Option

LogLevel is an Analyzer option which configures its log level. Default: info.

type Result

type Result struct {
	// Type is name of the type.
	// If "_" then matches any type.
	// If prefixed by "." then matches any type of specified
	// in its Rule.Packages.
	Type string

	// Pointer specifies if this type should be a pointer to
	// the named TypeName.
	Pointer bool

	// Expect sets the expectation for the result.
	// At least one Result in a rule must have a method specified.
	// If not specified no check it performed.
	Expect *Expect
	// contains filtered or unexported fields
}

Result is a result expected from a rule call.

type Rule

type Rule struct {
	// Name is the name of the rule.
	Name string

	// Category is the category used to report failures for this rule.
	Category string

	// Packages is the list of package imports which to be considered
	// When processing this rule. If one of the listed packages isn't
	// imported by the code being checked the rule is automatically
	// skipped. At least one package must be specified.
	Packages []string

	// Call represents the call to match to trigger rule processing.
	// Methods is a list of method calls on the package which trigger
	// the rule to be checked.
	// TODO: Implemented.
	Methods []string

	// Results represents the results the matched methods return.
	Results []*Result
	// contains filtered or unexported fields
}

Rule represents an individual rule for uncalled Analyzer.

Jump to

Keyboard shortcuts

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