1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-25 22:12:38 +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

@@ -4,6 +4,7 @@ import (
"go/ast"
"go/token"
"github.com/mgechev/revive/internal/astutils"
"github.com/mgechev/revive/lint"
)
@@ -40,7 +41,7 @@ func (w *lintConstantLogicalExpr) Visit(node ast.Node) ast.Visitor {
return w
}
subExpressionsAreNotEqual := gofmt(n.X) != gofmt(n.Y)
subExpressionsAreNotEqual := astutils.GoFmt(n.X) != astutils.GoFmt(n.Y)
if subExpressionsAreNotEqual {
return w // nothing to say
}