vet

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrQueryArgUnsupportedType = errors.New("unexpected query arg type")
	ErrQueryArgUnsafe          = errors.New("potentially unsafe query string")
	ErrQueryArgTODO            = errors.New("TODO: support this type")
)

Functions

func DebugQuery

func DebugQuery(q string)

func ValidateSqlQuery

func ValidateSqlQuery(ctx VetContext, queryStr string) error

Types

type ColumnUsed

type ColumnUsed struct {
	Column   string
	Table    string
	Location int
}

type MatchedSqlFunc

type MatchedSqlFunc struct {
	SSA         *ssa.Function
	QueryArgPos int
}

type QuerySite

type QuerySite struct {
	Called   string
	Position token.Position
	Query    string
	Err      error
}

func CheckDir

func CheckDir(ctx VetContext, dir string, extraMatchers []SqlFuncMatcher) ([]*QuerySite, error)

type SqlFuncMatchRule

type SqlFuncMatchRule struct {
	FuncName string `toml:"func_name"`
	// zero indexed
	QueryArgPos  int    `toml:"query_arg_pos"`
	QueryArgName string `toml:"query_arg_name"`
}

type SqlFuncMatcher

type SqlFuncMatcher struct {
	PkgPath string             `toml:"pkg_path"`
	Rules   []SqlFuncMatchRule `toml:"rules"`
	// contains filtered or unexported fields
}

func (*SqlFuncMatcher) IterPackageExportedFuncs

func (s *SqlFuncMatcher) IterPackageExportedFuncs(cb func(*types.Func))

func (*SqlFuncMatcher) MatchSqlFuncs

func (s *SqlFuncMatcher) MatchSqlFuncs(prog *ssa.Program) []MatchedSqlFunc

func (*SqlFuncMatcher) PackageImported

func (s *SqlFuncMatcher) PackageImported() bool

func (*SqlFuncMatcher) SetGoPackage

func (s *SqlFuncMatcher) SetGoPackage(p *packages.Package)

type SqlVetAnnotation

type SqlVetAnnotation struct {
	Ignore bool
}

func ParseComment

func ParseComment(comment string) (SqlVetAnnotation, error)

type TableUsed

type TableUsed struct {
	Name  string
	Alias string
}

type VetContext

type VetContext struct {
	Schema *schema.Db
}

Jump to

Keyboard shortcuts

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