mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
Python: move AlertSuppression.ql
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user