Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb3ced0

Browse files
committed
Python: Improve docs/names around already modeled classes
1 parent f06bbd2 commit bb3ced0

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

python/ql/lib/semmle/python/frameworks/internal/SubclassFinder.qll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ module NotExposed {
6464

6565
bindingset[this]
6666
abstract class FindSubclassesSpec extends string {
67+
/**
68+
* Gets an API node for a class that has already been modeled. You can include
69+
* `.getASubclass*()` without causing problems, but it is not needed.
70+
*/
6771
abstract API::Node getAlreadyModeledClass();
6872

6973
FindSubclassesSpec getSuperClass() { none() }
@@ -94,8 +98,14 @@ module NotExposed {
9498
)
9599
}
96100

101+
/**
102+
* Holds if `fullyQualifiedName` is already explicitly modeled in the `spec`.
103+
*
104+
* For specs that do `.getASubclass*()`, items found by following a `.getASubclass`
105+
* edge will not be considered explicitly modeled.
106+
*/
97107
bindingset[fullyQualifiedName]
98-
predicate alreadyModeled(FindSubclassesSpec spec, string fullyQualifiedName) {
108+
predicate alreadyExplicitlyModeled(FindSubclassesSpec spec, string fullyQualifiedName) {
99109
fullyQualifiedToApiGraphPath(fullyQualifiedName) = spec.getAlreadyModeledClass().getPath()
100110
}
101111

@@ -153,7 +163,7 @@ module NotExposed {
153163
or
154164
mod.declaredInAll(importMember.getName())
155165
) and
156-
not alreadyModeled(spec, newAliasFullyQualified) and
166+
not alreadyExplicitlyModeled(spec, newAliasFullyQualified) and
157167
isNonTestProjectCode(importMember)
158168
}
159169

@@ -181,7 +191,7 @@ module NotExposed {
181191
or
182192
mod.declaredInAll(relevantName)
183193
) and
184-
not alreadyModeled(spec, newAliasFullyQualified) and
194+
not alreadyExplicitlyModeled(spec, newAliasFullyQualified) and
185195
isNonTestProjectCode(importStar)
186196
}
187197

@@ -194,7 +204,7 @@ module NotExposed {
194204
classExpr.getScope() = mod and
195205
newSubclassQualified = mod.getName() + "." + classExpr.getName() and
196206
loc = classExpr.getLocation() and
197-
not alreadyModeled(spec, newSubclassQualified) and
207+
not alreadyExplicitlyModeled(spec, newSubclassQualified) and
198208
isNonTestProjectCode(classExpr)
199209
}
200210
}

0 commit comments

Comments
 (0)