From 81d20f15b34f8b76610a58e3e7f55cc872ed6025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 19 Apr 2010 14:08:54 +0200 Subject: [PATCH] Add script for finding unused messages Taken from QA_3_3 and slightly modified. This just checks libraries/messages.inc.php and could be removed once this file is gone. --- scripts/find_unused_messages.sh | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 scripts/find_unused_messages.sh diff --git a/scripts/find_unused_messages.sh b/scripts/find_unused_messages.sh new file mode 100755 index 000000000..79649524c --- /dev/null +++ b/scripts/find_unused_messages.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +export LANG=C +set -e + +# Simple script to find unused message strings by Michal Čihař + +tmp1=`mktemp` +tmp2=`mktemp` +grep -o '^\$\' libraries/messages.inc.php \ + | tr -d '$' \ + | grep -Ev '^str(Transformation_|ShowStatus)' | sort -u > $tmp1 +grep -ho '\' `find . -type f -a -name '*.php' -a -not -path '*/lang/*'` \ + | grep -Ev '^str(Transformation_|ShowStatus|Setup)' | sort -u > $tmp2 + +echo Please note that you need to check results of this script, it doesn\'t +echo understand PHP, it only tries to find what looks like message name. + +echo +echo Used messages not present in messages file: +echo '(this contains generated messages and composed message names, so these' +echo 'are not necessary a errors!)' +echo + +# filter out known false positives +diff $tmp1 $tmp2 | awk '/^>/ {print $2}' | grep -Ev '(strEncto|strXkana|strDBLink|strPrivDesc|strPrivDescProcess|strTableListOptions|strMissingParameter|strAttribute|strDoSelectAll)' + +echo +echo Not used messages present in messages file: +echo + +diff $tmp1 $tmp2 | awk '/^