Skip to content

Use an opinionated set of rules for Rubocop #722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

neilvcarvalho
Copy link
Member

Most projects that thoughtbot is working on currently did not start here. The "Use standard" recommendation comes from a time that that wasn't true.

There are a few reasons not to use Standard in existing projects:

  • A large project does not already use Standard and retrofitting would be costly
  • Need or want Rubocop rules other than Standard's opinionated set

Most projects that thoughtbot is working on currently did not start here.
The "Use standard" recommendation comes from a time that that wasn't
true.

There are a few reasons not to use Standard in existing projects:
- A large project does not already use Standard and retrofitting would be costly
- Need or want Rubocop rules other than Standard's opinionated set
@rdnewmanbot
Copy link

We also added reasoning as a sub-bullet to the "rule". We may do another change though to move a broader discussion/reasoning to an adjunct document (beyond just linking to a pull request or issue).

@vburzynski
Copy link
Contributor

vburzynski commented Mar 19, 2025

Some reasoning behind why I would vote to remove the recommendation of using Standard

  • The name has always felt like a form of doublespeak. It seems to deliberately obscure and distort the meaning of the word "standard". The README even furthers the confusion with language such as "Ruby Standard-compliant teams & projects". Which co-opts language used for indicating something is "standards compliant".
  • Standard does not always follow community conventions. For example, requiring that hashes remove spaces inside the beginning and end of hash literals. They do have opinionated arguments for why they chose this styling, but it speaks towards how Standard applies non-standards preferences.
  • Last year I wrote a ruby script to enumerate all the differences between Standard and the default Rubocop configuration. There is a nontrivial number of useful cops that are disabled. Due to the nature of Standard being "unconfigurable", you are not allowed to re-enable these.
    • One example is that Standard disables all of the Metrics/* cops; It would be impossible to set a one-size-fits-all configuration of these rules as they largely all should be tweaked and tuned to individual projects. Standard therefore has to disable them to make them universally applicable. Line length? standardrb/standard#102
    • These cops can be highly advantageous to use on projects.
    • I'd have to dig through my findings again to list other examples.
    • Some of the cops fall outside the purview of the Standard project's goals, yet the gem disallows you from benefiting from their use
  • While it is currently possible to run both rubocop and standard at the same time, it is NOT supported.
    • The README includes the following warning: "Please note that the following usage is not supported and may break at any time. Use at your own risk and please refrain from opening GitHub issues with respect to loading Standard or its plugins' YAML configurations for use by the rubocop CLI."
    • the project will not support using Rubocop, even when it relies heavily on the gem.
    • running both tools is an added cost that is experienced both during local development and on CI.

My strongest point from the items above is that Standard makes it unnecessarily difficult and risky to use common Rubocop cops that fall outside their preferences which center on styling and layout.

And to clarify, the style guides and conventions enforced by Standard are ones I could certainly get used to and even often agree with.

@cpytel
Copy link
Member

cpytel commented Mar 21, 2025

Here is some history on this: 6d86958

The config is still here https://github.com/thoughtbot/guides/blob/main/ruby/.rubocop.yml (or was restored, I'm not sure), though it may have fallen out of maintenance or be reduced.

That being said, I'm not sure about the arguments about existing code being a factor here are really applicable? One of the overarching guidelines in the guide is "Don't rewrite existing code to follow this guide."

@cpytel
Copy link
Member

cpytel commented Mar 21, 2025

Ah, it was added back here 9ac4a38

@nickcharlton
Copy link
Member

I had restored it in #623, because we used the shared configuration feature of Hound on Administrate (and probably others, I don't recall) and we couldn't move quite so fast on that project (removing it caused hundreds of comments on everyone's PRs, it was unpleasant).

We don't use it any more, although I'm yet to tidy up the final bits of linting to remove it entirely. That said, it's not been used in a while now, because we did switch to Standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants