/
.rubocop.yml
491 lines (416 loc) 路 10.9 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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
---
require:
- ./Homebrew/rubocops.rb
- rubocop-performance
- rubocop-rails
- rubocop-rspec
- rubocop-sorbet
inherit_mode:
merge:
- Include
- Exclude
- AllowedMethods
AllCops:
TargetRubyVersion: 2.6
DisplayCopNames: false
ActiveSupportExtensionsEnabled: true
NewCops: enable
Include:
- "**/*.rbi"
Exclude:
- "Homebrew/sorbet/rbi/gems/**/*.rbi"
- "Homebrew/sorbet/rbi/hidden-definitions/*.rbi"
- "Homebrew/sorbet/rbi/todo.rbi"
- "Homebrew/bin/*"
- "Homebrew/vendor/**/*"
- "Taps/*/*/vendor/**/*"
Cask/Desc:
Description: "Ensure that the desc stanza conforms to various content and style checks."
Enabled: true
Cask/HomepageUrlTrailingSlash:
Description: "Ensure that the homepage url has a slash after the domain name."
Enabled: true
Cask/NoDslVersion:
Description: "Do not use the deprecated DSL version syntax in your cask header."
Enabled: true
Cask/StanzaGrouping:
Description: "Ensure that cask stanzas are grouped correctly. More info at https://docs.brew.sh/Cask-Cookbook#stanza-order"
Enabled: true
Cask/StanzaOrder:
Description: "Ensure that cask stanzas are sorted correctly. More info at https://docs.brew.sh/Cask-Cookbook#stanza-order"
Enabled: true
FormulaAudit:
Enabled: true
FormulaAuditStrict:
Enabled: true
Homebrew:
Enabled: true
# only used internally
Homebrew/MoveToExtendOS:
Enabled: false
# `system` is a special case and aligns on second argument, so allow this for formulae.
Layout/ArgumentAlignment:
Exclude:
- "Taps/**/*.rb"
- "/**/Formula/**/*.rb"
- "**/Formula/**/*.rb"
# this is a bit less "floaty"
Layout/CaseIndentation:
EnforcedStyle: end
# significantly less indentation involved; more consistent
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent
# this is a bit less "floaty"
Layout/EndAlignment:
EnforcedStyleAlignWith: start_of_line
# make our hashes consistent
Layout/HashAlignment:
EnforcedHashRocketStyle: table
EnforcedColonStyle: table
# Need to allow #: for external commands.
Layout/LeadingCommentSpace:
Exclude:
- "Taps/*/*/cmd/*.rb"
# GitHub diff UI wraps beyond 118 characters
Layout/LineLength:
Max: 118
# ignore manpage comments and long single-line strings
AllowedPatterns:
[
"#: ",
' url "',
' mirror "',
" plist_options ",
' appcast "',
' executable: "',
' font "',
' homepage "',
' name "',
' pkg "',
' pkgutil: "',
" sha256 cellar: ",
" sha256 ",
"#{language}",
"#{version.",
' "/Library/Application Support/',
'"/Library/Caches/',
'"/Library/PreferencePanes/',
' "~/Library/Application Support/',
'"~/Library/Caches/',
'"~/Application Support',
" was verified as official when first introduced to the cask",
]
# conflicts with DSL-style path concatenation with `/`
Layout/SpaceAroundOperators:
Enabled: false
# makes DSL usage ugly.
Layout/SpaceBeforeBrackets:
Exclude:
- "**/*_spec.rb"
- "Taps/**/*.rb"
- "/**/{Formula,Casks}/**/*.rb"
- "**/{Formula,Casks}/**/*.rb"
# favour parens-less DSL-style arguments
Lint/AmbiguousBlockAssociation:
Enabled: false
Lint/DuplicateBranch:
Exclude:
- "Taps/**/*.rb"
- "/**/{Formula,Casks}/**/*.rb"
- "**/{Formula,Casks}/**/*.rb"
# so many of these in formulae and can't be autocorrected
Lint/ParenthesesAsGroupedExpression:
Exclude:
- "Taps/**/*.rb"
- "/**/Formula/**/*.rb"
- "**/Formula/**/*.rb"
# unused keyword arguments improve APIs
Lint/UnusedMethodArgument:
AllowUnusedKeywordArguments: true
# These metrics didn't end up helping.
Metrics:
Enabled: false
# Allow dashes in filenames.
Naming/FileName:
Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/
# Implicitly allow EOS as we use it everywhere.
Naming/HeredocDelimiterNaming:
ForbiddenDelimiters:
- END, EOD, EOF
Naming/InclusiveLanguage:
CheckStrings: true
FlaggedTerms:
# TODO: If possible, make this stricter.
slave:
AllowedRegex:
- "gitslave" # Used in formula `gitslave`
- "log_slave" # Used in formula `ssdb`
- "ssdb_slave" # Used in formula `ssdb`
- "var_slave" # Used in formula `ssdb`
- "patches/13_fix_scope_for_show_slave_status_data.patch" # Used in formula `mytop`
Naming/MethodName:
AllowedPatterns:
- '\A(fetch_)?HEAD\?\Z'
# allow those that are standard
# TODO: try to remove some of these
Naming/MethodParameterName:
inherit_mode:
merge:
- AllowedNames
AllowedNames:
[
"a",
"b",
"cc",
"c1",
"c2",
"d",
"e",
"f",
"ff",
"fn",
"id",
"o",
"p",
"pr",
"r",
"rb",
"s",
"v",
]
# Both styles are used depending on context,
# e.g. `sha256` and `something_countable_1`.
Naming/VariableNumber:
Enabled: false
# Does not hinder readability, so might as well enable it.
Performance/CaseWhenSplat:
Enabled: true
# Makes code less readable for minor performance increases.
Performance/Caller:
Enabled: false
# Makes code less readable for minor performance increases.
Performance/MethodObjectAsBlock:
Enabled: false
Rails:
# Selectively enable what we want.
Enabled: false
# Do not use ActiveSupport in RuboCops.
Exclude:
- "Homebrew/rubocops/**/*"
# These relate to ActiveSupport and not other parts of Rails.
Rails/ActiveSupportAliases:
Enabled: true
Rails/Blank:
Enabled: true
Rails/CompactBlank:
Enabled: true
Rails/Delegate:
Enabled: false # TODO
Rails/DelegateAllowBlank:
Enabled: true
Rails/DurationArithmetic:
Enabled: true
Rails/ExpandedDateRange:
Enabled: true
Rails/Inquiry:
Enabled: true
Rails/NegateInclude:
Enabled: true
Rails/PluralizationGrammar:
Enabled: true
Rails/Presence:
Enabled: true
Rails/Present:
Enabled: true
Rails/RelativeDateConstant:
Enabled: true
Rails/SafeNavigation:
Enabled: true
Rails/SafeNavigationWithBlank:
Enabled: true
Rails/StripHeredoc:
Enabled: true
Rails/ToFormattedS:
Enabled: true
# Intentionally disabled as it doesn't fit with our code style.
RSpec/AnyInstance:
Enabled: false
RSpec/FilePath:
Enabled: false
RSpec/SubjectStub:
Enabled: false
# TODO: try to enable these
RSpec/DescribeClass:
Enabled: false
RSpec/MessageSpies:
Enabled: false
RSpec/StubbedMock:
Enabled: false
# TODO: try to reduce these
RSpec/ExampleLength:
Max: 75
RSpec/MultipleExpectations:
Max: 26
RSpec/NestedGroups:
Max: 5
RSpec/MultipleMemoizedHelpers:
Max: 12
# Annoying to have these autoremoved.
RSpec/Focus:
AutoCorrect: false
# Try getting rid of these.
Sorbet/ConstantsFromStrings:
Enabled: false
Sorbet/FalseSigil:
Exclude:
- "Taps/**/*"
- "/**/{Formula,Casks}/**/*.rb"
- "**/{Formula,Casks}/**/*.rb"
- "Homebrew/test/**/Casks/**/*.rb"
Sorbet/StrictSigil:
inherit_mode:
override:
- Include
Enabled: true
Include:
- "**/*.rbi"
# Conflicts with type signatures on `attr_*`s.
Style/AccessorGrouping:
Enabled: false
# Require &&/|| instead of and/or
Style/AndOr:
EnforcedStyle: always
# Avoid leaking resources.
Style/AutoResourceCleanup:
Enabled: true
# This makes these a little more obvious.
Style/BarePercentLiterals:
EnforcedStyle: percent_q
# make rspec formatting more flexible
Style/BlockDelimiters:
Exclude:
- "Homebrew/**/*_spec.rb"
- "Homebrew/**/shared_examples/**/*.rb"
# TODO: remove this when possible.
Style/ClassVars:
Exclude:
- "**/developer/bin/*"
# Use consistent style for better readability.
Style/CollectionMethods:
Enabled: true
# Don't allow cops to be disabled in casks and formulae.
Style/DisableCopsWithinSourceCodeDirective:
Enabled: true
Include:
- "/**/{Formula,Casks}/**/*.rb"
- "**/{Formula,Casks}/**/*.rb"
# Don't enforce documentation in casks or formulae.
Style/Documentation:
Exclude:
- "Taps/**/*"
- "/**/{Formula,Casks}/**/*.rb"
- "**/{Formula,Casks}/**/*.rb"
- "**/*.rbi"
Style/DocumentationMethod:
Include:
- "Homebrew/formula.rb"
# This is quite a large change, so don't enforce this yet for formulae.
# We should consider doing so in the future, but be aware of the impact on third-party taps.
Style/FetchEnvVar:
Exclude:
- "Taps/**/*.rb"
- "/**/Formula/**/*.rb"
- "**/Formula/**/*.rb"
# Prefer tokens with type annotations for consistency
# between formatting numbers and strings.
Style/FormatStringToken:
EnforcedStyle: annotated
# Not used for casks and formulae.
Style/FrozenStringLiteralComment:
EnforcedStyle: always
Exclude:
- "Taps/**/*.rb"
- "/**/{Formula,Casks}/**/*.rb"
- "**/{Formula,Casks}/**/*.rb"
- "Homebrew/test/**/Casks/**/*.rb"
- "**/*.rbi"
- "**/Brewfile"
# TODO: remove this when possible.
Style/GlobalVars:
Exclude:
- "**/developer/bin/*"
# potential for errors in formulae too high with this
Style/GuardClause:
Exclude:
- "Taps/**/*.rb"
- "/**/{Formula,Casks}/**/*.rb"
- "**/{Formula,Casks}/**/*.rb"
# Allow for license expressions
Style/HashAsLastArrayItem:
Exclude:
- "Taps/**/*.rb"
- "/**/Formula/**/*.rb"
- "**/Formula/**/*.rb"
# Zero-prefixed octal literals are widely used and understood.
Style/NumericLiteralPrefix:
EnforcedOctalStyle: zero_only
# Only use this for numbers >= `1_000_000`.
Style/NumericLiterals:
MinDigits: 7
Strict: true
Exclude:
- "**/Brewfile"
# OpenStruct is a nice helper.
Style/OpenStructUse:
Enabled: false
# Rescuing `StandardError` is an understood default.
Style/RescueStandardError:
EnforcedStyle: implicit
# Returning `nil` is unnecessary.
Style/ReturnNil:
Enabled: true
# We have no use for using `warn` because we
# are calling Ruby with warnings disabled.
Style/StderrPuts:
Enabled: false
# so many of these in formulae and can't be autocorrected
Style/StringConcatenation:
Exclude:
- "Taps/**/*.rb"
- "/**/{Formula,Casks}/**/*.rb"
- "**/{Formula,Casks}/**/*.rb"
# ruby style guide favorite
Style/StringLiterals:
EnforcedStyle: double_quotes
# consistency with above
Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
# Use consistent method names.
Style/StringMethods:
Enabled: true
# An array of symbols is more readable than a symbol array
# and also allows for easier grepping.
Style/SymbolArray:
EnforcedStyle: brackets
# make things a bit easier to read
Style/TernaryParentheses:
EnforcedStyle: require_parentheses_when_complex
# Trailing commas make diffs nicer.
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma
# `unless ... ||` and `unless ... &&` are hard to mentally parse
Style/UnlessLogicalOperators:
Enabled: true
EnforcedStyle: forbid_logical_operators
# a bit confusing to non-Rubyists but useful for longer arrays
Style/WordArray:
MinSize: 4
# would rather freeze too much than too little
Style/MutableConstant:
EnforcedStyle: strict