1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-23 22:04:49 +02:00

refactor: replaces calls to astutils.PickNodes with calls to astutils.SeekNode when possible (#1482)

This commit is contained in:
chavacava
2025-08-23 17:41:10 +02:00
committed by GitHub
parent ccf85a25e5
commit cf4901574e
7 changed files with 58 additions and 17 deletions

View File

@@ -78,9 +78,8 @@ func (w conditionVisitor) Visit(node ast.Node) ast.Visitor {
return w.idents[ident.Name] == struct{}{}
}
uses := astutils.PickNodes(ifStmt.Cond, findUsesOfIdents)
if len(uses) < 1 {
uses := astutils.SeekNode[*ast.Ident](ifStmt.Cond, findUsesOfIdents)
if uses == nil {
return w
}
@@ -88,7 +87,7 @@ func (w conditionVisitor) Visit(node ast.Node) ast.Visitor {
Confidence: 1,
Node: w.fd.Type.Params,
Category: lint.FailureCategoryBadPractice,
Failure: fmt.Sprintf("parameter '%s' seems to be a control flag, avoid control coupling", uses[0]),
Failure: fmt.Sprintf("parameter '%s' seems to be a control flag, avoid control coupling", uses.Name),
})
return nil