remove benign result for js/whitespace-contradicts-precedence related to " | 0" expressions

This commit is contained in:
Erik Krogh Kristensen
2021-01-25 10:43:39 +01:00
parent 0e059cea56
commit d86705fe7a
2 changed files with 15 additions and 1 deletions

View File

@@ -61,6 +61,16 @@ class HarmlessNestedExpr extends BinaryExpr {
}
}
/**
* Holds if contradicting whitespace for `binop` is unlikely to cause confusion.
*/
predicate benignWhitespace(BinaryExpr binop) {
// asm.js like `expr |0` binary expression.
not binop.getParent() instanceof BinaryExpr and
binop.getOperator() = "|" and
binop.getRightOperand().getIntValue() = 0
}
/**
* Holds if `inner` is an operand of `outer`, and the relative precedence
* may not be immediately clear, but is important for the semantics of
@@ -69,7 +79,8 @@ class HarmlessNestedExpr extends BinaryExpr {
predicate interestingNesting(BinaryExpr inner, BinaryExpr outer) {
inner = outer.getAChildExpr() and
not inner instanceof AssocNestedExpr and
not inner instanceof HarmlessNestedExpr
not inner instanceof HarmlessNestedExpr and
not benignWhitespace(outer)
}
from BinaryExpr inner, BinaryExpr outer