An updated guide to writing custom RuboCop cops in 2026, covering the new plugin system based on lint_roller, the rubocop-internal_affairs department for linting cop implementations, the requires_gem API for gem-conditional cops, nuances of safe vs. unsafe autocorrection, and design trade-offs around using runtime information
•6m read time• From evilmartians.com
Table of contents
Custom "cops" for RuboCop: an emergency service for your Ruby codeIntroducing the Plugin systemUsing RuboCop’s internal rulesetUsing gem and Ruby runtime conditionalsThe Nuances of Safe AutocorrectionFollowing the RuboCop designSort: