-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path.rubocop.yml
572 lines (431 loc) · 12.3 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
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
require:
- rubocop-capybara
- rubocop-performance
- rubocop-rails
- rubocop-rake
- rubocop-rspec
AllCops:
NewCops: enable
ActiveSupportExtensionsEnabled: true
Exclude:
- 'bin/**/*'
- 'cookbooks/**/*'
- 'data/**/*'
- 'db/schema.rb'
- 'node_modules/**/*'
- 'solr/**/*'
- 'tmp/**/*'
- 'vendor/**/*'
### Capybara.
# TODO: Enable.
Capybara/ClickLinkOrButtonStyle:
Enabled: false
Capybara/SpecificFinders:
Enabled: false
# FactoryBot.
# FactoryBot/CreateList:
RSpec/FactoryBot/CreateList:
EnforcedStyle: n_times
# FactoryBot/ConsistentParenthesesStyle:
RSpec/FactoryBot/ConsistentParenthesesStyle:
Enabled: false
### Layout.
Layout/ArgumentAlignment:
EnforcedStyle: with_fixed_indentation
Layout/ClassStructure:
Enabled: true
# Use trailing dot to make it easier to copy-paste into the console.
Layout/DotPosition:
EnforcedStyle: trailing
# Disabled because guard clauses w/o empty lines look OK in short methods.
Layout/EmptyLineAfterGuardClause:
Enabled: false
Layout/FirstArrayElementLineBreak:
Enabled: true
Layout/FirstHashElementLineBreak:
Enabled: true
Layout/FirstMethodArgumentLineBreak:
Enabled: true
Layout/FirstMethodParameterLineBreak:
Enabled: true
# Disabled because aligning keys/values improves readability of some hashes.
Layout/HashAlignment:
Enabled: false
EnforcedLastArgumentHashStyle: ignore_implicit
Layout/HeredocArgumentClosingParenthesis:
Enabled: true
Layout/IndentationConsistency:
EnforcedStyle: indented_internal_methods
Layout/LineEndStringConcatenationIndentation:
Exclude:
- 'spec/**/*'
Layout/LineLength:
Enabled: false
Max: 135
Exclude:
- 'app/controllers/quick_and_dirty_fixes_controller.rb'
- 'app/database_scripts/database_scripts/**/*'
Layout/MultilineHashKeyLineBreaks:
Enabled: true
# Disabled due to needless alignment and because multiline method calls are a lost cause anyways.
Layout/MultilineMethodCallIndentation:
Enabled: false
Layout/MultilineOperationIndentation:
EnforcedStyle: indented
# Disabled for files included in `rails app:update`.
Layout/SpaceInsideArrayLiteralBrackets:
Exclude:
- 'config/environments/production.rb'
- 'config/environments/staging.rb'
### Lint.
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*'
Lint/ConstantDefinitionInBlock:
Exclude:
- 'lib/tasks/**/*.rake'
# Disabled because duplicated branch bodies are most often co-incidental duplication and/or added for clarity.
Lint/DuplicateBranch:
Enabled: false
Lint/EmptyBlock:
Exclude:
- 'spec/factories/**/*' # For transient attributes.
Lint/HeredocMethodCallPosition:
Enabled: true
# TODO: Investigate.
Lint/LiteralAssignmentInCondition:
Enabled: false
Lint/MissingSuper:
Exclude:
- 'app/components/**/*'
Lint/RedundantCopDisableDirective:
Enabled: false
Lint/RequireRelativeSelfPath:
Exclude:
- 'lib/tasks/**/*.rake'
Lint/UselessAccessModifier:
MethodCreatingMethods:
- delegate
# Metrics.
Metrics/AbcSize:
Enabled: false
Exclude:
- 'app/database_scripts/database_scripts/**/*'
- 'db/migrate/**/*'
Metrics/BlockLength:
Max: 25
AllowedMethods:
- solr_search
Exclude:
- '.simplecov'
- 'app/database_scripts/database_scripts/**/*'
- 'config/environments/**/*'
- 'config/routes.rb'
- 'lib/tasks/**/*.rake'
- 'spec/**/*'
Metrics/ClassLength:
Enabled: false
Max: 100
CountAsOne: [array, hash, heredoc]
Exclude:
- 'app/cleanup/**/*'
- 'app/controllers/quick_and_dirty_fixes_controller.rb'
- 'app/database_scripts/**/*'
Metrics/CollectionLiteralLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Exclude:
- 'app/database_scripts/database_scripts/**/*'
Metrics/MethodLength:
Enabled: false
Max: 15
CountAsOne: [array, hash, heredoc]
Exclude:
- 'app/database_scripts/database_scripts/**/*'
- 'db/migrate/**/*'
- 'lib/tasks/**/*'
Metrics/ModuleLength:
Enabled: false
Max: 100
CountAsOne: [array, hash, heredoc]
Metrics/ParameterLists:
CountKeywordArgs: false
Metrics/PerceivedComplexity:
Enabled: false
Max: 12
### Naming.
# Disabled because anonymous block forwarding requires parentheses.
Naming/BlockForwarding:
Enabled: false
Naming/MemoizedInstanceVariableName:
EnforcedStyleForLeadingUnderscores: required
Naming/VariableNumber:
Exclude:
- 'lib/tasks/seed/relational_history_items.rb'
- 'spec/**/*'
### Performance.
# Disabled because `filter_map` and `map.compact` are not identical.
Performance/MapCompact:
Enabled: false
Performance/MapMethodChain:
Enabled: false
Performance/MethodObjectAsBlock:
Enabled: false
# Disabled because some comparisons are more readable when left/right hand sides look more similar.
Performance/Casecmp:
Enabled: false
### Rails.
Rails/ActionOrder:
ExpectedOrder:
- index
- show
- new
- create
- edit
- update
- destroy
# Disabled because it can be decided on a case-by-case basis if it's relevant.
Rails/BulkChangeTable:
Enabled: false
Rails/DefaultScope:
Enabled: true
# Disabled because delegations are in some cases less readable and/or harder to grep for.
Rails/Delegate:
Enabled: false
# Allow reads for dev ENV variables.
Rails/EnvironmentVariableAccess:
Enabled: true
AllowReads: true
Rails/FindEach:
Enabled: false
Rails/FreezeTime:
Enabled: false
Rails/HasManyOrHasOneDependent:
Enabled: false
# Disabled because the site is only available in English (and there are tons of hardcoded translations in views and elsewhere).
Rails/I18nLocaleTexts:
Enabled: false
# Disabled because we don't need to add `inverse_of` to all associations for the sake of it.
Rails/InverseOf:
Enabled: false
Rails/Output:
Exclude:
- 'lib/tasks/**/*'
# Disabled because there are too many cases ;)
Rails/OutputSafety:
Enabled: false
Exclude:
- 'app/database_scripts/database_scripts/**/*'
# Disabled because not all tasks require `:environment`.
Rails/RakeEnvironment:
Enabled: false
# Disabled because it does not consider string constants to be strings.
Rails/ReflectionClassName:
Enabled: false
# Disabled because it flags many false positives.
Rails/SaveBang:
Enabled: false
AllowedReceivers:
- 'ProgressBar'
- 'reference_form' # Actually `ReferenceForm`.
Rails/SkipsModelValidations:
Exclude:
- 'spec/**/*'
AllowedMethods:
- update_all
- update_column
- update_columns
Rails/UnknownEnv:
Environments:
- production
- development
- test
- staging
# Disabled because it's not safe (for example with handwritten SQL/joins).
Rails/WhereEquals:
Enabled: false
# Disabled because it makes queries less chainable which makes them harder to test/debug in the console.
Rails/WhereExists:
Enabled: false
# Disabled because it's not safe (for example with handwritten SQL/joins).
Rails/WhereNot:
Enabled: false
# Indexes are not case sensitive in MySQL. Revisit if we ever migrate to Postgres.
Rails/UniqueValidationWithoutIndex:
Enabled: false
# Disabled because `validates` is not available as an instance method (but for example `validates_inclusion_of` is).
Rails/Validation:
Enabled: false
### Rake.
# Disabled because not all Rake tasks should be included in `rake -T`.
Rake/Desc:
Enabled: false
### RSpec.
RSpec/BeEmpty:
Enabled: false
# Disabled because identity comparisons do not matter for `true/false/nil`.
RSpec/BeEq:
Enabled: false
RSpec/Capybara/FeatureMethods:
Exclude:
- 'spec/features/**/*'
# Disabled because it's useful for empty placeholders.
RSpec/EmptyExampleGroup:
Enabled: false
RSpec/ExampleLength:
Enabled: false
Max: 20
CountAsOne: [array, hash, heredoc]
RSpec/ExpectChange:
EnforcedStyle: block
RSpec/FilePath:
# TODO: See if we can remove this after https://github.com/rubocop/rubocop-rspec/pull/1266
CustomTransform:
AntCatVersionLink: antcat_version_link
ParseAntCatTags: parse_antcat_tags
# Disabled because grouped Shoulda Matchers makes sense sometimes.
RSpec/ImplicitSubject:
Enabled: false
EnforcedStyle: single_statement_only
RSpec/IndexedLet:
Enabled: false
# Disabled because `let!` makes it easier to separate the Arrange step from the Act/Assert steps.
RSpec/LetSetup:
Enabled: false
RSpec/MatchArray:
Enabled: false
# Disabled for now even if `have_received` is more correct because `expect ... to receive` is currently mostly used for
# a) call checking (in a lazy way but with less duplication), and b) the cases in the comment for RSpec/StubbedMock.
RSpec/MessageSpies:
Enabled: false
# Disabled because it misunderstands "one expectation per spec" (don't test unrelated behavior in one spec) as "one `expect`".
RSpec/MultipleExpectations:
Enabled: false
RSpec/MultipleMemoizedHelpers:
Max: 8
RSpec/NestedGroups:
Max: 6
RSpec/NoExpectationExample:
Exclude:
- 'spec/features/**/*'
RSpec/PendingWithoutReason:
Enabled: false
RSpec/SortMetadata:
Enabled: false
# Disabled for now because `expect` is currently misused to make some specs less complicated. And `allow`s (which are more correct)
# are more likely to be left unused by mistake when modifying specs (as opposed to `expect`s which would fail the spec).
RSpec/StubbedMock:
Enabled: false
### Style.
Style/Alias:
EnforcedStyle: prefer_alias_method
Style/ArrayCoercion:
Enabled: true
Style/AutoResourceCleanup:
Enabled: true
# Disabled because not everything that can be a case statement must be rewritten as a case statement.
Style/CaseLikeIf:
Enabled: false
Style/ClassCheck:
EnforcedStyle: is_a?
# Disabled because some comparisons are more readable when left/right hand sides look more similar.
Style/ClassEqualityComparison:
Enabled: false
Style/CollectionMethods:
Enabled: true
Style/CommentAnnotation:
Keywords:
- TODO
- FIXME
- OPTIMIZE
- PERFORMANCE
- HACK
- REVIEW
- NOTE
- TMPCLEANUP
Style/DateTime:
Enabled: true
# Disabled because we don't use that kind of documentation.
Style/Documentation:
Enabled: false
Style/EmptyMethod:
EnforcedStyle: expanded
Style/FetchEnvVar:
Enabled: false
Style/FrozenStringLiteralComment:
EnforcedStyle: always_true
# Disabled for files included in `rails app:update`.
Style/GlobalStdStream:
Exclude:
- 'config/environments/production.rb'
- 'config/environments/staging.rb'
# Disabled because it wants to split up independent/logical chunks of code.
Style/GuardClause:
Enabled: false
Style/HashSyntax:
Enabled: false
# Disabled to avoid trailing "surprise if"s.
Style/IfUnlessModifier:
Enabled: false
Style/Lambda:
Enabled: false
Style/MethodDefParentheses:
EnforcedStyle: require_no_parentheses_except_multiline
# Disabled because it's OK to chain blocks even of they span multiple lines.
Style/MultilineBlockChain:
Enabled: false
Style/MutableConstant:
Enabled: false
# Disabled because "Use underscores(_) as thousands separator and separate every 3 digits with them" makes IDs look weird.
Style/NumericLiterals:
Enabled: false
Exclude:
- 'app/database_scripts/database_scripts/**/*'
- 'spec/**/*'
# "This cop checks for redundant assignment before returning."
# Disabled because redundant assignment before returning are most often added on purpose (more explicit).
Style/RedundantAssignment:
Enabled: false
# Disabled to due to redundant begins blocks added on purpose for consistency.
Style/RedundantBegin:
Enabled: false
# Disabled for files included in `rails app:update`.
Style/RedundantConstantBase:
Exclude:
- 'config/environments/production.rb'
- 'config/environments/staging.rb'
# TODO: Investigate.
Style/RedundantDoubleSplatHashBraces:
Enabled: false
Style/RedundantParentheses:
Enabled: false
Style/RedundantRegexpArgument:
Enabled: false
Style/RedundantReturn:
Enabled: false
Style/ReturnNil:
Enabled: true
Style/Send:
Enabled: true
Style/SingleLineBlockParams:
Enabled: true
# Disabled because some conditions are not combined on purpose for readability.
Style/SoleNestedConditional:
Enabled: false
# Disabled because string interpolation is harder to read in some cases.
Style/StringConcatenation:
Enabled: false
Style/StringLiterals:
Enabled: false
Style/StringMethods:
Enabled: true
Style/SymbolArray:
Enabled: false
Style/TrailingCommaInBlockArgs:
Enabled: true
# Disabled because underscores are more explicit and easier to spot.
Style/TrailingUnderscoreVariable:
Enabled: false
Style/WordArray:
Enabled: false