-
Notifications
You must be signed in to change notification settings - Fork 1
/
.rubocop.yml
201 lines (157 loc) · 6.27 KB
/
.rubocop.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# frozen_string_literal: true
# Copyright 2021-2024 Roy Liu
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
AllCops:
NewCops: enable
Exclude:
# Read an auxiliary `.rubocop_ignore` file if it exists.
<% if (ignore_file = Pathname.new(".rubocop_ignore").expand_path(Dir.pwd)) && ignore_file.file? %>
<% if (lines = ignore_file.open("rb") { |f| f.read }.split("\n")) && lines.size > 0 %>
<% lines.each do |path| %>
- <%= path %>
<% end %>
<% else %>
[]
<% end %>
<% else %>
[]
<% end %>
# Align relative to the start of the block for consistency.
Layout/BlockAlignment:
EnforcedStyleAlignWith: start_of_block
# Align relative to the `end` statement for consistency and density.
Layout/CaseIndentation:
EnforcedStyle: end
# Prefer trailing dot operator positioning to hint the Ruby parser of impending tokens.
Layout/DotPosition:
EnforcedStyle: trailing
# Allow contiguous comment blocks that include magic comments at the very top of the file.
Layout/EmptyLineAfterMagicComment:
Enabled: false
# Align relative to the start of line for consistency.
Layout/EndAlignment:
EnforcedStyleAlignWith: start_of_line
# Prefer consistency and density over a better-looking heredoc.
Layout/HeredocIndentation:
Enabled: false
# Prefer indentation over alignment for consistency and density.
Layout/LineEndStringConcatenationIndentation:
EnforcedStyle: indented
# Modern screens have plenty of pixels, and 120 seems like a good adjustment.
Layout/LineLength:
Max: 120
# Prefer indentation over alignment for consistency and density.
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
# Prefer indentation over alignment for consistency and density.
Layout/MultilineOperationIndentation:
EnforcedStyle: indented
# Prefer a compact style with regards to braces.
Layout/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space
# Sometimes we want to name canonical blocks for clarity.
Naming/BlockForwarding:
Enabled: false
# Don't group accessors because simplicity supersedes brevity.
Style/AccessorGrouping:
Enabled: false
# Prefer `alias_method` because `alias` uses special syntax.
Style/Alias:
EnforcedStyle: prefer_alias_method
# Disallow the abominations that are `and` and `or`: https://andrewwegner.com/ruby-gotcha-operator-precedence.html.
Style/AndOr:
EnforcedStyle: always
# Prefer `map` over `select` because it sounds more mechanical.
Style/CollectionMethods:
PreferredMethods:
collect: map
# Allow `!!expression` syntax as an idiomatic way to coerce into a boolean.
Style/DoubleNegation:
Enabled: false
# Allow `else`s consisting of only `nil`.
Style/EmptyElse:
EnforcedStyle: empty
# Allow empty methods that look empty.
Style/EmptyMethod:
EnforcedStyle: expanded
# Don't replace `__FILE__` with `__dir__` with `File.expand_path` if developers are more comfortable with the former.
Style/ExpandPathArguments:
Enabled: false
# Guard clauses obscure control flow by hiding conditionals after basic blocks. This is suboptimal since conditionals
# and loops are the very constructs that make programs undecidable.
Style/GuardClause:
Enabled: false
# Don't convert `Hash[]` usage to `Array#to_h` if developers are more comfortable with the former.
Style/HashConversion:
Enabled: false
# Sometimes the conversion to `elsif-else` obfuscates the code.
Style/IfInsideElse:
Enabled: false
# Don't convert one-line `if` statements into modifiers which aren't readable and are probably antipatterns.
Style/IfUnlessModifier:
Enabled: false
# Don't enforce conversion of `select` to `reject` because consistency may supersede brevity.
Style/InverseMethods:
Enabled: false
# Prefer the `->` syntax for lambdas.
Style/Lambda:
EnforcedStyle: literal
# Don't convert negated `if`s to `unless` because simplicity supersedes brevity.
Style/NegatedIf:
Enabled: false
# Allow negated `if`/`else`s because the true and false conditions should be ordered based on their importance.
Style/NegatedIfElseCondition:
Enabled: false
# This autocorrects into a `next unless ...` guard clause, and we heavily discourage guard clauses.
Style/Next:
Enabled: false
# Don't convert `foo > 0` to `foo.positive?` because simplicity supersedes brevity.
Style/NumericPredicate:
Enabled: false
# Don't fold `begin`/`rescue`/`end` blocks into the method body because simplicity supersedes brevity.
Style/RedundantBegin:
Enabled: false
# Don't remove leading `::`s because they might be there to increase clarity.
Style/RedundantConstantBase:
Enabled: false
# Don't convert `//` to `%r{}` if developers are more comfortable with the former.
Style/RegexpLiteral:
Enabled: false
# Prefer `""` over `''`.
Style/StringLiterals:
EnforcedStyle: double_quotes
# Don't convert `""` to `''` in interpolated string literals because developers shouldn't be confused.
Style/StringLiteralsInInterpolation:
Enabled: false
# Don't convert an array of symbols to `%i[]` because simplicity supersedes brevity.
Style/SymbolArray:
EnforcedStyle: brackets
# Require commas at the end of multiline argument lists.
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: consistent_comma
# Require commas at the end of multiline array literals.
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma
# Require commas at the end of multiline hash literals.
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma
# Same reasoning as guard clauses: Don't obscure control flow by hiding the loop declaration after the statement.
Style/WhileUntilModifier:
Enabled: false
# Don't convert an array of symbols to `%w[]` because simplicity supersedes brevity.
Style/WordArray:
EnforcedStyle: brackets
# Don't convert `foo.size > 0` to `foo.empty?` because simplicity supersedes brevity.
Style/ZeroLengthPredicate:
Enabled: false