rubocop README

The project's README from github.com/rubocop/rubocop. As one markdown file: README.md.

RuboCop Logo


Ruby Style Guide Gem Version CI Discord

Role models are important.
-- Officer Alex J. Murphy / RoboCop

RuboCop is a Ruby static code analyzer (a.k.a. linter) and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide. Apart from reporting the problems discovered in your code, RuboCop can also automatically fix many of them for you.

RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various configuration options.


Patreon OpenCollective OpenCollective Tidelift

Working on RuboCop is often fun, but it also requires a great deal of time and energy.

Please consider financially supporting its ongoing development.

Installation

RuboCop's installation is pretty standard:

gem install rubocop

If you'd rather install RuboCop using bundler, add a line for it in your Gemfile (but set the require option to false, as it is a standalone tool):

gem 'rubocop', require: false

RuboCop is stable between minor versions, both in terms of API and cop configuration. We aim to ease the maintenance of RuboCop extensions and the upgrades between RuboCop releases. All big changes are reserved for major releases. To prevent an unwanted RuboCop update you might want to use a conservative version lock in your Gemfile:

gem 'rubocop', '~> 1.82', require: false

See our versioning policy for further details.

Quickstart

Just type rubocop in a Ruby project's folder and watch the magic happen.

cd my/cool/ruby/project
rubocop

[!TIP]

You can also use this magic in your favorite editor with RuboCop's built-in LSP server.

Documentation

You can read a lot more about RuboCop in its official docs.

Compatibility

RuboCop officially supports the following runtime Ruby implementations:

It targets Ruby 2.0+ for code analysis.

See the compatibility documentation for further details.

Readme Badge

If you use RuboCop in your project, you can include one of these badges in your readme to let people know that your code is written following the community Ruby Style Guide.

Ruby Style Guide

Ruby Style Guide

Here are the Markdown snippets for the two badges:

[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)

[![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)

Team

Here's a list of RuboCop's core developers:

See the team page for more details.

RuboCop's logo was created by Dimiter Petrov. You can find the logo in various formats here.

The logo is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Contributors

Here's a list of all the people who have contributed to the development of RuboCop.

I'm extremely grateful to each and every one of them!

If you'd like to contribute to RuboCop, please take the time to go through our short contribution guidelines.

Converting more of the Ruby Style Guide into RuboCop cops is our top priority right now. Writing a new cop is a great way to dive into RuboCop!

Of course, bug reports and suggestions for improvements are always welcome. GitHub pull requests are even better! :-)

Funding

While RuboCop is free software and will always be, the project would benefit immensely from some funding. Raising a monthly budget of a couple of thousand dollars would make it possible to pay people to work on certain complex features, fund other development related stuff (e.g. hardware, conference trips) and so on. Raising a monthly budget of over $5000 would open the possibility of someone working full-time on the project which would speed up the pace of development significantly.

We welcome both individual and corporate sponsors! We also offer a wide array of funding channels to account for your preferences (although currently Open Collective is our preferred funding platform).

If you're working in a company that's making significant use of RuboCop we'd appreciate it if you suggest to your company to become a RuboCop sponsor.

You can support the development of RuboCop via GitHub Sponsors, Patreon, PayPal, Open Collective and Tidelift .

[!NOTE]

If doing a sponsorship in the form of donation is problematic for your company from an accounting standpoint, we'd recommend the use of Tidelift, where you can get a support-like subscription instead.

Open Collective for Individuals

Support us with a monthly donation and help us continue our activities. [Become a backer]

Open Collective for Organizations

Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]

Release Notes

RuboCop's release notes are available here.

Copyright (c) 2012-2026 Bozhidar Batsov. See LICENSE.txt for further details.

rubocop (rubocop/rubocop)

Searching Database…

12.9K ·GitHub
这是什么?RuboCop 是一款面向 Ruby 的静态代码分析工具(linter)兼代码格式化工具,开箱即用就能强制执行社区的 Ruby 风格指南,同时也可以配置为执行你自己的代码风格。
它只是报告问题,还是也能帮我修改代码?两者都可以:它会报告风格和质量上的违规项(称为 “cop”),还能自动修复其中许多问题。
怎么安装和运行它?安装 rubocop gem(可以直接安装,也可以通过 Bundler 把它加入 Gemfile,并将 require 设为 false),然后在 Ruby 项目文件夹中直接输入 “rubocop” 即可。
我需要哪个 Ruby 版本?RuboCop 可运行于 MRI 2.7+ 或 JRuby 9.4+,并且针对被分析的代码以 Ruby 2.0+ 为目标。
更新 RuboCop 会破坏我现有的配置吗?RuboCop 力求在次版本之间保持 API 和 cop 配置的稳定,但较大的变更会留到主版本发布时进行,因此你可能需要在 Gemfile 中锁定一个较保守的版本,以避免意外更新。
除了命令行,我能在编辑器里使用它吗?可以,RuboCop 内置了 LSP 服务器,你可以将其接入编辑器,实现实时代码检查。
RuboCop 的行为有多容易调整?它被描述为极其灵活,其行为的大多数方面都可以通过各种配置选项进行设置。
我为什么要在 readme 中放一个 RuboCop 徽章?readme 徽章可以让大家知道你的代码遵循社区的 Ruby 风格指南,而 RuboCop 为两种徽章样式提供了 Markdown 代码片段。
我能在经济上支持 RuboCop 的开发吗?可以,该项目接受通过 GitHub Sponsors、Patreon、PayPal、Open Collective 和 Tidelift 的资助,主要由 Bozhidar Batsov 和一个小型核心团队维护。
What are similar projects?ruff, biome, fallow, standard, ast-grep, ruby-style-guide, perch, jevlint
Creator
rubocop
Size
55.4 MB
Stars
12.9K
Age
14y
Commits · 90 Days