Python: move AlertSuppression.ql

This commit is contained in:
Arthur Baars
2022-12-16 14:32:41 +01:00
parent acb5d6e163
commit f68e18cd9c
3 changed files with 2 additions and 2 deletions

View File

@@ -1,41 +0,0 @@
/**
* @name Alert suppression
* @description Generates information about alert suppressions.
* @kind alert-suppression
* @id py/alert-suppression
*/
private import codeql.suppression.AlertSuppression as AS
private import semmle.python.Comment as P
class SingleLineComment instanceof P::Comment {
predicate hasLocationInfo(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
super.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
}
string getText() { result = super.getContents() }
string toString() { result = super.toString() }
}
import AS::Make<SingleLineComment>
/**
* A noqa suppression comment. Both pylint and pyflakes respect this, so lgtm ought to too.
*/
class NoqaSuppressionComment extends SuppressionComment instanceof SingleLineComment {
NoqaSuppressionComment() {
SingleLineComment.super.getText().regexpMatch("(?i)\\s*noqa\\s*([^:].*)?")
}
override string getAnnotation() { result = "lgtm" }
override predicate covers(
string filepath, int startline, int startcolumn, int endline, int endcolumn
) {
this.hasLocationInfo(filepath, startline, _, endline, endcolumn) and
startcolumn = 1
}
}