1
0
mirror of https://github.com/mgechev/revive.git synced 2025-01-10 03:17:11 +02:00

adds tests for Boolean expressions

This commit is contained in:
chavacava 2019-12-16 23:02:43 +01:00
parent e63e7cbd3d
commit e4ac6611aa

View File

@ -33,8 +33,8 @@ func g(f func() bool) string { // MATCH /function g has cognitive complexity 1 (
} }
// Test Boolean expr // Test Boolean expr
func h(a, b, c, d, e, f bool) bool { // MATCH /function h has cognitive complexity 2 (> max enabled 0)/ func h(a, b, c, d, e, f bool) bool { // MATCH /function h has cognitive complexity 3 (> max enabled 0)/
return a && b && c || d || e && f //FIXME: complexity should be 3? return a && b && c || d || e && f // +3
} }
func i(a, b, c, d, e, f bool) bool { // MATCH /function i has cognitive complexity 2 (> max enabled 0)/ func i(a, b, c, d, e, f bool) bool { // MATCH /function i has cognitive complexity 2 (> max enabled 0)/
@ -47,6 +47,10 @@ func j(a, b, c, d, e, f bool) bool { // MATCH /function j has cognitive complexi
return result return result
} }
func j1(a, b, c, d, e, f bool) bool { // MATCH /function j1 has cognitive complexity 2 (> max enabled 0)/
return (a && !(b < 2) || c)
}
// Test Switch expr // Test Switch expr
func k(a, b, c, d, e, f bool) bool { // MATCH /function k has cognitive complexity 1 (> max enabled 0)/ func k(a, b, c, d, e, f bool) bool { // MATCH /function k has cognitive complexity 1 (> max enabled 0)/
switch expr { // +1 switch expr { // +1