Created
May 28, 2018 08:54
-
-
Save adfinlay/edba959abd6277820a43fbdde575ea0b to your computer and use it in GitHub Desktop.
List unused Symfony routes and controller actions
This file contains hidden or 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
#!/usr/bin/env bash | |
echo Unused routes | |
bin/console router:debug | awk '{ print $1 }' | sort | uniq | grep -vE '(_profiler|_wdt|_configurator|Name|router)' | xargs -I {} sh -c "echo {} \`git grep \'{}\' | wc -l\`" | awk '{ if ($2 == "0") print $1 }' | |
# If Symfony 2 use below (app/console instead of bin/console | |
#app/console router:debug | awk '{ print $1 }' | sort | uniq | grep -vE '(_profiler|_wdt|_configurator|Name|router)' | xargs -I {} sh -c "echo {} \`git grep \'{}\' | wc -l\`" | awk '{ if ($2 == "0") print $1 }' | |
echo Unused controller actions | |
grep -rE 'public function.*Action\(' src/ | grep Controller | awk '{ gsub(/src\/(Platformd|Velocity42)\//, ""); print }' | awk '{ gsub(/\/Controller\//, ":"); print }' | awk '{ gsub(/Controller\.php: public function /, ":"); print }' | awk -F 'Action' '{ print $1 }' | sort | uniq | xargs -I {} sh -c "echo {} \`git grep -i {} | wc -l\`" | awk '{ if ($2 == "0") print $1 }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment