mirror of
https://github.com/github/codeql.git
synced 2026-04-05 15:18:20 +02:00
Python: Port UselessClass.ql
No test changes.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
import python
|
||||
private import LegacyPointsTo
|
||||
private import semmle.python.dataflow.new.internal.DataFlowDispatch
|
||||
|
||||
predicate fewer_than_two_public_methods(Class cls, int methods) {
|
||||
(methods = 0 or methods = 1) and
|
||||
@@ -25,13 +25,8 @@ predicate does_not_define_special_method(Class cls) {
|
||||
}
|
||||
|
||||
predicate no_inheritance(Class c) {
|
||||
not exists(ClassValue cls, ClassValue other |
|
||||
cls.getScope() = c and
|
||||
other != ClassValue::object()
|
||||
|
|
||||
other.getABaseType() = cls or
|
||||
cls.getABaseType() = other
|
||||
) and
|
||||
not exists(getADirectSubclass(c)) and
|
||||
not exists(getADirectSuperclass(c)) and
|
||||
not exists(Expr base | base = c.getABase() |
|
||||
not base instanceof Name or base.(Name).getId() != "object"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user