bin/find-unused-configkeys.sh |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

New commits:
commit 23e106034e86b13a00a5039486c3d6bb57f98382
Author:     Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
AuthorDate: Thu Nov 9 14:16:22 2023 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Sat Nov 11 18:30:30 2023 +0100

    find-unused-configkeys: check whether sets...
    
    are used at all, if they have an otherwise unused group as template
    
    TODO: Still gives some false positives if a group is only used
    as template of a set which is only used as template of another
    set which is actually used (MergeToolBarInstruction 
MergeStatusBarInstruction)
    
    Change-Id: Ia2f83c12a4e0bdcc88b1530bac4daaf456531f8b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159297
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/bin/find-unused-configkeys.sh b/bin/find-unused-configkeys.sh
index 9a159da23ebc..1336044b21f5 100755
--- a/bin/find-unused-configkeys.sh
+++ b/bin/find-unused-configkeys.sh
@@ -11,14 +11,22 @@
 
 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 ] ;
+        for gname in $(git grep -aIh "<$gs" "$filename" 2>/dev/null | awk 
-F'oor:name="' '{print $2}' | awk -F'"' '{print $1}') ; do
+            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
-                if [ $(git grep "$gname" officecfg | grep oor:node-type | wc 
-l ) -eq 0 ] ;
-                then
-                    echo "$gname group in "$filename" appears only in 
officecfg";
-                fi
+                # check whether this is also unused - report only if both are 
unused
+                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
+                    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";
+                    else
+                        if [ $(git grep -aI "$gname" officecfg 2>/dev/null | 
grep -saI oor:node-type 2>/dev/null | wc -l ) -eq 0 ] ;
+                        then
+                           echo "$gname group in "$filename" appears only in 
officecfg";
+                        fi
+                    fi
+                done
             fi
         done
     done

Reply via email to