Add AST analysis tools and go run/test execution tools

This commit is contained in:
Ian Gulliver
2025-06-27 22:54:45 -07:00
parent 9e94d0693b
commit ee04ab585a
18 changed files with 3796 additions and 5 deletions

View File

@@ -34,7 +34,7 @@ func findErrors(dir string) ([]ErrorInfo, error) {
case *ast.ExprStmt:
if call, ok := x.X.(*ast.CallExpr); ok {
// Check if this function likely returns an error
if returnsError(call, file) {
if callReturnsError(call) {
pos := fset.Position(call.Pos())
context := extractContext(src, pos)
info.UnhandledErrors = append(info.UnhandledErrors, ErrorContext{
@@ -84,7 +84,7 @@ func findErrors(dir string) ([]ErrorInfo, error) {
return errors, err
}
func returnsError(call *ast.CallExpr, file *ast.File) bool {
func callReturnsError(call *ast.CallExpr) bool {
// Simple heuristic: check if the function name suggests it returns an error
switch fun := call.Fun.(type) {
case *ast.Ident: