From 8566b767a24bc2c382391b6eb154f410c9f865b8 Mon Sep 17 00:00:00 2001 From: Gabor Kelemen Date: Fri, 17 Nov 2023 13:03:57 +0100 Subject: [PATCH] find-unused-configkeys: check groups that are not used as templates listing these was lost in the previous commit Change-Id: I5b53c3fcf91db930570ac55e182041b5d54cc196 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159632 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- bin/find-unused-configkeys.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/find-unused-configkeys.sh b/bin/find-unused-configkeys.sh index 1336044b21f5..d25b0ebb5469 100755 --- a/bin/find-unused-configkeys.sh +++ b/bin/find-unused-configkeys.sh @@ -11,12 +11,16 @@ for filename in $(find officecfg/ -name "*xcs"); do for gs in group set node-ref; do + # Search for all nodes with the given node type $gs for gname in $(git grep -aIh "<$gs" "$filename" 2>/dev/null | awk -F'oor:name="' '{print $2}' | awk -F'"' '{print $1}') ; do + # Check whether a group name appears outside of officecfg if [ $(git grep -aI "$gname" 2>/dev/null | grep -saIv ^officecfg 2>/dev/null | wc -l) -eq 0 ] ; then # group, set or node-ref names may serve as oor:node-type templates # check whether this is also unused - report only if both are unused + if [ $(git grep -aIh "oor:node-type=\"$gname" officecfg | wc -l ) -gt 0 ] ; then for tmpl in $(git grep -aIh oor:node-type=\""$gname" officecfg 2>/dev/null | awk -F'oor:name="' '{print $2}' | awk -F '"' '{print $1}' ) ; do + # check whether the set is used outside of officecfg if [ $(git grep -aI "$tmpl" 2>/dev/null | grep -saIv ^officecfg 2>/dev/null | wc -l) -eq 0 ]; then echo "$gname group and $tmpl set in "$filename" appears only in officecfg"; @@ -27,6 +31,10 @@ for filename in $(find officecfg/ -name "*xcs"); do fi fi done + # If it's not used in a template and does not appears outside, report + else + echo "$gname group/set/node-ref in "$filename" appears only in officecfg"; + fi fi done done