Skip to content

Instantly share code, notes, and snippets.

@hovsater
Created April 29, 2023 17:21
Show Gist options
  • Save hovsater/a0b1c26ead82e49bb9f07d23a1ba5f8c to your computer and use it in GitHub Desktop.
Save hovsater/a0b1c26ead82e49bb9f07d23a1ba5f8c to your computer and use it in GitHub Desktop.
Poor Man's version of finding dead code (specifically Ruby constants)
grep -REho --include \*.rb '\b[A-Z_]+\b\s*=' . | tr -d '=' | cut -d' ' -f1 | sort | uniq -u | xargs -I{} bash -c 'if [[ $(grep -Rhow --include \*.rb "{}" . | wc -l) -eq 1 ]] ; then echo {} ; fi'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment