update credits
[LibreOffice.git] / bin / find-unused-configkeys.sh
blobd25b0ebb54698b52ea0b534f7e5953c171096a7a
1 #!/usr/bin/env bash
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # find group, set and key names in officecfg that are not used in the code base
10 # caveat: only effective for reasonably unique strings
12 for filename in $(find officecfg/ -name "*xcs"); do
13 for gs in group set node-ref; do
14 # Search for all nodes with the given node type $gs
15 for gname in $(git grep -aIh "<$gs" "$filename" 2>/dev/null | awk -F'oor:name="' '{print $2}' | awk -F'"' '{print $1}') ; do
16 # Check whether a group name appears outside of officecfg
17 if [ $(git grep -aI "$gname" 2>/dev/null | grep -saIv ^officecfg 2>/dev/null | wc -l) -eq 0 ] ;
18 then
19 # group, set or node-ref names may serve as oor:node-type templates
20 # check whether this is also unused - report only if both are unused
21 if [ $(git grep -aIh "oor:node-type=\"$gname" officecfg | wc -l ) -gt 0 ] ; then
22 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
23 # check whether the set is used outside of officecfg
24 if [ $(git grep -aI "$tmpl" 2>/dev/null | grep -saIv ^officecfg 2>/dev/null | wc -l) -eq 0 ];
25 then
26 echo "$gname group and $tmpl set in "$filename" appears only in officecfg";
27 else
28 if [ $(git grep -aI "$gname" officecfg 2>/dev/null | grep -saI oor:node-type 2>/dev/null | wc -l ) -eq 0 ] ;
29 then
30 echo "$gname group in "$filename" appears only in officecfg";
33 done
34 # If it's not used in a template and does not appears outside, report
35 else
36 echo "$gname group/set/node-ref in "$filename" appears only in officecfg";
39 done
40 done
42 for pname in $(git grep -h "<prop" "$filename" | awk -F'oor:name="' '{print $2}' | awk -F'"' '{print $1}') ; do
43 if [ $(git grep "$pname" | grep -v ^officecfg | wc -l) -eq 0 ] ;
44 then
45 echo "$pname property in "$filename" appears only in officecfg";
47 done
49 done