Skip to content

Instantly share code, notes, and snippets.

@phiggins
Last active December 15, 2016 21:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phiggins/7850ccf50d2924f88ad0 to your computer and use it in GitHub Desktop.
Save phiggins/7850ccf50d2924f88ad0 to your computer and use it in GitHub Desktop.
bash scripts for finding dead rails code
for i in app/models/post.rb ; do sed -e "s/\s\+def \(self\.\)\?\([^( ]*\).*\|\s\+scope :\([^,]*\).*/\2\3/" -e 'tx' -e 'd' -e ':x' $i | while read j ; do echo $(grep -R $j app/ lib/ config/ | wc -l) $j ; done ; done | sort -rn
for i in $(find app/views/ -type f) ; do echo $(grep -R $(echo $i | sed "s/.*\/_\?\([^.]*\).*/\1/") app/ | wc -l) $i ; done | sort -rn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment