Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultWrappedFunctions = map[string][]string{ "github.com/pkg/errors": {"New", "Errorf", "Wrap", "Wrapf", "WithStack"}, } DefaultCleanFunctions = map[string][]string{ "fmt": {"Errorf"}, "errors": {"New"}, "github.com/pkg/errors": {"WithMessage", "WithMessagef"}, } DefaultThreshold = .25 DefaultMaxStackDepth = 25 )
Functions ¶
func NewAnalyzer ¶
Types ¶
type Assignment ¶
type Assignment struct { Stmt *ast.AssignStmt LPos int RPos int }
type ErrStack ¶
type ErrStack struct {
// contains filtered or unexported fields
}
func NewErrStack ¶
type FunctionInfo ¶
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
func (*Plugin) GetLoadMode ¶
type Settings ¶
type Settings struct { // WrappedFunctions - list of functions that are considered to wrap errors. // If you're using some fancy error wrapping library like github.com/pkg/errors, // you may want to add it to this list. // If you want to ignore some functions, simply don't add them to the list. WrappedFunctions FunctionInfo `mapstructure:"wrappedFunctions" yaml:"wrappedFunctions"` // CleanFunctions - list of functions that are considered to clean errors without stacktrace. CleanFunctions FunctionInfo `mapstructure:"cleanFunctions" yaml:"cleanFunctions"` // Threshold in percentage for the number of branches returning wrapped errors to be considered a violation. // Default value is 25%. // That means that if there are 3 sources of error that are non-wrapped and one that is wrapped, ErrStack will report an error. // On the other hand, if there are 4 wrapped sources and only one non-wrapped source, ErrStack will not report an error. Threshold float64 `mapstructure:"threshold" yaml:"threshold"` // MaxStackDepth - how many stack frames to check for before giving up. // May impact performance on large codebases and high value. // Default value is 25. MaxStackDepth int `mapstructure:"maxStackDepth" yaml:"maxStackDepth"` }
func NewDefaultConfig ¶
func NewDefaultConfig() Settings
Click to show internal directories.
Click to hide internal directories.