forked from forem/forem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.rubocop.yml
958 lines (767 loc) · 30 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
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
# TODO: [@thepracticaldev/oss] test cops that are commented out
inherit_from: .rubocop_todo.yml
require:
- rubocop-performance
- rubocop-rails
- rubocop-rspec
AllCops:
Exclude:
- bin/**/*
- db/schema.rb
- db/migrate/*.rb
- node_modules/**/*
- tmp/**/*
- vendor/**/*
DisplayStyleGuide: true
ExtraDetails: true
NewCops: enable # opt-in to new cops by default
TargetRubyVersion: 3.0
#################### Bundler ###########################
Bundler/GemVersion:
Description: 'Requires or forbids specifying gem versions.'
Enabled: true
EnforcedStyle: 'required'
AllowedGems: ['acts_as_follower']
Bundler/OrderedGems:
Description: >-
Gems within groups in the Gemfile should be alphabetically sorted.
Enabled: true
ConsiderPunctuation: true
#################### Layout ###########################
Gemspec/DateAssignment:
Description: 'Checks that `date =` is not used in gemspec file, it is set automatically when the gem is packaged.'
Enabled: true
#################### Layout ###########################
Lint/AmbiguousAssignment:
Description: 'Checks for mistyped shorthand assignments.'
Enabled: true
Layout/ClassStructure:
Description: 'Enforces a configured order of definitions within a class body.'
StyleGuide: '#consistent-classes'
Enabled: true
Layout/DotPosition:
Description: 'Checks the position of the dot in multi-line method calls.'
StyleGuide: '#consistent-multi-line-chains'
EnforcedStyle: leading
Lint/EmptyInPattern:
Description: 'Checks for the presence of `in` pattern branches without a body.'
Enabled: true
Layout/EmptyLinesAroundAttributeAccessor:
Description: "Keep blank lines around attribute accessors."
StyleGuide: '#empty-lines-around-attribute-accessor'
Enabled: true
# Layout/FirstArrayElementLineBreak:
# Description: >-
# Checks for a line break before the first element in a
# multi-line array.
# Enabled: false
# Layout/FirstHashElementLineBreak:
# Description: >-
# Checks for a line break before the first element in a
# multi-line hash.
# Enabled: false
# Layout/FirstMethodArgumentLineBreak:
# Description: >-
# Checks for a line break before the first argument in a
# multi-line method call.
# Enabled: false
# Layout/FirstMethodParameterLineBreak:
# Description: >-
# Checks for a line break before the first parameter in a
# multi-line method parameter definition.
# Enabled: false
# Layout/HeredocArgumentClosingParenthesis:
# Description: >-
# Checks for the placement of the closing parenthesis in a
# method call that passes a HEREDOC string as an argument.
# Enabled: false
# StyleGuide: '#heredoc-argument-closing-parentheses'
Layout/LineLength:
Description: 'Checks that line length does not exceed the configured limit.'
AutoCorrect: true # this is false by default
Exclude:
- Gemfile
- app/lib/constants/site_config.rb
# Layout/MultilineArrayLineBreaks:
# Description: >-
# Checks that each item in a multi-line array literal
# starts on a separate line.
# Enabled: false
# Layout/MultilineAssignmentLayout:
# Description: 'Check for a newline after the assignment operator in multi-line assignments.'
# StyleGuide: '#indent-conditional-assignment'
# Enabled: false
# Layout/MultilineHashKeyLineBreaks:
# Description: >-
# Checks that each item in a multi-line hash literal
# starts on a separate line.
# Enabled: false
# Layout/MultilineMethodArgumentLineBreaks:
# Description: >-
# Checks that each argument in a multi-line method call
# starts on a separate line.
# Enabled: false
Layout/MultilineOperationIndentation:
Description: >-
Checks indentation of binary operations that span more than
one line.
Enabled: true
EnforcedStyle: indented
Layout/MultilineMethodCallIndentation:
Description: >-
Checks indentation of method calls with the dot operator
that span more than one line.
Enabled: true
EnforcedStyle: indented
Layout/SpaceAroundMethodCallOperator:
Description: 'Checks method call operators to not have spaces around them.'
Enabled: true
Layout/SpaceBeforeBrackets:
Description: 'Checks for receiver with a space before the opening brackets.'
StyleGuide: '#space-in-brackets-access'
Enabled: true
#################### Lint ##################################
Lint/AmbiguousBlockAssociation:
Description: >-
Checks for ambiguous block association with method when param passed without
parentheses.
StyleGuide: '#syntax'
Enabled: true
Exclude:
- "spec/**/*"
Lint/BinaryOperatorWithIdenticalOperands:
Description: 'This cop checks for places where binary operator has identical operands.'
Enabled: true
Lint/ConstantResolution:
Description: 'Check that constants are fully qualified with `::`.'
Enabled: false
Lint/DeprecatedConstants:
Description: 'Checks for deprecated constants.'
Enabled: true
Lint/DeprecatedOpenSSLConstant:
Description: "Don't use algorithm constants for `OpenSSL::Cipher` and `OpenSSL::Digest`."
Enabled: true
Lint/DuplicateBranch:
Description: Checks that there are no repeated bodies within `if/unless`, `case-when` and `rescue` constructs.
Enabled: false
Lint/DuplicateElsifCondition:
Description: 'Do not repeat conditions used in if `elsif`.'
Enabled: true
Lint/DuplicateRegexpCharacterClassElement:
Description: 'Checks for duplicate elements in Regexp character classes.'
Enabled: true
Lint/DuplicateRescueException:
Description: 'Checks that there are no repeated exceptions used in `rescue` expressions.'
Enabled: true
Lint/EmptyConditionalBody:
Description: 'This cop checks for the presence of `if`, `elsif` and `unless` branches without a body.'
Enabled: true
Lint/EmptyBlock:
Description: 'This cop checks for blocks without a body.'
Enabled: true
Lint/EmptyClass:
Description: 'Checks for classes and metaclasses without a body.'
Enabled: true
Lint/FloatComparison:
Description: 'Checks for the presence of precise comparison of floating point numbers.'
StyleGuide: '#float-comparison'
Enabled: true
# Lint/HeredocMethodCallPosition:
# Description: >-
# Checks for the ordering of a method call where
# the receiver of the call is a HEREDOC.
# Enabled: false
Lint/MissingSuper:
Description: >-
This cop checks for the presence of constructors and lifecycle callbacks
without calls to `super`'.
Enabled: true
Exclude:
- 'app/components/**/*.rb'
Lint/MixedRegexpCaptureTypes:
Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
Enabled: true
Lint/NumberedParameterAssignment:
Description: 'Checks for uses of numbered parameter assignment.'
Enabled: true
# Lint/NumberConversion:
# Description: 'Checks unsafe usage of number conversion methods.'
# Enabled: false
Lint/OrAssignmentToConstant:
Description: 'Checks unintended or-assignment to constant.'
Enabled: true
Lint/OutOfRangeRegexpRef:
Description: 'Checks for out of range reference for Regexp because it always returns nil.'
Enabled: true
Lint/RaiseException:
Description: Checks for `raise` or `fail` statements which are raising `Exception` class.
StyleGuide: '#raise-exception'
Enabled: true
Lint/RedundantDirGlobSort:
Description: 'Checks for redundant `sort` method to `Dir.glob` and `Dir[]`.'
Enabled: true
Lint/SelfAssignment:
Description: 'Checks for self-assignments.'
Enabled: true
Lint/StructNewOverride:
Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
Enabled: true
Lint/SymbolConversion:
Description: 'Checks for unnecessary symbol conversions.'
Enabled: true
Lint/ToEnumArguments:
Description: 'This cop ensures that `to_enum`/`enum_for`, called for the current method, has correct arguments.'
Enabled: true
Lint/TopLevelReturnWithArgument:
Description: 'This cop detects top level return statements with argument.'
Enabled: true
Lint/TripleQuotes:
Description: 'Checks for useless triple quote constructs.'
Enabled: true
Lint/UnexpectedBlockArity:
Description: 'Looks for blocks that have fewer arguments that the calling method expects.'
Enabled: true
Lint/UnmodifiedReduceAccumulator:
Description: Checks for `reduce` or `inject` blocks that do not update the accumulator each iteration.
Enabled: true
Lint/UnreachableLoop:
Description: 'This cop checks for loops that will have at most one iteration.'
Enabled: true
#################### Metrics ###############################
Metrics/AbcSize:
Description: >-
A calculated magnitude based on number of assignments,
branches, and conditions.
Enabled: false
Metrics/BlockLength:
Description: 'Avoid long blocks with many lines.'
Enabled: true
Exclude:
- 'db/seeds.rb'
- 'Guardfile'
- 'spec/**/*'
Metrics/ClassLength:
Description: 'Avoid classes longer than 100 lines of code.'
Enabled: false
Metrics/CyclomaticComplexity:
Description: >-
A complexity metric that is strongly correlated to the number
of test cases needed to validate a method.
Enabled: true
Max: 13
Metrics/MethodLength:
Description: 'Avoid methods longer than 10 lines of code.'
StyleGuide: '#short-methods'
Enabled: false
Metrics/ModuleLength:
Description: 'Avoid modules longer than 100 lines of code.'
Enabled: false
Metrics/ParameterLists:
Description: 'Avoid parameter lists longer than three or four parameters.'
StyleGuide: '#too-many-params'
Enabled: false
Metrics/PerceivedComplexity:
Description: >-
A complexity metric geared towards measuring complexity for a
human reader.
Enabled: true
Max: 14
#################### Naming ##############################
Naming/AccessorMethodName:
Description: Check the naming of accessor methods for get_/set_.
StyleGuide: '#accessor_mutator_method_names'
Enabled: false
Naming/InclusiveLanguage:
Description: 'Recommend the use of inclusive language instead of problematic terms.'
Enabled: false
Naming/PredicateName:
Description: 'Check the names of predicate methods.'
StyleGuide: '#bool-methods-qmark'
Enabled: true
ForbiddenPrefixes:
- is_
Exclude:
- spec/**/*
Naming/VariableNumber:
Description: 'Use the configured style when numbering symbols, methods and variables.'
StyleGuide: '#snake-case-symbols-methods-vars-with-numbers'
Enabled: false
#################### Style ###############################
Style/AsciiComments:
Description: 'Use only ascii symbols in comments.'
StyleGuide: '#english-comments'
Enabled: false
Style/AccessorGrouping:
Description: 'Checks for grouping of accessors in `class` and `module` bodies.'
Enabled: true
Style/ArgumentsForwarding:
Description: 'Use arguments forwarding.'
StyleGuide: '#arguments-forwarding'
Enabled: false
Style/ArrayCoercion:
Description: >-
Use Array() instead of explicit Array check or [*var], when dealing
with a variable you want to treat as an Array, but you're not certain it's an array.
StyleGuide: '#array-coercion'
Enabled: true
# Style/AutoResourceCleanup:
# Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
# Enabled: false
Style/BisectedAttrAccessor:
Description: >-
Checks for places where `attr_reader` and `attr_writer`
for the same method can be combined into single `attr_accessor`.
Enabled: true
Style/CaseLikeIf:
Description: 'This cop identifies places where `if-elsif` constructions can be replaced with `case-when`.'
StyleGuide: '#case-vs-if-else'
Enabled: true
Style/ClassAndModuleChildren:
Description: 'Checks style of children classes and modules.'
StyleGuide: '#namespace-definition'
Enabled: true
SafeAutoCorrect: true
Style/CollectionCompact:
Description: 'Use `{Array,Hash}#{compact,compact!}` instead of custom logic to reject nils.'
Enabled: true
Style/CollectionMethods:
Description: 'Preferred collection methods.'
StyleGuide: '#map-find-select-reduce-include-size'
Enabled: true
PreferredMethods:
find: detect
# Style/ConstantVisibility:
# Description: >-
# Check that class- and module constants have
# visibility declarations.
# Enabled: false
# Style/DateTime:
# Description: 'Use Time over DateTime.'
# StyleGuide: '#no-datetime'
# Enabled: false
Style/Documentation:
Description: 'Document classes and non-namespace modules.'
Enabled: false
Style/DocumentDynamicEvalDefinition:
Description: >-
When using `class_eval` (or other `eval`) with string interpolation,
add a comment block showing its appearance if interpolated.
StyleGuide: '#eval-comment-docs'
Enabled: true
Style/ExplicitBlockArgument:
Description: >-
Consider using explicit block argument to avoid writing block literal
that just passes its arguments to another block.
StyleGuide: '#block-argument'
Enabled: true
Style/Encoding:
Description: 'Use UTF-8 as the source file encoding.'
Enabled: false
Style/EndlessMethod:
Description: 'Avoid the use of multi-lined endless method definitions.'
StyleGuide: '#endless-methods'
Enabled: pending
Style/ExponentialNotation:
Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
StyleGuide: '#exponential-notation'
Enabled: true
EnforcedStyle: scientific
Style/FormatStringToken:
Description: 'Use a consistent style for format string tokens.'
Exclude:
- 'config/routes.rb'
Style/FrozenStringLiteralComment:
Description: >-
Add the frozen_string_literal comment to the top of files
to help transition to frozen string literals by default.
Enabled: true
EnforcedStyle: never
Style/GlobalStdStream:
Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
StyleGuide: '#global-stdout'
Enabled: true
Style/HashAsLastArrayItem:
Description: >-
Checks for presence or absence of braces around hash literal as a last
array item depending on configuration.
StyleGuide: '#hash-literal-as-last-array-item'
Enabled: true
EnforcedStyle: braces
Style/HashConversion:
Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.'
Enabled: true
Style/HashEachMethods:
Description: 'Use Hash#each_key and Hash#each_value.'
StyleGuide: '#hash-each'
Enabled: true
Style/HashExcept:
Description: >-
Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
that can be replaced with `Hash#except` method.
Enabled: true
Style/HashLikeCase:
Description: >-
Checks for places where `case-when` represents a simple 1:1
mapping and can be replaced with a hash lookup.
Enabled: true
Style/HashSyntax:
Description: >-
Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
{ :a => 1, :b => 2 }.
StyleGuide: '#hash-literals'
Enabled: true
EnforcedStyle: ruby19_no_mixed_keys
Style/HashTransformKeys:
Description: 'Prefer `transform_keys` over `each_with_object` and `map`.'
StyleGuide: '#hash-transform-methods'
Enabled: true
Style/HashTransformValues:
Description: 'Prefer `transform_values` over `each_with_object` and `map`.'
StyleGuide: '#hash-transform-methods'
Enabled: true
Style/IfUnlessModifier:
Description: >-
Favor modifier if/unless usage when you have a
single-line body.
StyleGuide: '#if-as-a-modifier'
Enabled: false
Style/IfWithBooleanLiteralBranches:
Description: 'Checks for redundant `if` with boolean literal branches.'
Enabled: true
# Style/ImplicitRuntimeError:
# Description: >-
# Use `raise` or `fail` with an explicit exception class and
# message, rather than just a message.
# Enabled: false
# Style/InlineComment:
# Description: 'Avoid trailing inline comments.'
# Enabled: false
Style/InPatternThen:
Description: 'Checks for `in;` uses in `case` expressions.'
StyleGuide: '#no-in-pattern-semicolons'
Enabled: true
# Style/IpAddresses:
# Description: "Don't include literal IP addresses in code."
# Enabled: false
# Style/MethodCallWithArgsParentheses:
# Description: 'Use parentheses for method calls with arguments.'
# StyleGuide: '#method-invocation-parens'
# Enabled: false
# Style/MethodCalledOnDoEndBlock:
# Description: 'Avoid chaining a method call on a do...end block.'
# StyleGuide: '#single-line-blocks'
# Enabled: false
Style/MultilineInPatternThen:
Description: 'Do not use `then` for multi-line `in` statement.'
Enabled: true
Style/NegatedIfElseCondition:
Description: >-
This cop 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/Next:
Description: 'Use `next` to skip iteration instead of a condition at the end.'
StyleGuide: '#no-nested-conditionals'
Enabled: true
Style/NilLambda:
Description: 'Prefer `-> {}` to `-> { nil }`.'
Enabled: true
Style/OptionalBooleanParameter:
Description: 'Use keyword arguments when defining method with boolean argument.'
StyleGuide: '#boolean-keyword-arguments'
Enabled: true
Style/OptionHash:
Description: "Don't use option hashes when you can use keyword arguments."
Enabled: true
Style/QuotedSymbols:
Description: 'Use a consistent style for quoted symbols.'
Enabled: true
Style/RedundantArgument:
Description: 'Check for a redundant argument passed to certain methods.'
Enabled: true
Style/RedundantAssignment:
Description: 'Checks for redundant assignment before returning.'
Enabled: true
Style/RedundantFetchBlock:
Description: >-
Use `fetch(key, value)` instead of `fetch(key) { value }`
when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
Enabled: true
Style/RedundantFileExtensionInRequire:
Description: >-
Checks for the presence of superfluous `.rb` extension in
the filename provided to `require` and `require_relative`.
StyleGuide: '#no-explicit-rb-to-require'
Enabled: true
Style/RedundantRegexpCharacterClass:
Description: 'Checks for unnecessary single-element Regexp character classes.'
Enabled: true
Style/RedundantRegexpEscape:
Description: 'Checks for redundant escapes in Regexps.'
Enabled: true
Style/ReturnNil:
Description: 'Use return instead of return nil.'
Enabled: true
Style/Send:
Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
StyleGuide: '#prefer-public-send'
Enabled: true
Style/SingleArgumentDig:
Description: 'Avoid using single argument dig method.'
Enabled: true
Style/SingleLineBlockParams:
Description: 'Enforces the names of some block params.'
Enabled: true
Style/SlicingWithRange:
Description: 'Checks array slicing is done with endless ranges when suitable.'
Enabled: true
Style/StringChars:
Description: 'Checks for uses of `String#split` with empty string or regexp literal argument.'
Enabled: true
Style/StringConcatenation:
Description: 'Checks for places where string concatenation can be replaced with string interpolation.'
StyleGuide: '#string-interpolation'
Enabled: true
Style/StringLiterals:
Description: 'Checks if uses of quotes match the configured preference.'
StyleGuide: '#consistent-string-literals'
Enabled: true
EnforcedStyle: double_quotes
ConsistentQuotesInMultiline: true
Style/SwapValues:
Description: 'This cop enforces the use of shorthand-style swapping of 2 variables.'
StyleGuide: '#values-swapping'
Enabled: true
Style/TopLevelMethodDefinition:
Description: 'This cop looks for top-level method definitions.'
Enabled: true
Exclude:
- scripts/release
- scripts/stage_release
Style/TrailingCommaInArguments:
Description: 'Checks for trailing comma in argument lists.'
StyleGuide: '#no-trailing-params-comma'
Enabled: true
EnforcedStyleForMultiline: comma
Style/TrailingCommaInArrayLiteral:
Description: 'Checks for trailing comma in array literals.'
StyleGuide: '#no-trailing-array-commas'
Enabled: true
EnforcedStyleForMultiline: comma
Style/TrailingCommaInBlockArgs:
Description: 'Checks for useless trailing commas in block arguments.'
Enabled: true
Style/UnlessLogicalOperators:
Description: >-
Checks for use of logical operators in an unless condition.
Enabled: false
# Performance cops from rubocop-performance
# https://github.com/rubocop-hq/rubocop-performance/blob/master/config/default.yml
Performance/AncestorsInclude:
Description: 'Use `A <= B` instead of `A.ancestors.include?(B)`.'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#ancestorsinclude-vs--code'
Enabled: true
Performance/BigDecimalWithNumericArgument:
Description: 'Convert numeric argument to string before passing to BigDecimal.'
Enabled: true
Performance/CaseWhenSplat:
Description: >-
Reordering `when` conditions with a splat to the end
of the `when` branches can improve performance.
Enabled: true
Performance/ChainArrayAllocation:
Description: >-
Instead of chaining array methods that allocate new arrays, mutate an
existing array.
Reference: 'https://twitter.com/schneems/status/1034123879978029057'
Enabled: false
Performance/IoReadlines:
Description: 'Use `IO.each_line` (`IO#each_line`) instead of `IO.readlines` (`IO#readlines`).'
Reference: 'https://docs.gitlab.com/ee/development/performance.html#reading-from-files-and-other-data-sources'
Enabled: true
Performance/MapCompact:
Description: 'Use `filter_map` instead of `collection.map(&:do_something).compact`.'
Enabled: true
Performance/OpenStruct:
Description: 'Use `Struct` instead of `OpenStruct`.'
Enabled: true
Performance/RedundantEqualityComparisonBlock:
Description: >-
Checks for uses `Enumerable#all?`, `Enumerable#any?`, `Enumerable#one?`,
or `Enumerable#none?` are compared with `===` or similar methods in block.
Enabled: true
Performance/RedundantSortBlock:
Description: 'Use `sort` instead of `sort { |a, b| a <=> b }`.'
Enabled: true
Performance/RedundantSplitRegexpArgument:
Description: 'This cop identifies places where `split` argument can be replaced from a deterministic regexp to a string.'
Enabled: true
Performance/RedundantStringChars:
Description: 'Checks for redundant `String#chars`.'
Enabled: true
Performance/ReverseFirst:
Description: 'Use `last(n).reverse` instead of `reverse.first(n)`.'
Enabled: true
Performance/SelectMap:
Description: 'Use `filter_map` instead of `ary.select(&:foo).map(&:bar)`.'
Enabled: true
Performance/SortReverse:
Description: 'Use `sort.reverse` instead of `sort { |a, b| b <=> a }`.'
Enabled: true
Performance/Squeeze:
Description: "Use `squeeze('a')` instead of `gsub(/a+/, 'a')`."
Reference: 'https://github.com/JuanitoFatas/fast-ruby#remove-extra-spaces-or-other-contiguous-characters-code'
Enabled: true
Performance/StringInclude:
Description: 'Use `String#include?` instead of a regex match with literal-only pattern.'
Enabled: true
# Rails cops from rubocop-rails
# https://github.com/rubocop-hq/rubocop-rails/blob/master/config/default.yml
# TODO: [@thepracticaldev/oss] enable these Rails cops
Rails/ActiveRecordCallbacksOrder:
Description: 'Order callback declarations in the order in which they will be executed.'
StyleGuide: 'https://rails.rubystyle.guide/#callbacks-order'
Enabled: true
Rails/AddColumnIndex:
Description: >-
Rails migrations don't make use of a given `index` key, but also
doesn't given an error when it's used, so it makes it seem like an
index might be used.
Enabled: true
Rails/Date:
Exclude:
- scripts/release
- scripts/stage_release
Rails/DefaultScope:
Description: 'Avoid use of `default_scope`.'
StyleGuide: 'https://rails.rubystyle.guide#avoid-default-scope'
Enabled: true
Rails/EagerEvaluationLogMessage:
Description: 'Checks that blocks are used for interpolated strings passed to `Rails.logger.debug`.'
Reference: 'https://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance'
Enabled: true
Rails/EnvironmentVariableAccess:
Description: 'Do not access `ENV` directly after initialization.'
Enabled: false
Rails/ExpandedDateRange:
Description: 'Checks for expanded date range.'
Enabled: true
Rails/FilePath:
EnforcedStyle: slashes
Rails/FindById:
Description: >-
Favor the use of `find` over `where.take!`, `find_by!`, and `find_by_id!` when you
need to retrieve a single record by primary key when you expect it to be found.
StyleGuide: 'https://rails.rubystyle.guide/#find'
Enabled: true
Rails/I18nLocaleAssignment:
Description: 'Prefer the usage of `I18n.with_locale` instead of manually updating `I18n.locale` value.'
Enabled: true
Rails/Inquiry:
Description: "Prefer Ruby's comparison operators over Active Support's `Array#inquiry` and `String#inquiry`."
StyleGuide: 'https://rails.rubystyle.guide/#inquiry'
Enabled: true
Rails/MailerName:
Description: 'Mailer should end with `Mailer` suffix.'
StyleGuide: 'https://rails.rubystyle.guide/#mailer-name'
Enabled: true
Rails/MatchRoute:
Description: >-
Don't use `match` to define any routes unless there is a need to map multiple request types
among [:get, :post, :patch, :put, :delete] to a single action using the `:via` option.
StyleGuide: 'https://rails.rubystyle.guide/#no-match-routes'
Enabled: true
Rails/NegateInclude:
Description: 'Prefer `collection.exclude?(obj)` over `!collection.include?(obj)`.'
Enabled: true
Rails/Pluck:
Description: 'Prefer `pluck` over `map { ... }`.'
Enabled: true
Rails/PluckId:
Description: 'Use `ids` instead of `pluck(:id)` or `pluck(primary_key)`.'
StyleGuide: 'https://rails.rubystyle.guide/#ids'
Enabled: true
Rails/PluckInWhere:
Description: 'Use `select` instead of `pluck` in `where` query methods.'
Enabled: true
Rails/RenderInline:
Description: 'Prefer using a template over inline rendering.'
StyleGuide: 'https://rails.rubystyle.guide/#inline-rendering'
Enabled: true
Rails/RenderPlainText:
Description: 'Prefer `render plain:` over `render text:`.'
StyleGuide: 'https://rails.rubystyle.guide/#plain-text-rendering'
Enabled: true
# TODO: enable this once all loader related deprecations on console/server startup are dealt with
Rails/RequireDependency:
Description: 'Do not use `require_dependency` when running in Zeitwerk mode. `require_dependency` is for autoloading in classic mode.'
Reference: 'https://guides.rubyonrails.org/autoloading_and_reloading_constants.html'
Enabled: false
Rails/ReversibleMigrationMethodDefinition:
Description: 'Checks whether the migration implements either a `change` method or both an `up` and a `down` method.'
Enabled: true
Include:
- db/migrate/*.rb
Rails/ShortI18n:
Description: 'Use the short form of the I18n methods: `t` instead of `translate` and `l` instead of `localize`.'
StyleGuide: 'https://rails.rubystyle.guide/#short-i18n'
Enabled: true
Rails/SkipsModelValidations:
Description: >-
Use methods that skips model validations with caution.
See reference for more information.
Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
Enabled: false
Rails/SquishedSQLHeredocs:
Enabled: false
Rails/TimeZoneAssignment:
Description: 'Prefer the usage of `Time.use_zone` instead of manually updating `Time.zone` value.'
Reference: 'https://thoughtbot.com/blog/its-about-time-zones'
Enabled: true
Rails/UnusedIgnoredColumns:
Description: 'Remove a column that does not exist from `ignored_columns`.'
Enabled: true
Rails/WhereExists:
Description: 'Prefer `exists?(...)` over `where(...).exists?`.'
Enabled: true
# RSpec cops from rubocop-rspec
# https://github.com/rubocop-hq/rubocop-rspec/blob/master/config/default.yml
RSpec/DescribeClass:
Description: Check that the first argument to the top level describe is a constant.
Enabled: true
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass
Exclude:
- 'spec/requests/**/*'
- 'spec/system/**/*'
- 'spec/tasks/**/*'
RSpec/DescribedClassModuleWrapping:
Description: Avoid opening modules and defining specs within them.
Enabled: true
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClassModuleWrapping
RSpec/ExampleLength:
Description: Checks for long examples.
Enabled: true
Max: 15
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength
RSpec/IdenticalEqualityAssertion:
Description: Checks for equality assertions with identical expressions on both sides.
Enabled: true
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IdenticalEqualityAssertion
RSpec/MessageExpectation:
Description: Checks for consistent message expectation style.
Enabled: true
EnforcedStyle: allow
RSpec/MultipleMemoizedHelpers:
Description: Checks if example groups contain too many `let` and `subject` calls.
Enabled: false
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleMemoizedHelpers
RSpec/MultipleExpectations:
Description: Checks if examples contain too many `expect` calls.
Enabled: true
Max: 8
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleExpectations
RSpec/Rails/AvoidSetupHook:
Description: Checks that tests use RSpec `before` hook over Rails `setup` method.
Enabled: true
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/AvoidSetupHook