mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Ql4Ql: Share the definition of TestFile between multiple tests.
This commit is contained in:
@@ -61,3 +61,8 @@ class File extends Container, Impl::File {
|
||||
/** Holds if this file was extracted from ordinary source code. */
|
||||
predicate fromSource() { any() }
|
||||
}
|
||||
|
||||
/** A test file. */
|
||||
class TestFile extends File {
|
||||
TestFile() { this.getRelativePath().matches("%/" + ["experimental", "examples", "test"] + "/%") }
|
||||
}
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
import ql
|
||||
|
||||
private predicate unInterestingLocation(File f) {
|
||||
f.getRelativePath().matches("%/" + ["experimental", "examples", "test"] + "/%")
|
||||
}
|
||||
|
||||
private predicate hasQualityTag(QueryDoc doc) { doc.getQueryTags() = "quality" }
|
||||
|
||||
private predicate incorrectTopLevelCategorisation(QueryDoc doc) {
|
||||
@@ -31,7 +27,7 @@ private predicate maintainabilitySubCategory(QueryDoc doc) {
|
||||
from TopLevel t, QueryDoc doc, string msg
|
||||
where
|
||||
doc = t.getQLDoc() and
|
||||
not unInterestingLocation(t.getLocation().getFile()) and
|
||||
not t.getLocation().getFile() instanceof TestFile and
|
||||
hasQualityTag(doc) and
|
||||
(
|
||||
incorrectTopLevelCategorisation(doc) and
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
import ql
|
||||
|
||||
private predicate unInterestingLocation(File f) {
|
||||
f.getRelativePath().matches("%/" + ["experimental", "examples", "test"] + "/%")
|
||||
}
|
||||
|
||||
predicate missingSecuritySeverity(QueryDoc doc) {
|
||||
doc.getQueryTags() = "security" and
|
||||
exists(doc.getQueryPrecision()) and
|
||||
@@ -29,7 +25,7 @@ predicate missingSecurityTag(QueryDoc doc) {
|
||||
from TopLevel t, QueryDoc doc, string msg
|
||||
where
|
||||
doc = t.getQLDoc() and
|
||||
not unInterestingLocation(t.getLocation().getFile()) and
|
||||
not t.getLocation().getFile() instanceof TestFile and
|
||||
(
|
||||
missingSecuritySeverity(doc) and
|
||||
msg = "This query file is missing a `@security-severity` tag."
|
||||
|
||||
Reference in New Issue
Block a user