I’m starting to refactor my Redmine Invoice plugin now. This plugin is over two years old now and it’s code has seen better days. The Refactoring The Rails Best Practices gem showed me a quick refactoring to remove some duplication from InvoiceController using a before_filter. Before 1 2 3 4 5 6 7 8 9 …
Tag: refactoring
Daily Refactor #72: Move Method in KanbansController
The Refactoring Today I used move method to clean up a hack job I made a couple of months ago. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 class KanbansController < ApplicationController def sync # Brute force update :) Issue.all.each do |issue| KanbanIssue.update_from_issue(issue) end respond_to do …
Daily Refactor #71: Extract Method in KanbansController to before_filter
The code in the Redmine Merge plugin looks pretty good so I’m going back to my Redmine Kanban plugin. Today’s refactoring was guided by the Rails Best Practices gem. This gem uses static code analysis to search for common smells in Rails applications. Running it on Redmine Kanban showed several smells I can tackle: ./app/controllers/kanbans_controller.rb:8,13 …
Daily Refactor #70: Inline Temp in SourceVersion#migrate
The Refactoring Today’s refactoring is just like yesterday’s but I wanted to show a quick tip with #create! I didn’t mention. Before 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 class SourceVersion < ActiveRecord::Base include SecondDatabase set_table_name :versions def self.migrate all.each do |source_version| v = Version.new v.attributes …
Daily Refactor #69: Inline Temp in SourceNews#migrate
I wanted to start refactoring my Redmine merge plugin now. I’m getting it ready for a release so doing a few refactorings now will help me make sure it’s working properly. The Refactoring Using inline temp I was able to clean up how the SourceNews#migrate converts data from one database to the other database. Before …