ops: add ops scripts

This commit is contained in:
2026-10-14 13:20:24 -07:00
parent 7c906f525a
commit 6d23a47815
6 changed files with 30 additions and 19 deletions

View File

@@ -27,14 +27,9 @@ var Analyzer = &analysis.Analyzer{
}
func run(pass *analysis.Pass) (any, error) {
result, ok := pass.ResultOf[inspect.Analyzer]
insp, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
if !ok {
return nil, fmt.Errorf("inspect analyzer result is unavailable")
}
insp, ok := result.(*inspector.Inspector)
if !ok {
return nil, fmt.Errorf("inspect analyzer returned %T, want *inspector.Inspector", result)
panic("inspect.Analyzer did not produce *inspector.Inspector")
}
insp.WithStack([]ast.Node{(*ast.IfStmt)(nil)}, func(n ast.Node, isPush bool, stack []ast.Node) bool {
@@ -44,7 +39,7 @@ func run(pass *analysis.Pass) (any, error) {
stmt, ok := n.(*ast.IfStmt)
if !ok {
return true
panic("inspector passed a non-IfStmt node to an IfStmt stack walk")
}
if stmt.Init == nil {
return true