Skip to content

Commit b476fdd

Browse files
authored
Merge pull request #22675 from owen-mc/go/fix/whitespace-contradicts-precedence-parentheses
Go: fix some FPs in `go/whitespace-contradicts-precedence`
2 parents 4048b13 + fe566f0 commit b476fdd

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎go/ql/src/InconsistentCode/WhitespaceContradictsPrecedence.ql‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class HarmlessNestedExpr extends BinaryExpr {
6767
*/
6868
predicate interestingNesting(BinaryExpr inner, BinaryExpr outer) {
6969
inner = outer.getAChildExpr() and
70+
not isParenthesized(inner, _) and
7071
not inner instanceof AssocNestedExpr and
7172
not inner instanceof HarmlessNestedExpr
7273
}

‎go/ql/test/query-tests/InconsistentCode/WhitespaceContradictsPrecedence/ParenthesizedOperands.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ package main
55
func weightedMeanGood(a, b float64, countA, countB, total int) float64 {
66
return ((a * float64(countA)) + (b * float64(countB))) / float64(total)
77
}
8+
9+
func parenthesizedGood(a, b, c int) int {
10+
return (a ^ b)&c
11+
}

0 commit comments

Comments
 (0)