Skip to content

Instantly share code, notes, and snippets.

@jordinl-zz
Created April 3, 2013 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jordinl-zz/5303024 to your computer and use it in GitHub Desktop.
Save jordinl-zz/5303024 to your computer and use it in GitHub Desktop.
Find unused methods in a rails projecy
ignored_dirs = "--ignore-dir=spec --ignore-dir=log --ignore-dir=tmp --ignore-dir=vendor"
methods = `ack --no-group --no-color #{ignored_dirs} 'def .*'`.split("\n").map { |x| x.split(/\:\s*def\s*(?:self\.)?|\s|\(/)[0..1] }
methods.each do |filename, method|
if `ack --no-group --no-color #{ignored_dirs} -w #{method}`.strip.split("\n").length == 1
puts "#{filename} #{method}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment