mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Python: Adjust test-code predicate
This commit is contained in:
@@ -109,10 +109,10 @@ module NotExposed {
|
||||
fullyQualifiedToApiGraphPath(fullyQualifiedName) = spec.getAlreadyModeledClass().getPath()
|
||||
}
|
||||
|
||||
predicate isNonTestProjectCode(AstNode ast) {
|
||||
not ast.getScope*() instanceof TestScope and
|
||||
not ast.getLocation().getFile().getRelativePath().matches("tests/%") and
|
||||
not exists(ast.getLocation().getFile().getRelativePath())
|
||||
predicate isTestCode(AstNode ast) {
|
||||
ast.getScope*() instanceof TestScope
|
||||
or
|
||||
ast.getLocation().getFile().getRelativePath().matches("tests/%")
|
||||
}
|
||||
|
||||
predicate hasAllStatement(Module mod) {
|
||||
@@ -164,7 +164,7 @@ module NotExposed {
|
||||
mod.declaredInAll(importMember.getName())
|
||||
) and
|
||||
not alreadyExplicitlyModeled(spec, newAliasFullyQualified) and
|
||||
isNonTestProjectCode(importMember)
|
||||
not isTestCode(importMember)
|
||||
}
|
||||
|
||||
/** same as `newDirectAlias` predicate, but handling `from <module> import *`, considering all `<member>`, where `<module>.<member>` belongs to `spec`. */
|
||||
@@ -192,7 +192,7 @@ module NotExposed {
|
||||
mod.declaredInAll(relevantName)
|
||||
) and
|
||||
not alreadyExplicitlyModeled(spec, newAliasFullyQualified) and
|
||||
isNonTestProjectCode(importStar)
|
||||
not isTestCode(importStar)
|
||||
}
|
||||
|
||||
/** Holds if `classExpr` defines a new subclass that belongs to `spec`, which has the fully qualified name `newSubclassQualified`. */
|
||||
@@ -205,6 +205,6 @@ module NotExposed {
|
||||
newSubclassQualified = mod.getName() + "." + classExpr.getName() and
|
||||
loc = classExpr.getLocation() and
|
||||
not alreadyExplicitlyModeled(spec, newSubclassQualified) and
|
||||
isNonTestProjectCode(classExpr)
|
||||
not isTestCode(classExpr)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user