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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user