JavaScript: Introduce new query UnclearOperatorPrecedence.

This commit is contained in:
Max Schaefer
2018-09-28 13:04:52 +01:00
parent a63b7fc215
commit 768368498f
9 changed files with 97 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
| tst.js:1:9:1:17 | 0x0A != 0 | The '!=' operator binds more tightly than '&', which may not be obvious in this case. |
| tst.js:6:1:6:7 | x !== y | The '!==' operator binds more tightly than '&', which may not be obvious in this case. |
| tst.js:10:3:10:6 | b==c | The '==' operator binds more tightly than '&', which may not be obvious in this case. |

View File

@@ -0,0 +1 @@
Expressions/UnclearOperatorPrecedence.ql

View File

@@ -0,0 +1,10 @@
x.f() & 0x0A != 0; // NOT OK
x.f() & (0x0A != 0); // OK
x.f() & 0x0A != 0; // OK
x.f() & 0x0A!=0; // OK
x !== y & 1; // NOT OK
x > 0 & x < 10; // OK
a&b==c; // NOT OK

View File

@@ -0,0 +1 @@
a&b==c; // OK (minified file)