Major update of Selectricity to work with Rails 2.2.2 from 1.2!
[selectricity] / lib / tasks / rails.rake
1 desc "Checks your app and gently warns you if you are using deprecated code." 
2 task :deprecated => :environment do
3   deprecated = {
4     '@params'    => 'Use params[] instead',
5     '@session'   => 'Use session[] instead',
6     '@flash'     => 'Use flash[] instead',
7     '@request'   => 'Use request[] instead',
8     '@env' => 'Use env[] instead',
9     'find_all'   => 'Use find(:all) instead',
10     'find_first' => 'Use find(:first) instead',
11     'render_partial' => 'Use render :partial instead',
12     'component'  => 'Use of components are frowned upon',
13     'paginate'   => 'The default paginator is slow. Writing your own may be faster',
14     'start_form_tag'   => 'Use form_for instead',
15     'end_form_tag'   => 'Use form_for instead',
16     ':post => true'   => 'Use :method => :post instead'
17   }
18
19   deprecated.each do |key, warning|
20     puts '--> ' + key
21     output = `cd '#{File.expand_path('app', RAILS_ROOT)}' && grep -n --exclude=*.svn* -r '#{key}' *`
22     unless output =~ /^$/
23       puts "  !! " + warning + " !!" 
24       puts '  ' + '.' * (warning.length + 6)
25       puts output
26     else
27       puts "  Clean! Cheers for you!" 
28     end
29     puts
30   end
31 end
32

Benjamin Mako Hill || Want to submit a patch?