Last active
August 29, 2015 13:56
-
-
Save aslushnikov/9208534 to your computer and use it in GitHub Desktop.
Find private functions that have never been used in inspector front-end
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
if (( $# < 1 )); then | |
echo "Specify filename to analyze" | |
exit 1 | |
fi | |
fileName=$1 | |
for i in $(grep -o '_[a-zA-Z0-9_]*:\s\+fun' $fileName | cut -d':' -f1); do | |
# count number of occurences in file | |
num=$(grep $i $fileName | wc -l) | |
if (( $num == 1 )); then | |
# if declaration only found in file, then try to search whole repo | |
num=$(git grep $i | wc -l) | |
if (( $num == 1 )); then | |
if [[ -z $shownFileName ]]; then | |
echo "Processing $fileName" | |
shownFileName="yes" | |
fi | |
echo " WARN: $i is only one time used (in declaration)" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment