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