-
Notifications
You must be signed in to change notification settings - Fork 0
/
number_of_Static-not-Final.boa
44 lines (39 loc) · 1.22 KB
/
number_of_Static-not-Final.boa
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
# Static field public but not final
# output: project id, package.className.methodName (.className for default packages).
p: Project = input;
out : output top(10000) of string weight int;
count: output sum[String] of int;
package: string = "";
class: string = "";
variables: set of string;
counts := 0;
visit(p, visitor {
before node: CodeRepository -> {
# only look at the latest snapshot
# and only include Java files
snapshot := getsnapshot(node, "SOURCE_JAVA_JLS");
foreach (i: int; def(snapshot[i]))
visit(snapshot[i]);
stop;
}
before node: Namespace -> {
package = node.name;
}
before node: Declaration -> {
# only interested in fields, which only occur inside (anonymous) classes
if (node.kind == TypeKind.CLASS || node.kind == TypeKind.ANONYMOUS) {
# find uses and increment counter
foreach (i: int; def(node.fields[i]))
if(has_modifier_public(node.fields[i])&&
has_modifier_static(node.fields[i])&&
!has_modifier_final(node.fields[i])){
counts++;
out << package weight 1;
#count[p.project_url] <<1;
}
} else
stop;
}
});
#if (counts > 0)
# out[p.project_url] << counts;