Filter

Sign up for our newsletter

Receive a selection of our favorite articles from our blog and around the web straight to your inbox.

Article  |  Development

Code Quality Matters in Rails

Reading time: Less than a minute

Code Quality Matters in Rails

We recently released the results of our 2018 Ruby on Rails community survey. Over the next week, we'll be highlighting some of the interesting data this survey of the community uncovered.

Alarmingly, 23% of participants in our 2018 Ruby on Rails survey reported not using any of the tools to check code quality.

Thankfully 67% use Rubocop. Rubocop is a real gem (pun intended). It’s more than a style guide check. It also ensures all developers working on a project use the same set of guidelines for metrics like assignment branch condition (ABC) size to prohibit methods from getting too complex. Running rubocop on a feature branch before submitting a PR is a great asset for new team members who are become acclimated to your team’s conventions.

Simplecov measures how well your tests are covering your code base. We defined "good" coverage as 80%, but many strive for higher. Looking at your overall coverage provided in the default Simplecov console output after test are run is only part of the story.

Your tests could return an 85% test coverage score, but when you look at the breakdown, only 60% of the code in your models are actually getting testing. You can always set up your CI to measure the groupings (model, controllers, etc.) separately.

Rubocop and Simplecov are both great tools, but worthless if developers aren’t running them after they commit code. Using continuous integration (CI) services ensures this doesn’t happen. CI services like Circle CI, Jenkins, and Travis CI will run rubcocop and simplecov against code pushed to the repository and alert the team when code fails the checks configured for rubocop or test coverage slips below a desired percentage.

From the 2018 Rails Survey, 75% of developers reported using some CI service in their development cycle. This is a promising number, but it could always be better – we think it’s key to healthy, maintainable application. When a team uses code quality tools a healthier codebase is sure to result.


Click below to view more insights from our 2018 survey of the Rails community.

View the 2018 rails survey results
comments powered by Disqus

Have a project that needs help?

New Call-to-action