FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/python/ql/src/Classes/IncompleteOrdering.ql at codeql-cli-2.11.3 · github/codeql · GitHub
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10.1k
Code
Issues
1k
Pull requests
468
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
python
/
ql
/
src
/
Classes
/
IncompleteOrdering.ql
Copy path
More file actions
More file actions
Latest commit
History
History
History
73 lines (65 loc) · 2.12 KB
Breadcrumbs
codeql
/
python
/
ql
/
src
/
Classes
/
IncompleteOrdering.ql
Copy path
File metadata and controls
73 lines (65 loc) · 2.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* @name Incomplete ordering
* @description Class defines one or more ordering method but does not define all 4 ordering comparison methods
* @kind problem
* @tags reliability
* correctness
* @problem.severity warning
* @sub-severity low
* @precision very-high
* @id py/incomplete-ordering
*/
import
python
predicate
total_ordering
(
Class
cls
)
{
exists
(
Attribute
a
|
a
=
cls
.
getADecorator
(
)
|
a
.
getName
(
)
=
"total_ordering"
)
or
exists
(
Name
n
|
n
=
cls
.
getADecorator
(
)
|
n
.
getId
(
)
=
"total_ordering"
)
}
string
ordering_name
(
int
n
)
{
result
=
"__lt__"
and
n
=
1
or
result
=
"__le__"
and
n
=
2
or
result
=
"__gt__"
and
n
=
3
or
result
=
"__ge__"
and
n
=
4
}
predicate
overrides_ordering_method
(
ClassValue
c
,
string
name
)
{
name
=
ordering_name
(
_
)
and
(
c
.
declaresAttribute
(
name
)
or
exists
(
ClassValue
sup
|
sup
=
c
.
getASuperType
(
)
and
not
sup
=
Value
::
named
(
"object"
)
|
sup
.
declaresAttribute
(
name
)
)
)
}
string
unimplemented_ordering
(
ClassValue
c
,
int
n
)
{
not
c
=
Value
::
named
(
"object"
)
and
not
overrides_ordering_method
(
c
,
result
)
and
result
=
ordering_name
(
n
)
}
string
unimplemented_ordering_methods
(
ClassValue
c
,
int
n
)
{
n
=
0
and
result
=
""
and
exists
(
unimplemented_ordering
(
c
,
_
)
)
or
exists
(
string
prefix
,
int
nm1
|
n
=
nm1
+
1
and
prefix
=
unimplemented_ordering_methods
(
c
,
nm1
)
|
prefix
=
""
and
result
=
unimplemented_ordering
(
c
,
n
)
or
result
=
prefix
and
not
exists
(
unimplemented_ordering
(
c
,
n
)
)
and
n
<
5
or
prefix
!=
""
and
result
=
prefix
+
" or "
+
unimplemented_ordering
(
c
,
n
)
)
}
Value
ordering_method
(
ClassValue
c
,
string
name
)
{
/* If class doesn't declare a method then don't blame this class (the superclass will be blamed). */
name
=
ordering_name
(
_
)
and
result
=
c
.
declaredAttribute
(
name
)
}
from
ClassValue
c
,
Value
ordering
,
string
name
where
not
c
.
failedInference
(
_
)
and
not
total_ordering
(
c
.
getScope
(
)
)
and
ordering
=
ordering_method
(
c
,
name
)
and
exists
(
unimplemented_ordering
(
c
,
_
)
)
select
c
,
"Class "
+
c
.
getName
(
)
+
" implements $@, but does not implement "
+
unimplemented_ordering_methods
(
c
,
4
)
+
"."
,
ordering
,
name
Back
|
FazBrowse Home
|
New Git URL