Skip to content

Commit 3a328f6

Browse files
authored
Merge pull request #6570 from yoff/python/broaden-noqa-regex
Python: Broaden noqa regex to allow comments
2 parents a7993fb + 9bf2eb5 commit 3a328f6

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

python/ql/src/analysis/AlertSuppression.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class LgtmSuppressionComment extends LineSuppressionComment {
7272
* A noqa suppression comment. Both pylint and pyflakes respect this, so lgtm ought to too.
7373
*/
7474
class NoqaSuppressionComment extends LineSuppressionComment {
75-
NoqaSuppressionComment() { this.getContents().toLowerCase().regexpMatch("\\s*noqa\\s*") }
75+
NoqaSuppressionComment() { this.getContents().toLowerCase().regexpMatch("\\s*noqa\\s*([^:].*)?") }
7676

7777
override string getAnnotation() { result = "lgtm" }
7878
}

python/ql/test/query-tests/analysis/suppression/AlertSuppression.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
| test.py:36:21:36:33 | Comment # lgtm method | lgtm method | lgtm | test.py:36:1:36:33 | suppression range |
2222
| test.py:39:4:39:8 | Comment #noqa | noqa | lgtm | test.py:39:1:39:8 | suppression range |
2323
| test.py:40:4:40:9 | Comment # noqa | noqa | lgtm | test.py:40:1:40:9 | suppression range |
24+
| test.py:45:4:45:31 | Comment # noqa -- Some extra detail. | noqa -- Some extra detail. | lgtm | test.py:45:1:45:31 | suppression range |
2425
| test.py:50:34:50:117 | Comment # noqa: E501; (line too long) pylint: disable=invalid-name; lgtm [py/missing-equals] | noqa: E501; (line too long) pylint: disable=invalid-name; lgtm [py/missing-equals] | lgtm [py/missing-equals] | test.py:50:1:50:117 | suppression range |
2526
| test.py:52:4:52:67 | Comment # noqa: E501; (line too long) pylint: disable=invalid-name; lgtm | noqa: E501; (line too long) pylint: disable=invalid-name; lgtm | lgtm | test.py:52:1:52:67 | suppression range |
2627
| test.py:53:4:53:78 | Comment # random nonsense lgtm [py/missing-equals] and then some more commentary... | random nonsense lgtm [py/missing-equals] and then some more commentary... | lgtm [py/missing-equals] | test.py:53:1:53:78 | suppression range |

0 commit comments

Comments
 (0)