Revelry’s Pull Request Robot – Meet Lintron

I’m here to tell you the story of Lintron, our pull request linting robot.
Lintron is a tool that I wrote which automatically lints all code in all of our
pull requests at Revelry. We’ve been using it constantly since May and we’ve had
amazing results.

Before Lintron

Before Lintron, our code quality standards and style guides lived mostly in our
heads. They were interpreted and enforced differently by different code reviewers.
Also, reviewers had to comment on each code quality or style issue by hand. This
approach made a lot of busy work for reviewers and resulted in code that wasn’t
as consistent as we wanted.

It was silly. We had people doing static analysis that could be done by robots.
So I made Lintron.

What is Lintron?

Lintron listens for pull request webhooks. Then, it retrieves the PR
and its files from GitHub. It runs each file through one or more linters
(determined by file extension) and then uses the GitHub comments API to list any
violations immediately next to the corresponding line of code in the diff (see
the screenshot at the top of this post). It ignores violations on lines that the
PR doesn’t touch.

pull request robot

Lintron, our pull request robot, is a Rails application with no database. PRs are linted
immediately, and Lintron retains no local state. I used the GitHub API as the only
data store. I wrapped each linter in a common interface (i.e. the adapter
pattern) so that the application code stays extremely simple.

Lintron currently has adapters for these linters:

The results have been great

Within weeks of deploying Lintron, our code style had become much more consistent.
The robot’s consistent eye has also saved us from many code smells and
logic issues that might’ve escaped human reviewers.

When we create a new code standard, we don’t send around a memo. We update
Lintron. Within a week, everyone figures out the new rule and writes better
code.

The most important result is that reviewers can now focus on providing substantive
feedback, rather than spending their time on rote style issues.

As Joel said:

joel on pull request robot

You can use it too!

If you want to try Lintron out, the source is available on GitHub. Have questions? I’m on ask.fm.