Skip to content

Commit 8a88fc5

Browse files
Use an opinionated set of rules for Rubocop (#722)
* Use an opinionated set of rules for Rubocop 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 * additions to nme-standard branch (#754) * Use an opinionated set of rules for Rubocop 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 * link rubocop guideline to additional information * fix typos and add trade-offs for using standard --------- Co-authored-by: Neil Carvalho <[email protected]> --------- Co-authored-by: Valerie Burzynski <[email protected]>
1 parent 383a792 commit 8a88fc5

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

.markdownlint-cli2.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149

150150
/* MD052 - Reference links and images should use a label that is defined */
151151
"reference-links-images": {
152-
"shortcut_syntax": true
152+
"shortcut_syntax": false
153153
},
154154

155155
/* MD053 - Link and image reference definitions should be needed */

ruby/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[Sample 1](sample_1.rb) [Sample 2](sample_2.rb)
44

5-
- Use [standard]
5+
- [Use an opinionated set of rules for Rubocop](./Use an opinionated set of rules for Rubocop.md)
66
- Avoid conditional modifiers (lines that end with conditionals). [36491dbb9]
77
- Avoid multiple assignments per line (`one, two = 1, 2`). [#109]
88
- Avoid organizational comments (`# Validations`). [#63]
@@ -41,7 +41,6 @@
4141
- Prefer `private` when indicating scope. Use `protected` only with comparison
4242
methods like `def ==(other)`, `def <(other)`, and `def >(other)`.
4343

44-
[standard]: https://github.com/testdouble/standard
4544
[#63]: https://github.com/thoughtbot/guides/pull/63
4645
[#109]: https://github.com/thoughtbot/guides/pull/109
4746
[#122]: https://github.com/thoughtbot/guides/pull/122
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use an opinionated set of rules for Rubocop
2+
3+
Ruby code can be written in many different styles and still be syntactically correct. The presence of divergent style and
4+
format can disrupt communication as well as complicate feature development. Code that exhibits a consistent style is
5+
easier to understand and maintain. The absence of consistent enforced style can result in unnecessary code churn.
6+
7+
**Therefore:** Use an opinionated set of rules for Rubocop when coding in Ruby.
8+
9+
- Prefer [standard] for new projects.
10+
- By employing an already decided configuration, you avoid bikeshedding on what the Rubocop configuration should be.
11+
- Code that is consistently formatted and styled will be easier to work with.
12+
13+
There are, however, a few reasons one might choose not to introduce Standard in a project:
14+
15+
- Change for the sake of change can be disruptive
16+
- An existing project may already employ it's own opinionated configuration of Rubocop and that set of rules is working.
17+
- A large project, which does not already use Standard, might require a costly amount of time to refactor and retrofit
18+
existing code to conform to a new set of conventions.
19+
- There exists a need or desire to use Cops which are disabled by Standard
20+
- [standard] presents a lightweight but sensible set of style rules to focus on coding
21+
- [standard] prevents you from using cops that it disables
22+
23+
Overall, the goal is to increase the quality and consistency of code while not getting distracted by disproportionally
24+
minor or trivial details. It's more important for an implementation team to agree to follow shared conventions than it
25+
is to enforce a specific configuration.
26+
27+
[standard]: https://github.com/testdouble/standard

0 commit comments

Comments
 (0)