Yesterday’s refactoring to the ReportsController helped to move some of the ActiveRecord::Base#select_all methods out of the controller but I was still left with the duplication in the Issue model. Today, I’ll dig into those model methods and remove most of the duplication. The Refactoring Before 1 2 3 4 5 6 7 8 9 10 …
Tag: redmine
Daily Refactor #8: Move method in the ReportsController
The Refactoring This is the first part to a larger refactoring of the ReportsController in Redmine. This controller is responsible for calculating the total number of issues based on different criteria (e.g. issue status, issue priority). There are two big problems with the current code: It has a lot of duplication, both in the main …
Daily Refactor #7: Extract method in fetch_changesets
Working off of Caliper’s flay report for Redmine, I was able to refactor another code duplication. The Refactoring Redmine supports connecting to seven different source control systems to import their changes (e.g. git, subversion, mercurial). When Redmine runs the import, it adds each Changeset (a commit) into the database and also information about each Change …
Daily Refactor #6: Move recipients method to acts_as_event
This week I’m planning to do some refactoring on Redmine’s code base. Today I fixed a smell that Caliper found with flay. The Refactoring Redmine has several model objects that generate Events, which are listed on it’s Activity Page and cause email notifications to be sent. A few of these models had identical recipients methods …
Daily Refactor #5: Remove iteration by using Enumerable
Today is another simple refactoring to the BulkTimeEntry plugin’s helper. A common function is needing to sort one set of data into two different sets. The quick and dirty way is to just loop over each item in the set and build up the two sets yourself. But Ruby’s Arrays have another way… The Refactoring …