mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
Code inspect - clean ups (#8445)
This commit is contained in:
@@ -28,7 +28,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@@ -37,7 +37,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.BinaryExpr)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
expr, ok := node.(*ast.BinaryExpr)
|
||||
if !ok {
|
||||
return
|
||||
|
||||
@@ -27,7 +27,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@@ -42,7 +42,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
disallowedFns := []string{"NewSource", "New", "Seed", "Int63", "Uint32", "Uint64", "Int31", "Int",
|
||||
"Int63n", "Int31n", "Intn", "Float64", "Float32", "Perm", "Shuffle", "Read"}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
switch stmt := node.(type) {
|
||||
case *ast.File:
|
||||
// Reset aliases (per file).
|
||||
|
||||
@@ -63,7 +63,7 @@ func init() {
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.AssignStmt)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
switch stmt := node.(type) {
|
||||
case *ast.ExprStmt:
|
||||
if call, ok := stmt.X.(*ast.CallExpr); ok {
|
||||
|
||||
@@ -23,7 +23,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.AssignStmt)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
if ce, ok := node.(*ast.CallExpr); ok && isPkgDot(ce.Fun, "featureconfig", "Init") {
|
||||
reportForbiddenUsage(pass, ce.Pos())
|
||||
return
|
||||
|
||||
@@ -23,7 +23,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@@ -32,7 +32,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.StructType)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
if s, ok := node.(*ast.StructType); ok {
|
||||
if err := malign(node.Pos(), pass.TypesInfo.Types[s].Type.(*types.Struct)); err != nil {
|
||||
pass.Reportf(node.Pos(), err.Error())
|
||||
|
||||
@@ -26,7 +26,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.UnaryExpr)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
switch expr := node.(type) {
|
||||
case *ast.StarExpr:
|
||||
unaryExpr, ok := expr.X.(*ast.UnaryExpr)
|
||||
|
||||
@@ -33,7 +33,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
|
||||
aliases := make(map[string]string)
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
switch stmt := node.(type) {
|
||||
case *ast.File:
|
||||
// Reset aliases (per file).
|
||||
|
||||
@@ -32,7 +32,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
(*ast.ValueSpec)(nil),
|
||||
}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
switch declaration := node.(type) {
|
||||
case *ast.FuncDecl:
|
||||
if declaration.Recv != nil {
|
||||
|
||||
@@ -24,7 +24,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
}
|
||||
@@ -35,7 +35,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||
|
||||
typeInfo := types.Info{Types: make(map[ast.Expr]types.TypeAndValue)}
|
||||
|
||||
inspect.Preorder(nodeFilter, func(node ast.Node) {
|
||||
inspection.Preorder(nodeFilter, func(node ast.Node) {
|
||||
sliceExpr, ok := node.(*ast.SliceExpr)
|
||||
if !ok {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user