RuboCop in legacy projects, part 1: TODOs and TODON’Ts

Ruby and Rails developers: adding style linters to your legacy projects is harder than it should be. Let’s do something about that.

Scott Matthewman
6 min readOct 2, 2019

This is the first of a series of posts I’m writing about implementing RuboCop in legacy Ruby and Rails projects, and which I am building into a wider talk to be given at a later date.

I’ve talked before about how having a consistent style guide is essential for any team of developers, and how one can set up RuboCop to apply that style guide across multiple projects managed by the same team.

But what if you have a project which has been worked on for a number of years without any style guide at all? In a typical Rails project, that could mean several thousand lines of code, each with radically different stylistic approaches depending upon which developer was working on it at the time.

RuboCop has some tools which can help you. But if you apply them without knowing what you are doing, you might make things worse for yourself.

The current way of thinking is wrong

There is advice out there for starting with RuboCop. The gem’s command-line executable has options to help. It’s advice I’ve…

--

--

Scott Matthewman

Scott is a software developer during the day and a theatre critic & director of an evening. Which is the worst superhero identity ever.