analysis

package
v0.0.0-...-7bca272 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:     "serum",
	Doc:      "Checks that any function that has a structured docstring enumerating Serum-style error codes is telling the truth.",
	Requires: []*analysis.Analyzer{inspect.Analyzer},
	Run:      runVerify,
	FactTypes: []analysis.Fact{
		new(ErrorCodes),
		new(ErrorConstructor),
		new(ErrorType),
		new(ErrorInterface),
	},
}

Functions

This section is empty.

Types

type CodeSet

type CodeSet map[string]struct{}

func Difference

func Difference(set, subtrahend CodeSet) CodeSet

Difference creates a new set containing the elements of the given set (lhs), minus the elements in the given subtrahend (rhs). The input sets are not modified.

func Set

func Set(values ...string) CodeSet

Set creates a Set using the provided values.

func SliceToSet

func SliceToSet(slice []string) CodeSet

SliceToSet creates a set containing all values of the given slice, removing duplicates. The slice is not modified.

func Union

func Union(set, other CodeSet) CodeSet

Union returns a set containing all values that appear in either input set. The input sets are not modified.

func (CodeSet) Add

func (set CodeSet) Add(value string)

Add adds a value to the set.

func (CodeSet) Slice

func (set CodeSet) Slice() []string

Slice creates a Slice containing all values of the given set. The set is not modified.

func (CodeSet) String

func (set CodeSet) String() string

type ErrorCodeField

type ErrorCodeField struct {
	Name     string
	Position int
}

ErrorCodeField is part of ErrorType, and declares the field that might be returned by the Code() method of the ree.Error.

func (*ErrorCodeField) String

func (f *ErrorCodeField) String() string

type ErrorCodes

type ErrorCodes struct {
	Codes CodeSet
}

func (*ErrorCodes) AFact

func (*ErrorCodes) AFact()

func (*ErrorCodes) String

func (e *ErrorCodes) String() string

type ErrorConstructor

type ErrorConstructor struct {
	CodeParamPosition int
}

ErrorConstructor is a fact that is used to tag functions that are error constructors, meaning they take an error code parameter (string) and return an error.

For example a constructor function "NewError(code, message string) error { return &Error{code, message} }" gets an ErrorConstructor{CodeParamPosition: 0} fact.

func (*ErrorConstructor) AFact

func (*ErrorConstructor) AFact()

func (*ErrorConstructor) String

func (e *ErrorConstructor) String() string

type ErrorInterface

type ErrorInterface struct {
	// ErrorMethods contains the names of all methods in the interface,
	// that have error codes declared along with their declared error codes.
	//
	// For all types implementing this interface, these methods must be checked to
	// make sure they only contain a subset of the error codes declared in the interface.
	ErrorMethods map[string]CodeSet
}

ErrorInterface is a fact emitted by the analyser, marking an interface as containing methods that declare error codes.

func (*ErrorInterface) AFact

func (*ErrorInterface) AFact()

func (*ErrorInterface) String

func (e *ErrorInterface) String() string

type ErrorType

type ErrorType struct {
	Codes []string        // error codes, or nil
	Field *ErrorCodeField // field information, or nil
}

ErrorType is a fact about a ree.Error type, declaring which error codes Code() might return, and/or what field gets returned by a call to Code().

func (*ErrorType) AFact

func (*ErrorType) AFact()

func (*ErrorType) String

func (e *ErrorType) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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