mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Swift: Make file checking in tests more strict
With Swift 6.1 the extractor will start to extract files outside of the test directory. These files and their elements we do not want to see in our tests.
This commit is contained in:
@@ -6,7 +6,8 @@ import codeql.swift.elements.expr.internal.DotSyntaxCallExpr
|
||||
|
||||
cached
|
||||
predicate toBeTested(Element e) {
|
||||
e instanceof File
|
||||
e instanceof File and
|
||||
(exists(e.(File).getRelativePath()) or e instanceof UnknownFile)
|
||||
or
|
||||
e instanceof ParameterizedProtocolType
|
||||
or
|
||||
|
||||
@@ -21,5 +21,5 @@ string describe(Decl d) {
|
||||
}
|
||||
|
||||
from Decl d
|
||||
where d.getLocation().getFile().getName() != ""
|
||||
where exists(d.getLocation().getFile().getRelativePath())
|
||||
select d, strictconcat(describe(d), ", ")
|
||||
|
||||
@@ -27,6 +27,6 @@ string describe(Function f) {
|
||||
|
||||
from Function f
|
||||
where
|
||||
not f.getFile() instanceof UnknownFile and
|
||||
exists(f.getFile().getRelativePath()) and
|
||||
not f.getName().matches("%init%")
|
||||
select f, concat(describe(f), ", ")
|
||||
|
||||
@@ -16,7 +16,7 @@ string describe(Type t) {
|
||||
|
||||
from VarDecl v, Type t
|
||||
where
|
||||
v.getLocation().getFile().getBaseName() != "" and
|
||||
exists(v.getLocation().getFile().getRelativePath()) and
|
||||
not v.getName() = "self" and
|
||||
t = v.getType()
|
||||
select v, t.toString(), concat(describe(t), ", ")
|
||||
|
||||
@@ -14,7 +14,7 @@ string describe(TypeDecl td) {
|
||||
|
||||
from VarDecl v, TypeDecl td
|
||||
where
|
||||
v.getLocation().getFile().getBaseName() != "" and
|
||||
exists(v.getLocation().getFile().getRelativePath()) and
|
||||
not v.getName() = "self" and
|
||||
(
|
||||
td = v.getType().(NominalType).getDeclaration() or
|
||||
|
||||
@@ -14,6 +14,6 @@ string describe(Type t) {
|
||||
|
||||
from VarDecl v, Type t
|
||||
where
|
||||
v.getLocation().getFile().getBaseName() != "" and
|
||||
exists(v.getLocation().getFile().getRelativePath()) and
|
||||
t = v.getType()
|
||||
select v, t.toString(), concat(describe(t), ", ")
|
||||
|
||||
@@ -22,6 +22,6 @@ string describe(Type t) {
|
||||
|
||||
from VarDecl v, Type t
|
||||
where
|
||||
v.getLocation().getFile().getBaseName() != "" and
|
||||
exists(v.getLocation().getFile().getRelativePath()) and
|
||||
t = v.getType()
|
||||
select v, t.toString(), strictconcat(describe(t), ", ")
|
||||
|
||||
@@ -3,4 +3,5 @@ import swift
|
||||
string describe(File f) { (f.isSuccessfullyExtracted() and result = "isSuccessfullyExtracted") }
|
||||
|
||||
from File f
|
||||
where exists(f.getRelativePath()) or f instanceof UnknownFile
|
||||
select f, concat(f.getRelativePath(), ", "), concat(describe(f), ", ")
|
||||
|
||||
Reference in New Issue
Block a user