Skip to content

Commit 06d6913

Browse files
committed
Python: Change "sanity" to "consistency".
1 parent 01fb1e3 commit 06d6913

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

python/ql/src/analysis/Sanity.ql

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* @name Sanity check
3-
* @description General sanity check to be run on any and all code. Should never produce any results.
4-
* @id py/sanity-check
2+
* @name Consistency check
3+
* @description General consistency check to be run on any and all code. Should never produce any results.
4+
* @id py/consistency-check
55
*/
66

77
import python
@@ -24,7 +24,7 @@ predicate uniqueness_error(int number, string what, string problem) {
2424
)
2525
}
2626

27-
predicate ast_sanity(string clsname, string problem, string what) {
27+
predicate ast_consistency(string clsname, string problem, string what) {
2828
exists(AstNode a | clsname = a.getAQlClass() |
2929
uniqueness_error(count(a.toString()), "toString", problem) and
3030
what = "at " + a.getLocation().toString()
@@ -39,7 +39,7 @@ predicate ast_sanity(string clsname, string problem, string what) {
3939
)
4040
}
4141

42-
predicate location_sanity(string clsname, string problem, string what) {
42+
predicate location_consistency(string clsname, string problem, string what) {
4343
exists(Location l | clsname = l.getAQlClass() |
4444
uniqueness_error(count(l.toString()), "toString", problem) and what = "at " + l.toString()
4545
or
@@ -65,7 +65,7 @@ predicate location_sanity(string clsname, string problem, string what) {
6565
)
6666
}
6767

68-
predicate cfg_sanity(string clsname, string problem, string what) {
68+
predicate cfg_consistency(string clsname, string problem, string what) {
6969
exists(ControlFlowNode f | clsname = f.getAQlClass() |
7070
uniqueness_error(count(f.getNode()), "getNode", problem) and
7171
what = "at " + f.getLocation().toString()
@@ -80,7 +80,7 @@ predicate cfg_sanity(string clsname, string problem, string what) {
8080
)
8181
}
8282

83-
predicate scope_sanity(string clsname, string problem, string what) {
83+
predicate scope_consistency(string clsname, string problem, string what) {
8484
exists(Scope s | clsname = s.getAQlClass() |
8585
uniqueness_error(count(s.getEntryNode()), "getEntryNode", problem) and
8686
what = "at " + s.getLocation().toString()
@@ -125,7 +125,7 @@ private predicate introspected_builtin_object(Object o) {
125125
py_cobject_sources(o, 0)
126126
}
127127

128-
predicate builtin_object_sanity(string clsname, string problem, string what) {
128+
predicate builtin_object_consistency(string clsname, string problem, string what) {
129129
exists(Object o |
130130
clsname = o.getAQlClass() and
131131
what = best_description_builtin_object(o) and
@@ -146,7 +146,7 @@ predicate builtin_object_sanity(string clsname, string problem, string what) {
146146
)
147147
}
148148

149-
predicate source_object_sanity(string clsname, string problem, string what) {
149+
predicate source_object_consistency(string clsname, string problem, string what) {
150150
exists(Object o | clsname = o.getAQlClass() and not o.isBuiltin() |
151151
uniqueness_error(count(o.getOrigin()), "getOrigin", problem) and
152152
what = "at " + o.getOrigin().getLocation().toString()
@@ -161,7 +161,7 @@ predicate source_object_sanity(string clsname, string problem, string what) {
161161
)
162162
}
163163

164-
predicate ssa_sanity(string clsname, string problem, string what) {
164+
predicate ssa_consistency(string clsname, string problem, string what) {
165165
/* Zero or one definitions of each SSA variable */
166166
exists(SsaVariable var | clsname = var.getAQlClass() |
167167
uniqueness_error(strictcount(var.getDefinition()), "getDefinition", problem) and
@@ -196,7 +196,7 @@ predicate ssa_sanity(string clsname, string problem, string what) {
196196
)
197197
}
198198

199-
predicate function_object_sanity(string clsname, string problem, string what) {
199+
predicate function_object_consistency(string clsname, string problem, string what) {
200200
exists(FunctionObject func | clsname = func.getAQlClass() |
201201
what = func.getName() and
202202
(
@@ -229,7 +229,7 @@ predicate intermediate_origins(ControlFlowNode use, ControlFlowNode inter, Objec
229229
)
230230
}
231231

232-
predicate points_to_sanity(string clsname, string problem, string what) {
232+
predicate points_to_consistency(string clsname, string problem, string what) {
233233
exists(Object obj |
234234
multiple_origins_per_object(obj) and
235235
clsname = obj.getAQlClass() and
@@ -245,7 +245,7 @@ predicate points_to_sanity(string clsname, string problem, string what) {
245245
)
246246
}
247247

248-
predicate jump_to_definition_sanity(string clsname, string problem, string what) {
248+
predicate jump_to_definition_consistency(string clsname, string problem, string what) {
249249
problem = "multiple (jump-to) definitions" and
250250
exists(Expr use |
251251
strictcount(getUniqueDefinition(use)) > 1 and
@@ -254,7 +254,7 @@ predicate jump_to_definition_sanity(string clsname, string problem, string what)
254254
)
255255
}
256256

257-
predicate file_sanity(string clsname, string problem, string what) {
257+
predicate file_consistency(string clsname, string problem, string what) {
258258
exists(File file, Folder folder |
259259
clsname = file.getAQlClass() and
260260
problem = "has same name as a folder" and
@@ -269,7 +269,7 @@ predicate file_sanity(string clsname, string problem, string what) {
269269
)
270270
}
271271

272-
predicate class_value_sanity(string clsname, string problem, string what) {
272+
predicate class_value_consistency(string clsname, string problem, string what) {
273273
exists(ClassValue value, ClassValue sup, string attr |
274274
what = value.getName() and
275275
sup = value.getASuperType() and
@@ -283,16 +283,16 @@ predicate class_value_sanity(string clsname, string problem, string what) {
283283

284284
from string clsname, string problem, string what
285285
where
286-
ast_sanity(clsname, problem, what) or
287-
location_sanity(clsname, problem, what) or
288-
scope_sanity(clsname, problem, what) or
289-
cfg_sanity(clsname, problem, what) or
290-
ssa_sanity(clsname, problem, what) or
291-
builtin_object_sanity(clsname, problem, what) or
292-
source_object_sanity(clsname, problem, what) or
293-
function_object_sanity(clsname, problem, what) or
294-
points_to_sanity(clsname, problem, what) or
295-
jump_to_definition_sanity(clsname, problem, what) or
296-
file_sanity(clsname, problem, what) or
297-
class_value_sanity(clsname, problem, what)
286+
ast_consistency(clsname, problem, what) or
287+
location_consistency(clsname, problem, what) or
288+
scope_consistency(clsname, problem, what) or
289+
cfg_consistency(clsname, problem, what) or
290+
ssa_consistency(clsname, problem, what) or
291+
builtin_object_consistency(clsname, problem, what) or
292+
source_object_consistency(clsname, problem, what) or
293+
function_object_consistency(clsname, problem, what) or
294+
points_to_consistency(clsname, problem, what) or
295+
jump_to_definition_consistency(clsname, problem, what) or
296+
file_consistency(clsname, problem, what) or
297+
class_value_consistency(clsname, problem, what)
298298
select clsname + " " + what + " has " + problem

python/ql/test/library-tests/PointsTo/new/Sanity.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import python
22
import semmle.python.pointsto.PointsTo
33
import semmle.python.objects.ObjectInternal
44

5-
predicate ssa_sanity(string clsname, string problem, string what) {
5+
predicate ssa_consistency(string clsname, string problem, string what) {
66
/* Exactly one definition of each SSA variable */
77
exists(EssaVariable var | clsname = var.getAQlClass() |
88
/* Exactly one definition of each SSA variable */
@@ -130,7 +130,7 @@ predicate ssa_sanity(string clsname, string problem, string what) {
130130
)
131131
}
132132

133-
predicate undefined_sanity(string clsname, string problem, string what) {
133+
predicate undefined_consistency(string clsname, string problem, string what) {
134134
/* Variables may be undefined, but values cannot be */
135135
exists(ControlFlowNode f |
136136
PointsToInternal::pointsTo(f, _, ObjectInternal::undefined(), _) and
@@ -142,5 +142,5 @@ predicate undefined_sanity(string clsname, string problem, string what) {
142142
}
143143

144144
from string clsname, string problem, string what
145-
where ssa_sanity(clsname, problem, what) or undefined_sanity(clsname, problem, what)
145+
where ssa_consistency(clsname, problem, what) or undefined_consistency(clsname, problem, what)
146146
select clsname, what, problem

python/ql/test/library-tests/PointsTo/new/code/b_condition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def loop(seq):
5757
if v:
5858
use(v)
5959

60-
#This was causing the sanity check to fail,
60+
#This was causing the consistency check to fail,
6161
def double_attr_check(x, y):
6262
if x.b == 3:
6363
return

python/ql/test/library-tests/PointsTo/new/code/c_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def h():
9595
if not x:
9696
pass
9797

98-
def complex_test(x): # Was failing sanity check.
98+
def complex_test(x): # Was failing consistency check.
9999
if not (foo(x) and bar(x)):
100100
use(x)
101101
pass

0 commit comments

Comments
 (0)