It’s time to move on from the ReportsController to code that needs to be refactored more. Using Caliper’s Flay Report, it looks like IssueStatusesController, TrackersController, AuthSourcesController, and RolesController all have the exact same index action. 1 2 3 4 def index list render :action => 'list' unless request.xhr? end def index list render :action => …
Tag: refactoring
Daily Refactor #14: Extract method to before_filter in ReportsController
The Refactoring I started on a larger refactoring of the issue_report_details method today but found a potential security bug so I threw it away. It’s better to be secure than refactored :) So instead, I performed a common Rails refactoring for removing duplicate code: extracting some code to a before filter. Before 1 2 3 …
Daily Refactor #13: Inline utility methods in ReportsController
The Refactoring Today I used the inline method refactoring to make the ReportsController even more concise by removing all of the utility methods. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 …
Daily Refactor #12: Extract rendering in the case statement
It seems like every time I try to apply a big refactoring, there are parts that are missed. I tried to refactor the entire case statement in issue_report_details into a common data structure and a lookup method. But it ended up being more complex than the case statement was so I threw it away and …
Daily Refactor #11: Extract action in ReportsController
I’m back up in the ReportsController now, getting ready to tackle some more of the duplication. The Refactoring Before 1 2 3 4 5 # config/routes.rb map.with_options :controller => 'reports', :action => 'issue_report', :conditions => {:method => :get} do |reports| reports.connect 'projects/:id/issues/report' reports.connect 'projects/:id/issues/report/:detail' end# config/routes.rb map.with_options :controller => 'reports', :action => 'issue_report', :conditions => …