Skip to content

Commit f64811a

Browse files
committed
Python: Port UselessClass.ql
No test changes.
1 parent 7b34f11 commit f64811a

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

python/ql/src/Classes/UselessClass.ql

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414

1515
import python
16-
private import LegacyPointsTo
16+
private import semmle.python.dataflow.new.internal.DataFlowDispatch
1717

1818
predicate fewer_than_two_public_methods(Class cls, int methods) {
1919
(methods = 0 or methods = 1) and
@@ -25,13 +25,8 @@ predicate does_not_define_special_method(Class cls) {
2525
}
2626

2727
predicate no_inheritance(Class c) {
28-
not exists(ClassValue cls, ClassValue other |
29-
cls.getScope() = c and
30-
other != ClassValue::object()
31-
|
32-
other.getABaseType() = cls or
33-
cls.getABaseType() = other
34-
) and
28+
not exists(getADirectSubclass(c)) and
29+
not exists(getADirectSuperclass(c)) and
3530
not exists(Expr base | base = c.getABase() |
3631
not base instanceof Name or base.(Name).getId() != "object"
3732
)

0 commit comments

Comments
 (0)