-
Notifications
You must be signed in to change notification settings - Fork 0
/
.rubocop.yml
448 lines (356 loc) · 11.4 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
AllCops:
DisplayCopNames: true
DisplayStyleGuide: false
ExtraDetails: false
UseCache: false
Exclude:
- ./**/bin/**/*
- ./**/vendor/bundle/**/*
# Indent private/protected/public as deep as method definitions.
Style/AccessModifierIndentation:
EnforcedStyle: indent
# Align the key beginning and hash-rockets of multi-line hashes.
Style/AlignHash:
EnforcedHashRocketStyle: table
EnforcedColonStyle: table
EnforcedLastArgumentHashStyle: always_inspect
# Align multi-line method calls to next indented level.
Style/AlignParameters:
EnforcedStyle: with_fixed_indentation
# Ban `and` / `or` keywords everywhere.
Style/AndOr:
EnforcedStyle: always
# Enforce %() over %Q().
Style/BarePercentLiterals:
EnforcedStyle: bare_percent
# Enforce braces on single-line blocks and do..end around for multi-line blocks.
Style/BlockDelimiters:
EnforcedStyle: line_count_based
ProceduralMethods:
# Calls which use method return value instead of block return value.
- benchmark
- bm
- bmbm
- create
- each_with_object
- measure
- new
- realtime
- tap
- with_object
FunctionalMethods:
# Calls with return values which don't appear to be used.
- let
- let!
- subject
- watch
IgnoredMethods:
# Methods which cannot be categorised based on their usage alone.
- lambda
- proc
- it
# Require braces if second-to-last parameter is also a hash literal.
Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent
# Indent each `when` additional level inside case..end block.
Style/CaseIndentation:
IndentWhenRelativeTo: case
IndentOneStep: true
# Ban compact (e.g. `class Foo::Bar`) class/module definition style.
Style/ClassAndModuleChildren:
EnforcedStyle: nested
# Prefer `is_a?` over `kind_of?`.
Style/ClassCheck:
EnforcedStyle: is_a?
# TODO: https://github.com/bbatsov/rubocop/issues/1758
Style/ClosingParenthesisIndentation:
Enabled: true
# Align with the style guide (but `reduce` is dumb).
Style/CollectionMethods:
PreferredMethods:
collect: 'map'
collect!: 'map!'
inject: 'inject'
detect: 'find'
find_all: 'select'
# Use `..` for single-line, and %x on multi-line commands.
Style/CommandLiteral:
EnforcedStyle: mixed
AllowInnerBackticks: false
# Enforce formatting of special comments.
Style/CommentAnnotation:
Keywords:
- FIXME
- HACK
- NOTE
- OPTIMIZE
- REVIEW
- TODO
# General license is more than sufficient.
Style/Copyright:
Enabled: false
# Don't require top-level class documentation.
Style/Documentation:
Enabled: false
# Multi-line method chaining should be done with leading dots.
Style/DotPosition:
EnforcedStyle: leading
# An explicit true/false return value is not an unreasonable expectation.
Style/DoubleNegation:
Enabled: false
# Warn on empty else or else statements with nil.
Style/EmptyElse:
EnforcedStyle: both
# Require empty lines only between multi-line method definitions.
Style/EmptyLineBetweenDefs:
AllowAdjacentOneLineDefs: true
# No empty lines between block interior.
Style/EmptyLinesAroundBlockBody:
EnforcedStyle: no_empty_lines
# No empty lines between class interior.
Style/EmptyLinesAroundClassBody:
EnforcedStyle: no_empty_lines
# No empty lines between module interior.
Style/EmptyLinesAroundModuleBody:
EnforcedStyle: no_empty_lines
# Require `# coding: utf-8` at beginning of each ruby file.
Style/Encoding:
EnforcedStyle: always
# Loosens rules surrounding extra spacing intended for alignment.
Style/ExtraSpacing:
AllowForAlignment: true
Exclude:
- app/views/**/*
# Ignore executable ruby script files.
Style/FileName:
IgnoreExecutableScripts: true
# Indent first parameter for multi-line calls, require
# parentheses if any other arguments are also method calls.
Style/FirstParameterIndentation:
EnforcedStyle: special_for_inner_method_call_in_parentheses
# Prefer `each` over `for` loops.
Style/For:
EnforcedStyle: each
# Enforce `% foo` style for string formatting.
Style/FormatString:
EnforcedStyle: format
# Ban global variables except the standard built-ins.
Style/GlobalVars:
Enabled: true
# Prefer guard clauses for single-line `if` / `end` blocks.
Style/GuardClause:
MinBodyLength: 1
# Prefer key-value pairs over hash-rockets and ban mixed styles.
Style/HashSyntax:
EnforcedStyle: ruby19_no_mixed_keys
UseHashRocketsWithSymbolValues: false
# Annoying rule.
Style/IfUnlessModifier:
Enabled: false
# All method + modifier keywords should be indented the same.
Style/IndentationConsistency:
EnforcedStyle: normal
Style/IndentationWidth:
# Number of spaces for each indentation level.
Width: 2
# Indent multi-line hash key-value pairs the same, regardless of context.
Style/IndentHash:
EnforcedStyle: consistent
# Ban `lambda.(x, y)` syntactic sugar.
Style/LambdaCall:
EnforcedStyle: call
# Use `next` to skip iteration instead of conditional at end.
Style/Next:
EnforcedStyle: skip_modifier_ifs
# Allow various forms of `.nil?` checks, as `===` behavior CAN be important.
Style/NonNilCheck:
IncludeSemanticChanges: false
# Always equire parantheses around method argument definitions.
Style/MethodDefParentheses:
EnforcedStyle: require_parentheses
# Use snake_case for method definitions, since it's a nearly universal best
# practice to only use CamelCase in Ruby for certain constants.
Style/MethodName:
EnforcedStyle: snake_case
# Align with indentation instead of with operand.
Style/MultilineMethodCallIndentation:
EnforcedStyle: indented
# Enforce right-hand operand alignment of binary operations.
Style/MultilineOperationIndentation:
EnforcedStyle: indented
# Require `_` in between each 3-digit group beyond 4-digits in length.
Style/NumericLiterals:
MinDigits: 5
# Sometimes you need these, and they don't have identical behavior.
Style/OptionHash:
Enabled: false
# Too handy to enable.
Style/ParallelAssignment:
Enabled: false
# Allow safe assignment in conditions.
Style/ParenthesesAroundCondition:
AllowSafeAssignment: true
# `{}` for strings, `[]` for arrays, `()` for everything else.
Style/PercentLiteralDelimiters:
PreferredDelimiters:
'%': '{}'
'%i': '[]'
'%I': '[]'
'%q': '{}'
'%Q': '{}'
'%r': '()'
'%s': '()'
'%w': '[]'
'%W': '[]'
'%x': '()'
# Use `%Q` only when necessary.
Style/PercentQLiterals:
EnforcedStyle: lower_case_q
# Prefer `.foo?` over `.is_foo?`.
Style/PredicateName:
NamePrefixBlacklist:
- can_
- has_
- have_
- is_
- will_
NameWhitelist:
- is_a?
# Prefer `raise Exception, msg` over `raise Exception.new(msg)`.
Style/RaiseArgs:
EnforcedStyle: exploded
# Prefer `return [x, y]` over `return x, y`.
Style/RedundantReturn:
AllowMultipleReturnValues: false
# Prefer `/../` for regular expressions (and disallow inner slashes in `/../`).
Style/RegexpLiteral:
EnforcedStyle: slashes
AllowInnerSlashes: false
# Disallow multiple expressions on the same line.
Style/Semicolon:
AllowAsExpressionSeparator: false
# This is garbage, considering there's a lack of prominent Ruby literature that
# effectively justifies the contrived nature of this semantic preference.
Style/SignalException:
Enabled: false
# Variable names should always be expressive, and not be dictated simply because
# common method calls more prominently feature short-hand in the Ruby universe.
Style/SingleLineBlockParams:
Enabled: false
# Disallow all single-line methods.
Style/SingleLineMethods:
AllowIfMethodIsEmpty: false
# Require easy-to-read spacing.
Style/SpaceBeforeFirstArg:
AllowForAlignment: true
# Require parentheses around short-hand lambda arguments.
Style/StabbyLambdaParentheses:
EnforcedStyle: require_parentheses
# Prefer single-quotes when possible.
Style/StringLiterals:
EnforcedStyle: single_quotes
# Prefer single-quotes when possible.
Style/StringLiteralsInInterpolation:
EnforcedStyle: single_quotes
# No space between `|` and parameters in block definition.
Style/SpaceAroundBlockParameters:
EnforcedStyleInsidePipes: no_space
# Require spaces around `=` sign when defining parameter defaults.
Style/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: space
# This just makes alignment a nightmare for conditional waterfall operations.
Style/SpaceAroundOperators:
Enabled: false
# Require space between method call and block definition braces.
Style/SpaceBeforeBlockBraces:
EnforcedStyle: space
# Require spaces inside block definition braces
Style/SpaceInsideBlockBraces:
EnforcedStyle: space
EnforcedStyleForEmptyBraces: space
SpaceBeforeBlockParameters: true
# Require spaces inside hash definition braces, except for empty hashes.
Style/SpaceInsideHashLiteralBraces:
EnforcedStyle: space
EnforcedStyleForEmptyBraces: no_space
# Ban spaces inside string interpolation braces.
Style/SpaceInsideStringInterpolation:
EnforcedStyle: no_space
# Prefer `.map(&:to_s)` over `.map { |i| i.to_s }`.
Style/SymbolProc:
Enabled: true
# Require final newline at end of each Ruby file.
Style/TrailingBlankLines:
EnforcedStyle: final_newline
# The precedent of including a trailing comma in lists is only for convenience
# of reading file diffs and shouldn't dictate the general style of any language.
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: no_comma
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: no_comma
# Warn when defining methods which could use built-in `attr_*` declarations.
Style/TrivialAccessors:
AllowDSLWriters: true
AllowPredicates: false
ExactNameMatch: true
# See Style/MethodName for more information.
Style/VariableName:
EnforcedStyle: snake_case
# Warns when `while` loops could be single-line `while` / `until` loops.
Style/WhileUntilModifier:
MaxLineLength: 80
# Prefer `%w[]` for array literals of word-like strings.
Style/WordArray:
Enabled: true
##################### Metrics ##################################
# Enforces a reasonable maximum Assignment/Branch/Condition magnitude
# that will allow for organic development and timely warnings.
Metrics/AbcSize:
Max: 16
# Warn when block nesting exceeds 3 levels.
Metrics/BlockNesting:
Max: 3
# These values are rather contrived and have been reasonably adjusted to
# reflect the broader application of length metrics in the real world.
Metrics/ClassLength:
CountComments: false
Max: 120
# See Metrics/ClassLength for more information.
Metrics/ModuleLength:
CountComments: false
Max: 120
# Enforce a maximum CyclomaticComplexity magnitude.
Metrics/CyclomaticComplexity:
Max: 7
# The archaic practice of 80-character line lengths is hilariously insufficient.
Metrics/LineLength:
Max: 100
AllowURI: true
# See Metrics/ClassLength for more information.
Metrics/MethodLength:
CountComments: false
Max: 15
# Use keyword arguments if parameter list length exceeds 5 declarations.
Metrics/ParameterLists:
CountKeywordArgs: false
Max: 5
# Sets maximum score for the ease of reading a method.
Metrics/PerceivedComplexity:
Max: 7
##################### Lint ##################################
# Allow safe assignment in conditions.
Lint/AssignmentInCondition:
AllowSafeAssignment: true
# Align `end` with `keyword`.
Lint/EndAlignment:
AlignWith: keyword
# Align with current level of modifier keyword indentation.
Lint/DefEndAlignment:
AlignWith: start_of_line
# Checks for unused block arguments.
Lint/UnusedBlockArgument:
IgnoreEmptyBlocks: true
# Checks for unused method arguments.
Lint/UnusedMethodArgument:
AllowUnusedKeywordArguments: false
IgnoreEmptyMethods: true