1
0
mirror of https://github.com/mgechev/revive.git synced 2025-07-17 01:12:27 +02:00

refactor: moves code related to AST from rule.utils into astutils package (#1380)

Modifications summary:

* Moves AST-related functions from rule/utils.go to astutils/ast_utils.go (+ modifies function calls)
* Renames some of these AST-related functions
* Avoids instantiating a printer config at each call to astutils.GoFmt
* Uses astutils.IsIdent and astutils.IsPkgDotName when possible
This commit is contained in:
chavacava
2025-05-26 13:18:38 +02:00
committed by GitHub
parent 87b146c60e
commit 92f28cb5e1
35 changed files with 164 additions and 148 deletions

View File

@ -3,6 +3,7 @@ package rule
import (
"go/ast"
"github.com/mgechev/revive/internal/astutils"
"github.com/mgechev/revive/lint"
)
@ -174,7 +175,7 @@ func (*lintUnconditionalRecursionRule) hasControlExit(node ast.Node) bool {
case *ast.ReturnStmt:
return true
case *ast.CallExpr:
if isIdent(n.Fun, "panic") {
if astutils.IsIdent(n.Fun, "panic") {
return true
}
se, ok := n.Fun.(*ast.SelectorExpr)
@ -197,5 +198,5 @@ func (*lintUnconditionalRecursionRule) hasControlExit(node ast.Node) bool {
return false
}
return len(pick(node, isExit)) != 0
return len(astutils.PickNodes(node, isExit)) != 0
}