Skip to content

Commit d00e739

Browse files
committed
Python: Consistently use camelCase in annotated call-graph tests
1 parent 65c4e6c commit d00e739

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

python/ql/test/experimental/library-tests/CallGraph/CallGraphTest.qll

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import python
22

3-
/** Gets the comment on the line above for a given `ast_node` */
4-
Comment comment_for(AstNode ast_node) {
5-
exists(int line | line = ast_node.getLocation().getStartLine() - 1 |
3+
/** Gets the comment on the line above `ast` */
4+
Comment commentFor(AstNode ast) {
5+
exists(int line | line = ast.getLocation().getStartLine() - 1 |
66
result
77
.getLocation()
8-
.hasLocationInfo(ast_node.getLocation().getFile().getAbsolutePath(), line, _, line, _)
8+
.hasLocationInfo(ast.getLocation().getFile().getAbsolutePath(), line, _, line, _)
99
)
1010
}
1111

12-
/** Gets the value from `tag:value` in the comment for `ast_node` */
13-
string getAnnotation(AstNode ast_node, string tag) {
14-
exists(Comment comment, string match, string the_regex |
15-
the_regex = "([\\w]+):([\\w.]+)" and
16-
comment = comment_for(ast_node) and
17-
match = comment.getText().regexpFind(the_regex, _, _) and
18-
tag = match.regexpCapture(the_regex, 1) and
19-
result = match.regexpCapture(the_regex, 2)
12+
/** Gets the value from `tag:value` in the comment for `ast` */
13+
string getAnnotation(AstNode ast, string tag) {
14+
exists(Comment comment, string match, string theRegex |
15+
theRegex = "([\\w]+):([\\w.]+)" and
16+
comment = commentFor(ast) and
17+
match = comment.getText().regexpFind(theRegex, _, _) and
18+
tag = match.regexpCapture(theRegex, 1) and
19+
result = match.regexpCapture(theRegex, 2)
2020
)
2121
}
2222

@@ -42,7 +42,7 @@ predicate missingAnnotationForCall(string name, Function callable) {
4242
}
4343

4444
/** There is an obvious problem with the annotation `name` */
45-
predicate name_in_error_state(string name) {
45+
predicate nameInErrorState(string name) {
4646
missingAnnotationForCallable(name, _)
4747
or
4848
nonUniqueAnnotationForCallable(name, _)
@@ -52,7 +52,7 @@ predicate name_in_error_state(string name) {
5252

5353
/** Source code has annotation with `name` showing that `call` will call `callable` */
5454
predicate annotatedCallEdge(string name, Call call, Function callable) {
55-
not name_in_error_state(name) and
55+
not nameInErrorState(name) and
5656
call = annotatedCall(name) and
5757
callable = annotatedCallable(name)
5858
}
@@ -112,13 +112,13 @@ abstract class CallGraphResolver extends TCallGraphResolver {
112112
exists(string name |
113113
message = "Call resolved to the callable named '" + name + "' but was not annotated as such" and
114114
callable = annotatedCallable(name) and
115-
not name_in_error_state(name)
115+
not nameInErrorState(name)
116116
)
117117
or
118118
exists(string name |
119119
message = "Annotated call resolved to unannotated callable" and
120120
call = annotatedCall(name) and
121-
not name_in_error_state(name) and
121+
not nameInErrorState(name) and
122122
not exists( | callable = annotatedCallable(_))
123123
)
124124
)
@@ -130,9 +130,9 @@ abstract class CallGraphResolver extends TCallGraphResolver {
130130
/** A call graph resolver based on the existing points-to analysis */
131131
class PointsToResolver extends CallGraphResolver, TPointsToResolver {
132132
override predicate callEdge(Call call, Function callable) {
133-
exists(PythonFunctionValue func_value |
134-
func_value.getScope() = callable and
135-
call = func_value.getACall().getNode()
133+
exists(PythonFunctionValue funcValue |
134+
funcValue.getScope() = callable and
135+
call = funcValue.getACall().getNode()
136136
)
137137
}
138138

0 commit comments

Comments
 (0)