From 1c4a9830f985aaff198527cf92d8bb9647563903 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 24 Apr 2025 10:16:48 +0200 Subject: [PATCH] Scripts: last adjustments? ;) --- Scripts/unused-functions.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Scripts/unused-functions.sh b/Scripts/unused-functions.sh index 84a653385..d8897adfa 100755 --- a/Scripts/unused-functions.sh +++ b/Scripts/unused-functions.sh @@ -47,7 +47,6 @@ grep -Eor '^function &?[^( ]+' ${TESTDIR} | tr ':' ' ' | tr -d '&' | while read MODULE=$(basename ${FILE}) MODULE=${MODULE%.inc} - # exclude indirect plugin calls not otherwise referenced if [ "${BASEDIR}" = "plugins.inc.d" ]; then for PLUGIN in ${PLUGINS}; do @@ -57,8 +56,22 @@ grep -Eor '^function &?[^( ]+' ${TESTDIR} | tr ':' ' ' | tr -d '&' | while read done fi - # either by direct call xxx( or wrapped in single quotes - USED=$(grep -Fr -e "${FUNC}(" -e "'${FUNC}'" -e "'${FUNC}:' ${DIRS} | wc -l | awk '{ print $1 }') + # exclude xmlrpc magic + if [ "${BASEDIR}" = "xmlrpc" ]; then + if [ "${FUNC}" = "xmlrpc_publishable_${MODULE}" ]; then + continue 2 + fi + fi + + # exclude obvious and non-obvious ways to call a function + USED=$(grep -Fr "${FUNC}" ${DIRS} | grep -F \ + -e "${FUNC}(" \ + -e "'${FUNC}'" \ + -e "'${FUNC}:" \ + -e "${FUNC}.bind" \ + -e "${FUNC}.call" \ + -e "= ${FUNC};" \ + | wc -l | awk '{ print $1 }') if [ ${USED} -le 1 ]; then echo "${FUNC}() appears unused" ${NOTE} elif [ ${USED} -eq 2 ]; then