Ruby Code Linting with RuboCop

Опубликовано: 02 Март 2026
на канале: Brett Codes
5,061
60

In this episode, I go over using RuboCop, configuring it, driving out refactors with it, as well as my thoughts on how far to take it and when it's most useful.

RuboCop is a Ruby linting tool that I've used at various places I've worked and in various projects. It can help catch issues before committing them, improve code quality and performance, and have a consistent style of code throughout a codebase.

The `bundle gem` command has the option to include RuboCop by default, which I've been doing in this series. I adjust the config to suit my needs and refactor the code to appease some of the lint offenses.

Support my screencasts by buying me a coffee: https://www.buymeacoffee.com/brettcha...

Table of contents:
00:00 - Introduction
02:10 - Running RuboCop
04:25 - Configuring RuboCop
05:47 - Fixing Offenses
08:42 - Autocorrecting Offenses
13:21 - Using RuboCop's Docs
15:35 - Method Length
16:49 - Refactoring for ABC Size
34:40 - Catching Errors with RuboCop
36:00 - Closing Thoughts on Linting

RuboCop website: https://rubocop.org/
RuboCop docs: https://docs.rubocop.org/

View the code from this episode: https://github.com/brettchalupa/conve...

Companion blog post: https://code.brettchalupa.com/linting...

Ruby version: 2.6.5
RuboCop version: 1.13.0
Bundler version: 2.2.16
Ruby Gems version: 3.0.6