mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Remove total order check from equals not equals (doesn't make sense there; total order doesn't define eq or ne methods at all)
This commit is contained in:
@@ -1,12 +0,0 @@
|
|||||||
/** Helper definitions for reasoning about comparison methods. */
|
|
||||||
|
|
||||||
import python
|
|
||||||
import semmle.python.ApiGraphs
|
|
||||||
|
|
||||||
/** Holds if `cls` has the `functools.total_ordering` decorator. */
|
|
||||||
predicate totalOrdering(Class cls) {
|
|
||||||
API::moduleImport("functools")
|
|
||||||
.getMember("total_ordering")
|
|
||||||
.asSource()
|
|
||||||
.flowsTo(DataFlow::exprNode(cls.getADecorator()))
|
|
||||||
}
|
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import python
|
import python
|
||||||
import Comparisons
|
|
||||||
import semmle.python.dataflow.new.internal.DataFlowDispatch
|
import semmle.python.dataflow.new.internal.DataFlowDispatch
|
||||||
import Classes.Equality
|
import Classes.Equality
|
||||||
|
|
||||||
@@ -33,8 +32,6 @@ predicate missingEquality(Class cls, Function defined, string missing) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
from Class cls, Function defined, string missing
|
from Class cls, Function defined, string missing
|
||||||
where
|
where missingEquality(cls, defined, missing)
|
||||||
not totalOrdering(cls) and
|
|
||||||
missingEquality(cls, defined, missing)
|
|
||||||
select cls, "This class implements $@, but does not implement " + missing + ".", defined,
|
select cls, "This class implements $@, but does not implement " + missing + ".", defined,
|
||||||
defined.getName()
|
defined.getName()
|
||||||
|
|||||||
@@ -14,7 +14,14 @@
|
|||||||
import python
|
import python
|
||||||
import semmle.python.dataflow.new.internal.DataFlowDispatch
|
import semmle.python.dataflow.new.internal.DataFlowDispatch
|
||||||
import semmle.python.ApiGraphs
|
import semmle.python.ApiGraphs
|
||||||
import Comparisons
|
|
||||||
|
/** Holds if `cls` has the `functools.total_ordering` decorator. */
|
||||||
|
predicate totalOrdering(Class cls) {
|
||||||
|
API::moduleImport("functools")
|
||||||
|
.getMember("total_ordering")
|
||||||
|
.asSource()
|
||||||
|
.flowsTo(DataFlow::exprNode(cls.getADecorator()))
|
||||||
|
}
|
||||||
|
|
||||||
predicate definesStrictOrdering(Class cls, Function meth) {
|
predicate definesStrictOrdering(Class cls, Function meth) {
|
||||||
meth = cls.getMethod("__lt__")
|
meth = cls.getMethod("__lt__")
|
||||||
|
|||||||
Reference in New Issue
Block a user