1
0
mirror of https://github.com/mgechev/revive.git synced 2025-10-30 23:37:49 +02:00

Prevent empty-block when looping over call expr

This commit is contained in:
Mario Valderrama
2023-04-28 15:38:51 +02:00
committed by chavacava
parent dc6909b49f
commit 55585666b7
2 changed files with 41 additions and 1 deletions

View File

@@ -43,6 +43,13 @@ func (w lintEmptyBlock) Visit(node ast.Node) ast.Visitor {
case *ast.SelectStmt:
w.ignore[n.Body] = true
return w
case *ast.ForStmt:
if len(n.Body.List) == 0 && n.Init == nil && n.Post == nil && n.Cond != nil {
if _, isCall := n.Cond.(*ast.CallExpr); isCall {
w.ignore[n.Body] = true
return w
}
}
case *ast.RangeStmt:
if len(n.Body.List) == 0 {
w.onFailure(lint.Failure{