Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 48deb30

Browse files
authored
Merge pull request #2573 from max-schaefer/js/generalise-alert-suppression
Approved by asgerf
2 parents 5dcc5b3 + 8d1ad5c commit 48deb30

5 files changed

Lines changed: 36 additions & 4 deletions

File tree

change-notes/1.24/analysis-javascript.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
## General improvements
44

5+
* Alert suppression can now be done with single-line block comments (`/* ... */`) as well as line comments (`// ...`).
6+
7+
* Imports with the `.js` extension can now be resolved to a TypeScript file,
8+
when the import refers to a file generated by TypeScript.
9+
510
* Support for the following frameworks and libraries has been improved:
611
- [react](https://www.npmjs.com/package/react)
712
- [typeahead.js](https://www.npmjs.com/package/typeahead.js)
813
- [Handlebars](https://www.npmjs.com/package/handlebars)
914

10-
- Imports with the `.js` extension can now be resolved to a TypeScript file,
11-
when the import refers to a file generated by TypeScript.
12-
1315
## New queries
1416

1517
| **Query** | **Tags** | **Purpose** |

javascript/ql/src/AlertSuppression.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ class SuppressionComment extends Locatable {
1616

1717
SuppressionComment() {
1818
(
19-
text = this.(LineComment).getText() or
19+
text = this.(Comment).getText() or
2020
text = this.(HTML::CommentNode).getText()
2121
) and
22+
// suppression comments must be single-line
23+
not text.matches("%\n%") and
2224
(
2325
// match `lgtm[...]` anywhere in the comment
2426
annotation = text.regexpFind("(?i)\\blgtm\\s*\\[[^\\]]*\\]", _, _)

javascript/ql/test/query-tests/AlertSuppression/AlertSuppression.expected

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
| tst.js:8:1:8:18 | // lgtm: blah blah | lgtm: blah blah | lgtm | tst.js:8:1:8:18 | suppression range |
1010
| tst.js:9:1:9:32 | // lgtm ... ositive | lgtm blah blah #falsepositive | lgtm | tst.js:9:1:9:32 | suppression range |
1111
| tst.js:10:1:10:39 | //lgtm ... nction] | lgtm [js/invocation-of-non-function] | lgtm [js/invocation-of-non-function] | tst.js:10:1:10:39 | suppression range |
12+
| tst.js:11:1:11:10 | /* lgtm */ | lgtm | lgtm | tst.js:11:1:11:10 | suppression range |
1213
| tst.js:12:1:12:9 | // lgtm[] | lgtm[] | lgtm[] | tst.js:12:1:12:9 | suppression range |
1314
| tst.js:14:1:14:6 | //lgtm | lgtm | lgtm | tst.js:14:1:14:6 | suppression range |
1415
| tst.js:15:1:15:7 | //\\tlgtm | \tlgtm | lgtm | tst.js:15:1:15:7 | suppression range |
@@ -23,6 +24,10 @@
2324
| tst.js:27:1:27:70 | // lgtm ... nction] | lgtm[js/debugger-statement] and lgtm[js/invocation-of-non-function] | lgtm[js/invocation-of-non-function] | tst.js:27:1:27:70 | suppression range |
2425
| tst.js:28:1:28:36 | // lgtm ... ]; lgtm | lgtm[js/debugger-statement]; lgtm | lgtm | tst.js:28:1:28:36 | suppression range |
2526
| tst.js:28:1:28:36 | // lgtm ... ]; lgtm | lgtm[js/debugger-statement]; lgtm | lgtm[js/debugger-statement] | tst.js:28:1:28:36 | suppression range |
27+
| tst.js:29:1:29:12 | /* lgtm[] */ | lgtm[] | lgtm[] | tst.js:29:1:29:12 | suppression range |
28+
| tst.js:30:1:30:41 | /* lgtm ... ion] */ | lgtm[js/invocation-of-non-function] | lgtm[js/invocation-of-non-function] | tst.js:30:1:30:41 | suppression range |
29+
| tst.js:36:1:36:55 | /* lgtm ... ion] */ | lgtm[@tag:nullness,js/invocation-of-non-function] | lgtm[@tag:nullness,js/invocation-of-non-function] | tst.js:36:1:36:55 | suppression range |
30+
| tst.js:37:1:37:25 | /* lgtm ... ess] */ | lgtm[@tag:nullness] | lgtm[@tag:nullness] | tst.js:37:1:37:25 | suppression range |
2631
| tstWindows.html:5:30:5:42 | <!-- lgtm --> | lgtm | lgtm | tstWindows.html:5:1:5:42 | suppression range |
2732
| tstWindows.js:1:11:1:17 | // lgtm | lgtm | lgtm | tstWindows.js:1:1:1:17 | suppression range |
2833
| tstWindows.js:2:1:2:30 | // lgtm ... tement] | lgtm[js/debugger-statement] | lgtm[js/debugger-statement] | tstWindows.js:2:1:2:30 | suppression range |
@@ -34,6 +39,7 @@
3439
| tstWindows.js:8:1:8:18 | // lgtm: blah blah | lgtm: blah blah | lgtm | tstWindows.js:8:1:8:18 | suppression range |
3540
| tstWindows.js:9:1:9:32 | // lgtm ... ositive | lgtm blah blah #falsepositive | lgtm | tstWindows.js:9:1:9:32 | suppression range |
3641
| tstWindows.js:10:1:10:39 | //lgtm ... nction] | lgtm [js/invocation-of-non-function] | lgtm [js/invocation-of-non-function] | tstWindows.js:10:1:10:39 | suppression range |
42+
| tstWindows.js:11:1:11:10 | /* lgtm */ | lgtm | lgtm | tstWindows.js:11:1:11:10 | suppression range |
3743
| tstWindows.js:12:1:12:9 | // lgtm[] | lgtm[] | lgtm[] | tstWindows.js:12:1:12:9 | suppression range |
3844
| tstWindows.js:14:1:14:6 | //lgtm | lgtm | lgtm | tstWindows.js:14:1:14:6 | suppression range |
3945
| tstWindows.js:15:1:15:7 | //\\tlgtm | \tlgtm | lgtm | tstWindows.js:15:1:15:7 | suppression range |
@@ -48,3 +54,7 @@
4854
| tstWindows.js:27:1:27:70 | // lgtm ... nction] | lgtm[js/debugger-statement] and lgtm[js/invocation-of-non-function] | lgtm[js/invocation-of-non-function] | tstWindows.js:27:1:27:70 | suppression range |
4955
| tstWindows.js:28:1:28:36 | // lgtm ... ]; lgtm | lgtm[js/debugger-statement]; lgtm | lgtm | tstWindows.js:28:1:28:36 | suppression range |
5056
| tstWindows.js:28:1:28:36 | // lgtm ... ]; lgtm | lgtm[js/debugger-statement]; lgtm | lgtm[js/debugger-statement] | tstWindows.js:28:1:28:36 | suppression range |
57+
| tstWindows.js:29:1:29:12 | /* lgtm[] */ | lgtm[] | lgtm[] | tstWindows.js:29:1:29:12 | suppression range |
58+
| tstWindows.js:30:1:30:41 | /* lgtm ... ion] */ | lgtm[js/invocation-of-non-function] | lgtm[js/invocation-of-non-function] | tstWindows.js:30:1:30:41 | suppression range |
59+
| tstWindows.js:36:1:36:55 | /* lgtm ... ion] */ | lgtm[@tag:nullness,js/invocation-of-non-function] | lgtm[@tag:nullness,js/invocation-of-non-function] | tstWindows.js:36:1:36:55 | suppression range |
60+
| tstWindows.js:37:1:37:25 | /* lgtm ... ess] */ | lgtm[@tag:nullness] | lgtm[@tag:nullness] | tstWindows.js:37:1:37:25 | suppression range |

javascript/ql/test/query-tests/AlertSuppression/tst.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,12 @@ debugger; // lgtm
2626
// LGTM[js/debugger-statement]
2727
// lgtm[js/debugger-statement] and lgtm[js/invocation-of-non-function]
2828
// lgtm[js/debugger-statement]; lgtm
29+
/* lgtm[] */
30+
/* lgtm[js/invocation-of-non-function] */
31+
/* lgtm
32+
*/
33+
/* lgtm
34+
35+
*/
36+
/* lgtm[@tag:nullness,js/invocation-of-non-function] */
37+
/* lgtm[@tag:nullness] */

javascript/ql/test/query-tests/AlertSuppression/tstWindows.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,12 @@ debugger; // lgtm
2626
// LGTM[js/debugger-statement]
2727
// lgtm[js/debugger-statement] and lgtm[js/invocation-of-non-function]
2828
// lgtm[js/debugger-statement]; lgtm
29+
/* lgtm[] */
30+
/* lgtm[js/invocation-of-non-function] */
31+
/* lgtm
32+
*/
33+
/* lgtm
34+
35+
*/
36+
/* lgtm[@tag:nullness,js/invocation-of-non-function] */
37+
/* lgtm[@tag:nullness] */

0 commit comments

Comments
 (0)