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 …
Tag: redmine
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 => …
Daily Refactor #10: Pull up the #find_project method to the ApplicationController
Back up in the ReportsController, there is still some duplication that needs to be resolved. There are nine methods: 1 controller action (issue_report) 1 private before_filter method (find_project) 7 private utility methods The controller action is ripe for a few refactorings but I wanted to start with the find_project for personal reasons. I used the …