From: Donatas Abraitis Date: Mon, 31 Jan 2022 19:33:19 +0000 (+0200) Subject: tools: Check against capital first in JSON keys X-Git-Tag: pim6-testing-20220430~220^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=bcd464bb34706e125424a694a06a2781e0ad409e;p=mirror%2Ffrr.git tools: Check against capital first in JSON keys Signed-off-by: Donatas Abraitis --- diff --git a/tools/coccinelle/json_object_add_camel_case.cocci b/tools/coccinelle/json_object_add_camel_case.cocci new file mode 100644 index 0000000000..279ba213ac --- /dev/null +++ b/tools/coccinelle/json_object_add_camel_case.cocci @@ -0,0 +1,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)) diff --git a/tools/coccinelle/json_object_add_no_whitespace.cocci b/tools/coccinelle/json_object_add_no_whitespace.cocci deleted file mode 100644 index 61250aa39f..0000000000 --- a/tools/coccinelle/json_object_add_no_whitespace.cocci +++ /dev/null @@ -1,17 +0,0 @@ -// 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))