diff --git a/go/ql/src/InconsistentCode/WhitespaceContradictsPrecedence.ql b/go/ql/src/InconsistentCode/WhitespaceContradictsPrecedence.ql index 83ce8ce7eead..77706822f1fb 100644 --- a/go/ql/src/InconsistentCode/WhitespaceContradictsPrecedence.ql +++ b/go/ql/src/InconsistentCode/WhitespaceContradictsPrecedence.ql @@ -67,6 +67,7 @@ class HarmlessNestedExpr extends BinaryExpr { */ predicate interestingNesting(BinaryExpr inner, BinaryExpr outer) { inner = outer.getAChildExpr() and + not isParenthesized(inner, _) and not inner instanceof AssocNestedExpr and not inner instanceof HarmlessNestedExpr } diff --git a/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/ParenthesizedOperands.go b/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/ParenthesizedOperands.go index 1b9d472a6237..07882d38b0a4 100644 --- a/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/ParenthesizedOperands.go +++ b/go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/ParenthesizedOperands.go @@ -5,3 +5,7 @@ package main func weightedMeanGood(a, b float64, countA, countB, total int) float64 { return ((a * float64(countA)) + (b * float64(countB))) / float64(total) } + +func parenthesizedGood(a, b, c int) int { + return (a ^ b)&c +}