Python: Adjust test-code predicate

This commit is contained in:
Rasmus Wriedt Larsen
2023-09-12 15:15:19 +02:00
parent bb3ced02e3
commit ba0a5b1c23

View File

@@ -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)
}
}