Skip to content

Instantly share code, notes, and snippets.

@timfeirg
Created September 25, 2018 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timfeirg/348036656329e2b5f2a3076ee979d70b to your computer and use it in GitHub Desktop.
Save timfeirg/348036656329e2b5f2a3076ee979d70b to your computer and use it in GitHub Desktop.
analyse unused class and functions (using ag)
#!/bin/sh
set -e
target_directory=${1-.}
export IFS='
'
for target in $(ag -o '((class|def)\s+(\w+))'); do
target_name=$(echo $target | ag -o '\w+$')
occurance=$(ag -Q $target_name $target_directory --py | wc -l)
if [ $occurance -eq 1 ]; then
echo $target
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment