Python: Adjust test-code predicate

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

View File

@@ -112,10 +112,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) {
@@ -167,7 +167,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`. */
@@ -195,7 +195,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`. */
@@ -208,6 +208,6 @@ module NotExposed {
newSubclassQualified = mod.getName() + "." + classExpr.getName() and
loc = classExpr.getLocation() and
not alreadyExplicitlyModeled(spec, newSubclassQualified) and
isNonTestProjectCode(classExpr)
not isTestCode(classExpr)
}
}