Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rough and naive script to find unused functions in php files
#!/bin/bash
function report_unused_functions() {
# Find the function
# Remove the ampersands for pass by reference functions
# Remove everything after and including the ( in the function name
git grep -Ei '(public|private|protected) function' $1 | awk '{print $4}' | tr -d '&' | cut -f1 -d"(" | while read -r function ; do
match_count="$(git grep -i $function| wc -l)"
if [ "$match_count" -lt 2 ]; then
echo "$function can be removed. $match_count match"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.