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

fix binexp complexity logic

This commit is contained in:
chavacava
2019-12-14 16:18:53 +01:00
parent 2eae0cd122
commit d877a0d7e8

View File

@@ -148,17 +148,14 @@ type binExprComplexityCalculator struct {
func (v *binExprComplexityCalculator) Visit(n ast.Node) ast.Visitor {
switch n := n.(type) {
case *ast.UnaryExpr:
// TODO (chavacava): confirm if NOT should be taken into account
if n.Op == token.NOT {
v.complexity++
}
case *ast.BinaryExpr:
isLogicOp := n.Op == token.LAND || n.Op == token.LOR
if isLogicOp && n.Op != v.currentOp {
v.complexity++
v.currentOp = n.Op
}
case *ast.ParenExpr:
v.complexity++
}
return v