]> git.puffer.fish Git - mirror/frr.git/commitdiff
tools: Check against capital first in JSON keys
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Mon, 31 Jan 2022 19:33:19 +0000 (21:33 +0200)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Thu, 3 Feb 2022 08:48:06 +0000 (10:48 +0200)
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
tools/coccinelle/json_object_add_camel_case.cocci [new file with mode: 0644]
tools/coccinelle/json_object_add_no_whitespace.cocci [deleted file]

diff --git a/tools/coccinelle/json_object_add_camel_case.cocci b/tools/coccinelle/json_object_add_camel_case.cocci
new file mode 100644 (file)
index 0000000..279ba21
--- /dev/null
@@ -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 (file)
index 61250aa..0000000
+++ /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))