summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGabor Kelemen <kelemeng@ubuntu.com>2023-10-03 18:24:36 +0200
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2023-10-05 14:43:43 +0200
commitb3ebcb83c3915e99a9572850dc2db4998a438b45 (patch)
tree717d178ec591a9cd20741eb11b4548896efec4f5 /bin
parentf9ac0ced960112af69caeacfffd7ebd200f07221 (diff)
Add script to find unused config groups/keys in officecfg
Change-Id: Ic5f71ae8fd2ceab3c2480e083788d904804da213 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157523 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/find-unused-configkeys.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/bin/find-unused-configkeys.sh b/bin/find-unused-configkeys.sh
new file mode 100755
index 000000000000..9a159da23ebc
--- /dev/null
+++ b/bin/find-unused-configkeys.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# find group, set and key names in officecfg that are not used in the code base
+# caveat: only effective for reasonably unique strings
+
+for filename in $(find officecfg/ -name "*xcs"); do
+ for gs in group set node-ref; do
+ for gname in $(git grep -h "<$gs" "$filename" | awk -F'oor:name="' '{print $2}' | awk -F'"' '{print $1}') ; do
+ if [ $(git grep "$gname" | grep -v ^officecfg | wc -l) -eq 0 ] ;
+ then
+ # group, set or node-ref names may serve as oor:node-type templates
+ if [ $(git grep "$gname" officecfg | grep oor:node-type | wc -l ) -eq 0 ] ;
+ then
+ echo "$gname group in "$filename" appears only in officecfg";
+ fi
+ fi
+ done
+ done
+
+ for pname in $(git grep -h "<prop" "$filename" | awk -F'oor:name="' '{print $2}' | awk -F'"' '{print $1}') ; do
+ if [ $(git grep "$pname" | grep -v ^officecfg | wc -l) -eq 0 ] ;
+ then
+ echo "$pname property in "$filename" appears only in officecfg";
+ fi
+ done
+
+done