Trivial script to find unused functions in JavaScript

I haven't found any more advanced approach to finding unused JS
functions, but this seems to produce at least some results, so better
than nothing.

There is nothing new to remove though, the last round of cleanup has
removed what was there to remove.

Signed-off-by: Jan Holesovsky <kendy@collabora.com>
Change-Id: If39fecb7781cc78b30cb95da354c71d3547b7ae7
pull/1398/head
Jan Holesovsky 2021-01-07 09:54:04 +01:00 committed by Jan Holesovsky
parent 18c4ad5584
commit efd9b93652
1 changed files with 10 additions and 0 deletions

View File

@ -0,0 +1,10 @@
#! /bin/bash
find loleaflet/src/ -name "*.js" -exec grep ': function' \{\} \; | sed -e 's/:.*//' -e 's/^[\t ]*//' -e 's/[\t ]*$//' | grep -v " " | sort | uniq | \
while read FUNC ; do
NUM=`git grep "\<$FUNC\>" loleaflet/src/ | wc -l`
#echo "Trying $FUNC: $NUM"
if [ "$NUM" = "1" ] ; then
git --no-pager grep "\<$FUNC\>" loleaflet/src/
fi
done