-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path.rubocop.yml
300 lines (237 loc) · 7.87 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# TODO: Disallow any aliases, including Rails extensions.
# It's not good to have 42 different ways to make the same thing.
# https://github.com/rubocop/rubocop/issues/1065
require:
- rubocop-minitest
- rubocop-rails
- rubocop-rake
- rubocop-sorbet
AllCops:
NewCops: enable
# Bundler
# Using dependencies without specifying a version is like hanging a loaded gun
# on the wall. You never know when it will shoot or what it will hurt.
Bundler/GemVersion:
Enabled: true
EnforcedStyle: required
# Layout
# I don't think using pure border comments is a good idea for separating code
# into sections. I believe it's better to use a comment with the full name of
# the section. For example, instead of `#####` use `# Section Name`.
# I don't fully understand comments with margins either, but we might be able to
# use them for the license header.
Layout/EmptyComment:
Enabled: true
AllowBorderComment: false
AllowMarginComment: true
# This rule frequently goes against the conciseness of functions.
Layout/EmptyLineAfterGuardClause:
Enabled: false
# To prevent inconsistency and unnecessary merge conflicts, it's advisable to
# use only one newline character.
Layout/EndOfLine:
Enabled: true
EnforcedStyle: lf
# TODO: Wait for more smarter options.
# https://github.com/rubocop/rubocop/issues/9518
Layout/ExtraSpacing:
Enabled: true
Severity: warning
# For better consistency, it's recommended to wrap the first element in a
# multiline definition on a new line.
Layout/FirstArrayElementLineBreak:
Enabled: true
AllowMultilineFinalElement: false
Layout/FirstHashElementLineBreak:
Enabled: true
AllowMultilineFinalElement: false
Layout/FirstMethodArgumentLineBreak:
Enabled: true
AllowMultilineFinalElement: false
Layout/FirstMethodParameterLineBreak:
Enabled: true
AllowMultilineFinalElement: false
# Please try to respect the 80-character limit. It's fine if it goes up to 100
# characters, but if it's more than that, consider simplifying the logic.
Layout/LineLength:
Enabled: true
Max: 120
AllowedPatterns:
# For the inline link. A link that ends with a backslash.
- '\[[\S\s]*\]\([\S\s]*\) \\$'
Layout/MultilineArrayLineBreaks:
Enabled: true
AllowMultilineFinalElement: false
# It's better to move blocks with logic to a new line while assigning, without
# any exceptions.
Layout/MultilineAssignmentLayout:
Enabled: true
EnforcedStyle: new_line
SupportedTypes: []
Layout/MultilineHashKeyLineBreaks:
Enabled: true
AllowMultilineFinalElement: false
Layout/MultilineMethodArgumentLineBreaks:
Enabled: true
AllowMultilineFinalElement: false
Layout/MultilineMethodParameterLineBreaks:
Enabled: true
AllowMultilineFinalElement: false
# One-liners are often much harder to understand than multi-lines ones.
Layout/SingleLineBlockChain:
Enabled: true
# Lint
# This rule is enabled to prevent unexpected results from auto type conversion.
Lint/NumberConversion:
Enabled: true
# Metrics
# Metric rules can sometimes be more noisy than helpful. Of course, there're
# definitely some useful rules among them. However, I've a lot of faith in our
# talented developers.
Metrics:
Enabled: false
# Naming
# Sorbet doesn't support anonymous forwarding.
Naming/BlockForwarding:
Enabled: false
# Inclusion is a good thing.
Naming/InclusiveLanguage:
Enabled: true
# Style
# Writing a modifier as a group style forces methods to be grouped based on the
# modifier itself, rather than their meaning. Sometimes, a section may contain
# both public and private methods. Breaking the semantic order of methods just
# to satisfy the linter doesn't seem like a good idea.
Style/AccessModifierDeclarations:
Enabled: true
EnforcedStyle: inline
# Grouped accessors are indeed uncommon and may require more attention when
# working with them. Duplicating a declaration can be a better approach as it
# ensures that everything is written in the same style.
Style/AccessorGrouping:
Enabled: true
EnforcedStyle: separated
# Sorbet doesn't support anonymous forwarding.
Style/ArgumentsForwarding:
Enabled: false
# Difficult.
Style/ArrayCoercion:
Enabled: true
# It's more convenient to combine these two approaches.
Style/ClassAndModuleChildren:
Enabled: false
# Similar to the `Style/AccessModifierDeclarations`, it's more convenient to
# think of individual elements rather than blocks.
Style/ClassMethodsDefinitions:
Enabled: true
# To maintain consistency, it's recommended not to use aliases.
Style/CollectionMethods:
Enabled: true
# TODO: Wait for the support for a multiline header.
# https://github.com/rubocop/rubocop/issues/7189
# Style/Copyright
# A clearer separation of responsibilities is good.
Style/DateTime:
Enabled: true
# Documentation is wonderful, but it's not always necessary. It's not a good
# idea to write an inconsistent description just to avoid getting a warning from
# the linter.
Style/Documentation:
Enabled: false
# Sometimes an empty `else` isn't wrong, but it should be explicit.
Style/EmptyElse:
Enabled: true
EnforcedStyle: empty
AllowComments: true
# There's really no need to sacrifice overall consistency just to save three
# keystrokes.
Style/EndlessMethod:
Enabled: true
EnforcedStyle: disallow
# It's okay.
Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always
Exclude:
- "Gemfile"
# We must support Ruby 2.
Style/HashSyntax:
Enabled: true
EnforcedShorthandSyntax: never
# Sometimes even a short condition written in one line is difficult to read.
Style/IfUnlessModifier:
Enabled: false
# There is no difference between the lambda syntaxes, so I would prefer a more
# explicit way.
Style/Lambda:
Enabled: true
EnforcedStyle: lambda
# A very interesting and in its own way radical functionality. Just let all
# functions with parameters, without exception, need braces.
Style/MethodCallWithArgsParentheses:
Enabled: true
AllowedMethods:
# Think of it as a keyword like `if`, `for`, etc.
- raise
AllowedPatterns: []
# Calling a method on the do-end block isn't what I expect.
Style/MethodCalledOnDoEndBlock:
Enabled: true
# Having a default case is a good practice for a switch-case statement. It helps
# prevent missing any unprocessed values.
Style/MissingElse:
Enabled: true
EnforcedStyle: case
# Repeating comparisons aren't a problem at all. On the contrary, they're easier
# to understand than functional methods.
Style/MultipleComparison:
Enabled: false
# Having more explicit access to function parameters always makes the code
# easier to read.
Style/NumberedParameters:
Enabled: true
EnforcedStyle: disallow
# Using parentheses in multiline conditions is both convenient and intuitive.
Style/ParenthesesAroundCondition:
Enabled: true
AllowInMultilineConditions: true
# The behavior of the `&` symbol can be confusing. Sometimes we don't want to
# raise a system error.
Style/SafeNavigation:
Enabled: false
# A good rule that can be turned off in special cases.
Style/StringHashKeys:
Enabled: true
# There's no need to split strings into different types that support
# interpolation and those that don't. Just use double quotes all the time,
# they're easier to read and don't affect performance.
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
# The percentage syntax can be quite confusing and misleading every time.
Style/SymbolArray:
Enabled: true
EnforcedStyle: brackets
Style/WordArray:
Enabled: true
EnforcedStyle: brackets
# Minitest
Minitest:
Include:
- test/**/*.rb
Minitest/EmptyLineBeforeAssertionMethods:
Enabled: false
# Prefix, postfix, just use the same name as the module that should be tested.
# In any case, tests are separated from the source code.
Minitest/TestFileName:
Enabled: false
# Rails
Rails:
Include:
- app/**/*.rb
# This rule doesn't fit our needs because we're not exactly a typical Rails app.
Rails/ActionOrder:
Enabled: false
# Since we perform injections, we frequently utilize `html_safe`.
Rails/OutputSafety:
Enabled: false