Posted about 1 month ago. Visible to the public.

Adding makandra-rubocop to an existing code base

Introduction

Most of the time it is a tedious task to apply a code style guide to an existing code base as there are likely to be a lot of conflicts. At makandra we are using makandra-rubocop to have code style checks. Here is some advice on how to add makandra-rubocop efficiently.

Run rubocop in parallel

To bost performance rubocop can process in parallel (just not in combination with every switch):

Copy
$ rubocop --parallel # or short: $ rubocop -p

Apply Cops separately

If you want to review each correction, it is easier to run each Cop separately. This way you know what kind of change to expect and don't have to find out what changed.

1. list conflicting cops

Copy
$ rubocop --parallel --format offenses 1815/1815 files |========================== 100 ===========================>| Time: 00:00:00 1074 Lint/Void 418 Naming/VariableNumber 255 Style/StringLiterals ... -- 4727 Total

2. correct single Cop

Copy
$ rubocop --auto-correct --only Style/StringLiterals

3. review changes

Copy
$ git add -p
Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Avatar
Daniel Straßner
Last edit:
26 days ago
by Daniel Straßner
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Daniel Straßner to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more