X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/05ebed925ae2b5e7bf2a599536ba7d7ac15ffbf7..ad088c1324d08a65f6f5336bedf7a88a8a8950e7:/lib/tasks/rails.rake diff --git a/lib/tasks/rails.rake b/lib/tasks/rails.rake new file mode 100644 index 0000000..99d3321 --- /dev/null +++ b/lib/tasks/rails.rake @@ -0,0 +1,32 @@ +desc "Checks your app and gently warns you if you are using deprecated code." +task :deprecated => :environment do + deprecated = { + '@params' => 'Use params[] instead', + '@session' => 'Use session[] instead', + '@flash' => 'Use flash[] instead', + '@request' => 'Use request[] instead', + '@env' => 'Use env[] instead', + 'find_all' => 'Use find(:all) instead', + 'find_first' => 'Use find(:first) instead', + 'render_partial' => 'Use render :partial instead', + 'component' => 'Use of components are frowned upon', + 'paginate' => 'The default paginator is slow. Writing your own may be faster', + 'start_form_tag' => 'Use form_for instead', + 'end_form_tag' => 'Use form_for instead', + ':post => true' => 'Use :method => :post instead' + } + + deprecated.each do |key, warning| + puts '--> ' + key + output = `cd '#{File.expand_path('app', RAILS_ROOT)}' && grep -n --exclude=*.svn* -r '#{key}' *` + unless output =~ /^$/ + puts " !! " + warning + " !!" + puts ' ' + '.' * (warning.length + 6) + puts output + else + puts " Clean! Cheers for you!" + end + puts + end +end +