Documentation ¶
Overview ¶
Package descriptormarshal defines an suite of Analyzers that detects correct setting of timestamps when unmarshaling table descriptors.
Index ¶
Constants ¶
View Source
const Doc = `check for correct unmarshaling of sqlbase descriptors`
Doc documents this pass.
Variables ¶
View Source
var Analyzer = &analysis.Analyzer{ Name: "descriptormarshal", Doc: Doc, Requires: []*analysis.Analyzer{inspect.Analyzer}, Run: func(pass *analysis.Pass) (interface{}, error) { inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector) inspect.Preorder([]ast.Node{ (*ast.CallExpr)(nil), }, func(n ast.Node) { call := n.(*ast.CallExpr) sel, ok := call.Fun.(*ast.SelectorExpr) if !ok { return } obj, ok := pass.TypesInfo.Uses[sel.Sel] if !ok { return } f, ok := obj.(*types.Func) if !ok { return } if f.Pkg() == nil || f.Pkg().Path() != sqlbasePkg || f.Name() != "GetTable" { return } if !isMethodForNamedType(f, "Descriptor") { return } containing := findContainingFunc(pass, n) if isAllowed(containing) { return } pass.Report(analysis.Diagnostic{ Pos: n.Pos(), Message: fmt.Sprintf("Illegal call to Descriptor.GetTable() in %s, see Descriptor.Table()", containing.Name()), }) }) return nil, nil }, }
Analyzer is a linter that ensures there are no calls to sqlbase.Descriptor.GetTable() except where appropriate.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.