1
1
/**
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
5
5
*/
6
6
7
7
import python
@@ -24,7 +24,7 @@ predicate uniqueness_error(int number, string what, string problem) {
24
24
)
25
25
}
26
26
27
- predicate ast_sanity ( string clsname , string problem , string what ) {
27
+ predicate ast_consistency ( string clsname , string problem , string what ) {
28
28
exists ( AstNode a | clsname = a .getAQlClass ( ) |
29
29
uniqueness_error ( count ( a .toString ( ) ) , "toString" , problem ) and
30
30
what = "at " + a .getLocation ( ) .toString ( )
@@ -39,7 +39,7 @@ predicate ast_sanity(string clsname, string problem, string what) {
39
39
)
40
40
}
41
41
42
- predicate location_sanity ( string clsname , string problem , string what ) {
42
+ predicate location_consistency ( string clsname , string problem , string what ) {
43
43
exists ( Location l | clsname = l .getAQlClass ( ) |
44
44
uniqueness_error ( count ( l .toString ( ) ) , "toString" , problem ) and what = "at " + l .toString ( )
45
45
or
@@ -65,7 +65,7 @@ predicate location_sanity(string clsname, string problem, string what) {
65
65
)
66
66
}
67
67
68
- predicate cfg_sanity ( string clsname , string problem , string what ) {
68
+ predicate cfg_consistency ( string clsname , string problem , string what ) {
69
69
exists ( ControlFlowNode f | clsname = f .getAQlClass ( ) |
70
70
uniqueness_error ( count ( f .getNode ( ) ) , "getNode" , problem ) and
71
71
what = "at " + f .getLocation ( ) .toString ( )
@@ -80,7 +80,7 @@ predicate cfg_sanity(string clsname, string problem, string what) {
80
80
)
81
81
}
82
82
83
- predicate scope_sanity ( string clsname , string problem , string what ) {
83
+ predicate scope_consistency ( string clsname , string problem , string what ) {
84
84
exists ( Scope s | clsname = s .getAQlClass ( ) |
85
85
uniqueness_error ( count ( s .getEntryNode ( ) ) , "getEntryNode" , problem ) and
86
86
what = "at " + s .getLocation ( ) .toString ( )
@@ -125,7 +125,7 @@ private predicate introspected_builtin_object(Object o) {
125
125
py_cobject_sources ( o , 0 )
126
126
}
127
127
128
- predicate builtin_object_sanity ( string clsname , string problem , string what ) {
128
+ predicate builtin_object_consistency ( string clsname , string problem , string what ) {
129
129
exists ( Object o |
130
130
clsname = o .getAQlClass ( ) and
131
131
what = best_description_builtin_object ( o ) and
@@ -146,7 +146,7 @@ predicate builtin_object_sanity(string clsname, string problem, string what) {
146
146
)
147
147
}
148
148
149
- predicate source_object_sanity ( string clsname , string problem , string what ) {
149
+ predicate source_object_consistency ( string clsname , string problem , string what ) {
150
150
exists ( Object o | clsname = o .getAQlClass ( ) and not o .isBuiltin ( ) |
151
151
uniqueness_error ( count ( o .getOrigin ( ) ) , "getOrigin" , problem ) and
152
152
what = "at " + o .getOrigin ( ) .getLocation ( ) .toString ( )
@@ -161,7 +161,7 @@ predicate source_object_sanity(string clsname, string problem, string what) {
161
161
)
162
162
}
163
163
164
- predicate ssa_sanity ( string clsname , string problem , string what ) {
164
+ predicate ssa_consistency ( string clsname , string problem , string what ) {
165
165
/* Zero or one definitions of each SSA variable */
166
166
exists ( SsaVariable var | clsname = var .getAQlClass ( ) |
167
167
uniqueness_error ( strictcount ( var .getDefinition ( ) ) , "getDefinition" , problem ) and
@@ -196,7 +196,7 @@ predicate ssa_sanity(string clsname, string problem, string what) {
196
196
)
197
197
}
198
198
199
- predicate function_object_sanity ( string clsname , string problem , string what ) {
199
+ predicate function_object_consistency ( string clsname , string problem , string what ) {
200
200
exists ( FunctionObject func | clsname = func .getAQlClass ( ) |
201
201
what = func .getName ( ) and
202
202
(
@@ -229,7 +229,7 @@ predicate intermediate_origins(ControlFlowNode use, ControlFlowNode inter, Objec
229
229
)
230
230
}
231
231
232
- predicate points_to_sanity ( string clsname , string problem , string what ) {
232
+ predicate points_to_consistency ( string clsname , string problem , string what ) {
233
233
exists ( Object obj |
234
234
multiple_origins_per_object ( obj ) and
235
235
clsname = obj .getAQlClass ( ) and
@@ -245,7 +245,7 @@ predicate points_to_sanity(string clsname, string problem, string what) {
245
245
)
246
246
}
247
247
248
- predicate jump_to_definition_sanity ( string clsname , string problem , string what ) {
248
+ predicate jump_to_definition_consistency ( string clsname , string problem , string what ) {
249
249
problem = "multiple (jump-to) definitions" and
250
250
exists ( Expr use |
251
251
strictcount ( getUniqueDefinition ( use ) ) > 1 and
@@ -254,7 +254,7 @@ predicate jump_to_definition_sanity(string clsname, string problem, string what)
254
254
)
255
255
}
256
256
257
- predicate file_sanity ( string clsname , string problem , string what ) {
257
+ predicate file_consistency ( string clsname , string problem , string what ) {
258
258
exists ( File file , Folder folder |
259
259
clsname = file .getAQlClass ( ) and
260
260
problem = "has same name as a folder" and
@@ -269,7 +269,7 @@ predicate file_sanity(string clsname, string problem, string what) {
269
269
)
270
270
}
271
271
272
- predicate class_value_sanity ( string clsname , string problem , string what ) {
272
+ predicate class_value_consistency ( string clsname , string problem , string what ) {
273
273
exists ( ClassValue value , ClassValue sup , string attr |
274
274
what = value .getName ( ) and
275
275
sup = value .getASuperType ( ) and
@@ -283,16 +283,16 @@ predicate class_value_sanity(string clsname, string problem, string what) {
283
283
284
284
from string clsname , string problem , string what
285
285
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 )
298
298
select clsname + " " + what + " has " + problem
0 commit comments