-
Notifications
You must be signed in to change notification settings - Fork 0
/
.rubocop.yml
500 lines (392 loc) · 12.2 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
492
493
494
495
496
497
498
499
500
# All options: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
require:
- rubocop-rspec
- rubocop-thread_safety
AllCops:
Exclude:
- "vendor/**/*"
- "db/schema.rb"
- "db/droms_schema.rb"
- "lib/**/*.rake"
- "bin/*"
- "node_modules/**/*"
UseCache: false
TargetRubyVersion: 2.7.2
# Style Cops
Style/GlobalVars:
AllowedVariables:
- $pubnub
Style/MultilineBlockChain:
Enabled: false
Style/NumericPredicate:
Enabled: false
Style/Copyright:
Enabled: false
Style/WordArray:
Enabled: false
Style/CollectionMethods:
Description: Preferred collection methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
Enabled: true
PreferredMethods:
collect: map
collect!: map!
find: detect
find_all: select
reduce: inject
Style/GuardClause:
Description: Check for conditionals that can be replaced with guard clauses
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
Enabled: true
MinBodyLength: 5
Style/IfUnlessModifier:
Description: Favor modifier if/unless usage when you have a single-line body.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
Enabled: true
Style/OptionHash:
Description: Don't use option hashes when you can use keyword arguments.
Enabled: false
Style/PercentLiteralDelimiters:
Description: Use `%`-literal delimiters consistently
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
Enabled: false
PreferredDelimiters:
"%": "()"
"%i": "()"
"%q": "()"
"%Q": "()"
"%r": "{}"
"%s": "()"
"%w": "()"
"%W": "()"
"%x": "()"
Style/RaiseArgs:
Description: Checks the arguments passed to raise/fail.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
Enabled: false
EnforcedStyle: exploded
SupportedStyles:
- compact
- exploded
Style/SignalException:
Description: Checks for proper usage of fail and raise.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
Enabled: false
EnforcedStyle: semantic
SupportedStyles:
- only_raise
- only_fail
- semantic
Style/SingleLineBlockParams:
Description: Enforces the names of some block params.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
Enabled: false
Methods:
- reduce:
- a
- e
- inject:
- a
- e
Style/SingleLineMethods:
Description: Avoid single-line methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
Enabled: true
AllowIfMethodIsEmpty: true
Style/StringLiterals:
Description: Checks if uses of quotes match the configured preference.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
Enabled: true
EnforcedStyle: single_quotes
SupportedStyles:
- single_quotes
- double_quotes
Exclude:
- 'db/migrate/*'
Style/StringLiteralsInInterpolation:
Description: Checks if uses of quotes inside expressions in interpolated strings
match the configured preference.
Enabled: true
EnforcedStyle: single_quotes
SupportedStyles:
- single_quotes
- double_quotes
Style/TrailingCommaInArguments:
Description: Checks for trailing comma in argument lists.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
Enabled: true
EnforcedStyleForMultiline: no_comma
Style/InlineComment:
Description: Avoid inline comments.
Enabled: false
Style/Alias:
Description: Use alias_method instead of alias.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
Enabled: true
EnforcedStyle: prefer_alias_method
Style/Documentation:
Description: Document classes and non-namespace modules.
Enabled: false
Style/DoubleNegation:
Description: Checks for uses of double negation (!!).
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
Enabled: true
Style/EachWithObject:
Description: Prefer `each_with_object` over `inject` or `reduce`.
Enabled: false
Style/EmptyLiteral:
Description: Prefer literals to Array.new/Hash.new/String.new.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
Enabled: true
Style/Encoding:
Enabled: false
Style/ModuleFunction:
Description: Checks for usage of `extend self` in modules.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
Enabled: true
Style/OneLineConditional:
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
Enabled: true
Style/PerlBackrefs:
Description: Avoid Perl-style regex back references.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
Enabled: false
Style/Send:
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
may overlap with existing methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
Enabled: false
Style/SpecialGlobalVars:
Description: Avoid Perl-style global variables.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
Enabled: false
Style/VariableInterpolation:
Description: Don't interpolate global, instance and class variables directly in
strings.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
Enabled: true
Style/WhenThen:
Description: Use when x then ... for one-line cases.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
Enabled: true
Style/SafeNavigation:
Enabled: false
Style/AsciiComments:
Description: 'Use only ascii symbols in comments.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
Enabled: false
Style/NumericLiterals:
Enabled: false
Style/ClassAndModuleChildren:
Description: Checks style of children classes and modules.
Enabled: false
EnforcedStyle: compact
SupportedStyles:
- nested
- compact
Style/FrozenStringLiteralComment:
Enabled: false
Style/SymbolArray:
Enabled: false
Style/RegexpLiteral:
Enabled: false
Style/BlockDelimiters:
Exclude:
- '**/*_spec.rb'
- 'spec/**/*.rb'
Style/ExponentialNotation:
Enabled: false
Style/HashEachMethods:
Enabled: true
Style/HashTransformKeys:
Enabled: false
Style/HashTransformValues:
Enabled: false
Style/ArgumentsForwarding:
Description: Identifies places where do_something(*args, &block) can be replaced by do_something(…).
Enabled: true
Style/CollectionCompact:
Description: Checks for places where custom logic on rejection nils from arrays and hashes can be replaced with {Array,Hash}#{compact,compact!}.
Enabled: true
Style/DocumentDynamicEvalDefinition:
Description: When using class_eval (or other eval) with string interpolation, add a comment block showing its appearance if interpolated (a practice used in Rails code).
Enabled: true
Style/NegatedIfElseCondition:
Description: Checks for uses of if-else and ternary operators with a negated condition which can be simplified by inverting condition and swapping branches.
Enabled: true
Style/NilLambda:
Description: Checks for lambdas that always return nil, which can be replaced with an empty lambda instead.
Enabled: true
Style/SwapValues:
Description: Enforces the use of shorthand-style swapping of 2 variables.
Enabled: true
# Layout Cops
Layout/LineLength:
Max: 220
# To make it possible to copy or click on URIs in the code, we allow lines
# containing a URI to be longer than Max.
AllowHeredoc: true
AllowURI: true
URISchemes:
- http
- https
Exclude:
- '**/*_spec.rb'
- 'spec/**/*.rb'
Layout/EndOfLine:
EnforcedStyle: lf
Layout/ExtraSpacing:
Description: Checks for extra/unnecessary whitespace.
Enabled: true
Layout/SpaceInsideHashLiteralBraces:
Description: Checks for whitespace inside Hash literal braces.
Enabled: false
Layout/DotPosition:
Description: Checks the position of the dot in multi-line method calls.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
Enabled: true
EnforcedStyle: leading
SupportedStyles:
- leading
- trailing
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent
Layout/EmptyLinesAroundBeginBody:
Enabled: false
Layout/EmptyLinesAroundAccessModifier:
Enabled: false
Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented
Layout/IndentationWidth:
Enabled: true
Layout/FirstParameterIndentation:
Enabled: true
EnforcedStyle: consistent
Layout/ClosingParenthesisIndentation:
Enabled: false
Layout/EmptyLinesAroundClassBody:
Enabled: false
Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent
Layout/CaseIndentation:
EnforcedStyle: end
Layout/EndAlignment:
EnforcedStyleAlignWith: variable
Layout/SpaceAroundMethodCallOperator:
Enabled: true
Layout/SpaceInLambdaLiteral:
Enabled: false
# Lint Cops
Lint/RequireParentheses:
Description: Use parentheses in the method call to avoid confusion about precedence.
Enabled: false
Lint/IneffectiveAccessModifier:
Enabled: false
Lint/AssignmentInCondition:
Description: Don't use assignment in conditions.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
Enabled: true
AllowSafeAssignment: true
Lint/EachWithObjectArgument:
Description: Check for immutable argument given to each_with_object.
Enabled: true
Lint/SuppressedException:
Description: Don't suppress exception.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
Enabled: false
Lint/LiteralAsCondition:
Description: Checks of literals used in conditions.
Enabled: false
Lint/LiteralInInterpolation:
Description: Checks for literals used in interpolation.
Enabled: false
Lint/DuplicateBranch:
Description: Checks that there are no repeated bodies within if/unless, case-when and rescue constructs.
Enabled: true
Lint/DuplicateRegexpCharacterClassElement:
Description: Checks for duplicate elements in Regexp character classes.
Enabled: true
Lint/EmptyBlock:
Description: Checks for blocks without a body.
Enabled: true
Lint/EmptyClass:
Description: Checks for classes and metaclasses without a body.
Enabled: true
Lint/NoReturnInBeginEndBlocks:
Description: Checks for the presence of a return inside a begin..end block in assignment contexts.
Enabled: true
Lint/ToEnumArguments:
Description: Ensures that to_enum/enum_for, called for the current method, has correct arguments.
Enabled: true
Lint/UnmodifiedReduceAccumulator:
Description: Looks for reduce or inject blocks where the value returned (implicitly or explicitly) does not include the accumulator.
Enabled: true
# This cop breaks rspec "expect {}.to change {}" matcher
Lint/AmbiguousBlockAssociation:
Exclude:
- '**/*_spec.rb'
- 'spec/**/*.rb'
Lint/RaiseException:
Enabled: true
Lint/StructNewOverride:
Enabled: true
# Metric Cops
Metrics/AbcSize:
Enabled: false
Metrics/BlockNesting:
Max: 3
Metrics/ClassLength:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Metrics/BlockLength:
Exclude:
- 'config/routes.rb'
- 'config/environments/*.rb'
- 'db/seeds.rb'
- '**/*_spec.rb'
- 'spec/**/*.rb'
# Avoid complex methods.
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ParameterLists:
Description: Avoid parameter lists longer than three or four parameters.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
Enabled: true
Max: 5
CountKeywordArgs: true
Metrics/PerceivedComplexity:
Enabled: false
# Naming Cops
Naming/FileName:
Description: Use snake_case for source file names.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
Enabled: false
Naming/AccessorMethodName:
Description: Check the naming of accessor methods for get_/set_.
Enabled: false
# Bundler Cops
Bundler/OrderedGems:
Enabled: false
# RSpec Cops
RSpec/NestedGroups:
Max: 6
RSpec/ExampleLength:
Description: Checks for long examples.
Enabled: true
Max: 10
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength
RSpec/ContextWording:
Prefixes:
- when
- with
- without
- if
- unless
- for
- as
RSpec/MultipleMemoizedHelpers:
Max: 18