frr/tools/coccinelle/json_object_add_camel_case.cocci
Daniel Baumann 3124f89aed
Adding upstream version 10.1.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-05 10:03:58 +01:00

19 lines
439 B
Text

// 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))