summaryrefslogtreecommitdiff
path: root/tools/coccinelle/json_object_add_camel_case.cocci
blob: 279ba213ac8149544a19722d0f40ed3662e25833 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Catch whitespaces in JSON keys

@r@
identifier json;
constant key;
identifier func =~ "json_object_";
position p;
@@

func(json, key, ...)@p

@script:python@
fmt << r.key;
p << r.p;
@@
if " " in str(fmt):
    print("Whitespace detected in JSON keys %s:%s:%s:%s" % (p[0].file, p[0].line, p[0].column, fmt))
if str(fmt)[1].isupper():
    print("Capital first detected in JSON keys %s:%s:%s:%s" % (p[0].file, p[0].line, p[0].column, fmt))