.rubocop.yml 27.2 KB
Newer Older
R
Robert Speicher 已提交
1 2
require: rubocop-rspec

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
AllCops:
  TargetRubyVersion: 2.1
  # Cop names are not displayed in offense messages by default. Change behavior
  # by overriding DisplayCopNames, or by giving the -D/--display-cop-names
  # option.
  DisplayCopNames: true
  # Style guide URLs are not displayed in offense messages by default. Change
  # behavior by overriding DisplayStyleGuide, or by giving the
  # -S/--display-style-guide option.
  DisplayStyleGuide: false
  # Exclude some GitLab files
  Exclude:
    - 'vendor/**/*'
    - 'db/**/*'
    - 'tmp/**/*'
    - 'bin/**/*'
    - 'lib/backup/**/*'
    - 'lib/ci/backup/**/*'
    - 'lib/tasks/**/*'
    - 'lib/ci/migrate/**/*'
    - 'lib/email_validator.rb'
    - 'lib/gitlab/upgrader.rb'
    - 'lib/gitlab/seeder.rb'
26
    - 'generator_templates/**/*'
27 28 29 30 31


##################### Style ##################################

# Check indentation of private/protected visibility modifiers.
32
Style/AccessModifierIndentation:
33
  Enabled: true
34

35
# Check the naming of accessor methods for get_/set_.
36
Style/AccessorMethodName:
37
  Enabled: false
38

39
# Use alias_method instead of alias.
40
Style/Alias:
41
  EnforcedStyle: prefer_alias_method
42
  Enabled: true
43

44
# Align the elements of an array literal if they span more than one line.
45
Style/AlignArray:
46
  Enabled: true
47

48
# Align the elements of a hash literal if they span more than one line.
49
Style/AlignHash:
50
  Enabled: true
51

52
# Align the parameters of a method call if they span more than one line.
53
Style/AlignParameters:
54
  Enabled: false
55

56
# Use &&/|| instead of and/or.
57
Style/AndOr:
58
  Enabled: false
59

60
# Use `Array#join` instead of `Array#*`.
61
Style/ArrayJoin:
62
  Enabled: true
63

64
# Use only ascii symbols in comments.
65
Style/AsciiComments:
66
  Enabled: true
67

68
# Use only ascii symbols in identifiers.
69
Style/AsciiIdentifiers:
70
  Enabled: true
71

72
# Checks for uses of Module#attr.
73
Style/Attr:
74
  Enabled: true
75

76
# Avoid the use of BEGIN blocks.
77
Style/BeginBlock:
D
Dmitriy Zaporozhets 已提交
78
  Enabled: true
79

80
# Checks if usage of %() or %Q() matches configuration.
81 82 83
Style/BarePercentLiterals:
  Enabled: false

84
# Do not use block comments.
85
Style/BlockComments:
86
  Enabled: true
87

88
# Put end statement of multiline block on its own line.
89
Style/BlockEndNewline:
90
  Enabled: true
91

92 93
# Avoid using {...} for multi-line blocks (multiline chaining is # always
# ugly). Prefer {...} over do...end for single-line blocks.
94
Style/BlockDelimiters:
95
  Enabled: true
96

97
# Enforce braces style around hash parameters.
98 99 100
Style/BracesAroundHashParameters:
  Enabled: false

101
# Avoid explicit use of the case equality operator(===).
102 103 104
Style/CaseEquality:
  Enabled: false

105
# Indentation of when in a case/when/[else/]end.
106
Style/CaseIndentation:
107
  Enabled: true
108

109
# Checks for uses of character literals.
110
Style/CharacterLiteral:
D
Dmitriy Zaporozhets 已提交
111
  Enabled: true
112

113
# Use CamelCase for classes and modules.'
114
Style/ClassAndModuleCamelCase:
D
Dmitriy Zaporozhets 已提交
115
  Enabled: true
116

117
# Checks style of children classes and modules.
118 119 120
Style/ClassAndModuleChildren:
  Enabled: false

121
# Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.
122 123 124
Style/ClassCheck:
  Enabled: false

125
# Use self when defining module/class methods.
126
Style/ClassMethods:
127
  Enabled: true
128

129
# Avoid the use of class variables.
130
Style/ClassVars:
D
Dmitriy Zaporozhets 已提交
131
  Enabled: true
132

133
# Do not use :: for method call.
134 135 136
Style/ColonMethodCall:
  Enabled: false

137
# Checks formatting of special comments (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
138 139 140
Style/CommentAnnotation:
  Enabled: false

141
# Indentation of comments.
142
Style/CommentIndentation:
143
  Enabled: true
144

145 146 147 148 149 150 151
# Use the return value of `if` and `case` statements for assignment to a
# variable and variable comparison instead of assigning that variable
# inside of each branch.
Style/ConditionalAssignment:
  Enabled: false

# Constants should use SCREAMING_SNAKE_CASE.
152
Style/ConstantName:
153
  Enabled: true
154

155
# Use def with parentheses when there are arguments.
156
Style/DefWithParentheses:
157
  Enabled: true
158

159
# Checks for use of deprecated Hash methods.
160 161 162
Style/DeprecatedHashMethods:
  Enabled: false

163
# Document classes and non-namespace modules.
164 165 166
Style/Documentation:
  Enabled: false

167
# Checks the position of the dot in multi-line method calls.
168 169 170
Style/DotPosition:
  Enabled: false

171
# Checks for uses of double negation (!!).
172 173 174
Style/DoubleNegation:
  Enabled: false

175
# Prefer `each_with_object` over `inject` or `reduce`.
176 177 178
Style/EachWithObject:
  Enabled: false

179
# Align elses and elsifs correctly.
180
Style/ElseAlignment:
181
  Enabled: true
182

183
# Avoid empty else-clauses.
184 185 186
Style/EmptyElse:
  Enabled: false

187
# Use empty lines between defs.
188 189 190
Style/EmptyLineBetweenDefs:
  Enabled: false

191
# Don't use several empty lines in a row.
192 193 194
Style/EmptyLines:
  Enabled: false

195
# Keep blank lines around access modifiers.
196
Style/EmptyLinesAroundAccessModifier:
197
  Enabled: true
198

199
# Keeps track of empty lines around block bodies.
200 201 202
Style/EmptyLinesAroundBlockBody:
  Enabled: false

203
# Keeps track of empty lines around class bodies.
204 205 206
Style/EmptyLinesAroundClassBody:
  Enabled: false

207
# Keeps track of empty lines around module bodies.
208 209 210
Style/EmptyLinesAroundModuleBody:
  Enabled: false

211
# Keeps track of empty lines around method bodies.
212 213 214
Style/EmptyLinesAroundMethodBody:
  Enabled: false

215
# Prefer literals to Array.new/Hash.new/String.new.
216 217 218
Style/EmptyLiteral:
  Enabled: false

219
# Avoid the use of END blocks.
220
Style/EndBlock:
221
  Enabled: true
222

223
# Use Unix-style line endings.
224
Style/EndOfLine:
225
  Enabled: true
226

227
# Favor the use of Fixnum#even? && Fixnum#odd?
228
Style/EvenOdd:
229
  Enabled: true
230

231
# Do not use unnecessary spacing.
232 233 234
Style/ExtraSpacing:
  Enabled: false

235
# Use snake_case for source file names.
236
Style/FileName:
237 238 239
  Enabled: true

# Checks for a line break before the first parameter in a multi-line method
240
# parameter definition.
241 242
Style/FirstMethodParameterLineBreak:
  Enabled: true
243

244
# Checks for flip flops.
245
Style/FlipFlop:
246
  Enabled: true
247

248
# Checks use of for or each in multiline loops.
249
Style/For:
G
Grzegorz Bizon 已提交
250
  Enabled: true
251

252
# Enforce the use of Kernel#sprintf, Kernel#format or String#%.
253 254 255
Style/FormatString:
  Enabled: false

256
# Do not introduce global variables.
257
Style/GlobalVars:
258
  Enabled: true
259

260
# Check for conditionals that can be replaced with guard clauses.
261 262 263
Style/GuardClause:
  Enabled: false

264 265
# Prefer Ruby 1.9 hash syntax `{ a: 1, b: 2 }`
# over 1.8 syntax `{ :a => 1, :b => 2 }`.
266
Style/HashSyntax:
267
  Enabled: true
268

269 270 271 272 273
# Finds if nodes inside else, which can be converted to elsif.
Style/IfInsideElse:
  Enabled: false

# Favor modifier if/unless usage when you have a single-line body.
274 275 276
Style/IfUnlessModifier:
  Enabled: false

277
# Do not use if x; .... Use the ternary operator instead.
278
Style/IfWithSemicolon:
279
  Enabled: true
280

281 282 283 284 285 286
# Checks that conditional statements do not have an identical line at the
# end of each branch, which can validly be moved out of the conditional.
Style/IdenticalConditionalBranches:
  Enabled: false

# Checks the indentation of the first line of the right-hand-side of a
G
Gabriel Mazetto 已提交
287
# multi-line assignment.
288
Style/IndentAssignment:
289
  Enabled: true
290 291

# Keep indentation straight.
292
Style/IndentationConsistency:
293
  Enabled: true
294

295
# Use 2 spaces for indentation.
296
Style/IndentationWidth:
297
  Enabled: true
298

299
# Checks the indentation of the first element in an array literal.
300 301 302
Style/IndentArray:
  Enabled: false

303
# Checks the indentation of the first key in a hash literal.
304 305 306
Style/IndentHash:
  Enabled: false

307
# Use Kernel#loop for infinite loops.
308
Style/InfiniteLoop:
309
  Enabled: true
310

311
# Use the new lambda literal syntax for single-line blocks.
312 313 314
Style/Lambda:
  Enabled: false

315
# Use lambda.call(...) instead of lambda.(...).
316
Style/LambdaCall:
317
  Enabled: true
318

319
# Comments should start with a space.
320
Style/LeadingCommentSpace:
F
Felipe Artur 已提交
321
  Enabled: true
322

323
# Use \ instead of + or << to concatenate two string literals at line end.
324 325 326
Style/LineEndConcatenation:
  Enabled: false

327
# Do not use parentheses for method calls with no arguments.
328 329 330
Style/MethodCallParentheses:
  Enabled: false

331
# Checks if the method definitions have or don't have parentheses.
332
Style/MethodDefParentheses:
333
  Enabled: true
334

335
# Use the configured style when naming methods.
336
Style/MethodName:
337
  Enabled: true
338

339
# Checks for usage of `extend self` in modules.
340 341 342
Style/ModuleFunction:
  Enabled: false

R
Robert Speicher 已提交
343 344 345 346 347 348
# Checks that the closing brace in an array literal is either on the same line
# as the last array element, or a new line.
Style/MultilineArrayBraceLayout:
  Enabled: false
  EnforcedStyle: symmetrical

349
# Avoid multi-line chains of blocks.
350 351 352
Style/MultilineBlockChain:
  Enabled: false

353
# Ensures newlines after multiline block do statements.
354
Style/MultilineBlockLayout:
355
  Enabled: true
356

R
Robert Speicher 已提交
357 358 359 360 361 362
# Checks that the closing brace in a hash literal is either on the same line as
# the last hash element, or a new line.
Style/MultilineHashBraceLayout:
  Enabled: false
  EnforcedStyle: symmetrical

363
# Do not use then for multi-line if/unless.
364
Style/MultilineIfThen:
365
  Enabled: true
366

R
Robert Speicher 已提交
367 368 369 370 371 372
# Checks that the closing brace in a method call is either on the same line as
# the last method argument, or a new line.
Style/MultilineMethodCallBraceLayout:
  Enabled: false
  EnforcedStyle: symmetrical

373 374 375 376 377
# Checks indentation of method calls with the dot operator that span more than
# one line.
Style/MultilineMethodCallIndentation:
  Enabled: false

378 379 380 381 382
# Checks that the closing brace in a method definition is symmetrical with
# respect to the opening brace and the method parameters.
Style/MultilineMethodDefinitionBraceLayout:
  Enabled: false

383
# Checks indentation of binary operations that span more than one line.
384 385 386
Style/MultilineOperationIndentation:
  Enabled: false

387
# Avoid multi-line `? :` (the ternary operator), use if/unless instead.
388 389 390
Style/MultilineTernaryOperator:
  Enabled: false

391 392 393 394 395
# Do not assign mutable objects to constants.
Style/MutableConstant:
  Enabled: false

# Favor unless over if for negative conditions (or control flow or).
396
Style/NegatedIf:
397
  Enabled: true
398

399
# Favor until over while for negative conditions.
400 401 402
Style/NegatedWhile:
  Enabled: false

403 404
# Avoid using nested modifiers.
Style/NestedModifier:
405
  Enabled: true
406 407 408 409 410 411 412

# Parenthesize method calls which are nested inside the argument list of
# another parenthesized method call.
Style/NestedParenthesizedCalls:
  Enabled: false

# Use one expression per branch in a ternary operator.
413
Style/NestedTernaryOperator:
414
  Enabled: true
415

416
# Use `next` to skip iteration instead of a condition at the end.
417 418 419
Style/Next:
  Enabled: false

420
# Prefer x.nil? to x == nil.
421
Style/NilComparison:
422
  Enabled: true
423

424
# Checks for redundant nil checks.
425
Style/NonNilCheck:
426
  Enabled: true
427

428
# Use ! instead of not.
429
Style/Not:
430
  Enabled: true
431

432
# Add underscores to large numeric literals to improve their readability.
433 434 435
Style/NumericLiterals:
  Enabled: false

436
# Favor the ternary operator(?:) over if/then/else/end constructs.
437
Style/OneLineConditional:
438
  Enabled: true
439

440
# When defining binary operators, name the argument other.
441
Style/OpMethod:
442
  Enabled: true
443

444 445
# Check for simple usages of parallel assignment. It will only warn when
# the number of variables matches on both sides of the assignment.
446 447 448
Style/ParallelAssignment:
  Enabled: false

449
# Don't use parentheses around the condition of an if/unless/while.
450
Style/ParenthesesAroundCondition:
451
  Enabled: true
452

453
# Use `%`-literal delimiters consistently.
454 455 456
Style/PercentLiteralDelimiters:
  Enabled: false

457
# Checks if uses of %Q/%q match the configured preference.
458 459 460
Style/PercentQLiterals:
  Enabled: false

461
# Avoid Perl-style regex back references.
462 463 464
Style/PerlBackrefs:
  Enabled: false

465
# Check the names of predicate methods.
466 467 468
Style/PredicateName:
  Enabled: false

469
# Use proc instead of Proc.new.
470 471 472
Style/Proc:
  Enabled: false

473
# Checks the arguments passed to raise/fail.
474 475 476
Style/RaiseArgs:
  Enabled: false

477
# Don't use begin blocks when they are not needed.
478 479 480
Style/RedundantBegin:
  Enabled: false

481
# Checks for an obsolete RuntimeException argument in raise/fail.
482 483 484
Style/RedundantException:
  Enabled: false

485 486 487 488 489 490
# Checks usages of Object#freeze on immutable objects.
Style/RedundantFreeze:
  Enabled: false

# Checks for parentheses that seem not to serve any purpose.
Style/RedundantParentheses:
491
  Enabled: true
492 493

# Don't use return where it's not required.
494
Style/RedundantReturn:
495
  Enabled: true
496

497
# Don't use self where it's not needed.
498 499 500
Style/RedundantSelf:
  Enabled: false

501 502 503
# Use %r for regular expressions matching more than `MaxSlashes` '/'
# characters. Use %r only for regular expressions matching more
# than `MaxSlashes` '/' character.
504 505 506
Style/RegexpLiteral:
  Enabled: false

507
# Avoid using rescue in its modifier form.
508 509 510
Style/RescueModifier:
  Enabled: false

511
# Checks for places where self-assignment shorthand should have been used.
512 513 514
Style/SelfAssignment:
  Enabled: false

515
# Don't use semicolons to terminate expressions.
516
Style/Semicolon:
517
  Enabled: true
518

519
# Checks for proper usage of fail and raise.
520
Style/SignalException:
521 522
  EnforcedStyle: only_raise
  Enabled: true
523

524
# Enforces the names of some block params.
525 526 527
Style/SingleLineBlockParams:
  Enabled: false

528
# Avoid single-line methods.
529 530 531
Style/SingleLineMethods:
  Enabled: false

532
# Use spaces after colons.
533 534 535
Style/SpaceAfterColon:
  Enabled: false

536
# Use spaces after commas.
537 538 539
Style/SpaceAfterComma:
  Enabled: false

540 541
# Do not put a space between a method name and the opening parenthesis in a
# method definition.
542
Style/SpaceAfterMethodName:
543
  Enabled: true
544

545
# Tracks redundant space after the ! operator.
546
Style/SpaceAfterNot:
547
  Enabled: true
548

549
# Use spaces after semicolons.
550
Style/SpaceAfterSemicolon:
551
  Enabled: true
552

553 554 555
# Checks that the equals signs in parameter default assignments have or don't
# have surrounding space depending on configuration.
Style/SpaceAroundEqualsInParameterDefault:
556 557
  Enabled: false

558 559
# Use a space around keywords if appropriate.
Style/SpaceAroundKeyword:
560
  Enabled: true
561

562 563
# Use a single space around operators.
Style/SpaceAroundOperators:
G
Gabriel Mazetto 已提交
564
  Enabled: true
565

566 567
# Checks that the left block brace has or doesn't have space before it.
Style/SpaceBeforeBlockBraces:
568 569
  Enabled: false

570 571
# No spaces before commas.
Style/SpaceBeforeComma:
572
  Enabled: true
573

574 575
# Checks for missing space between code and a comment on the same line.
Style/SpaceBeforeComment:
576
  Enabled: true
577

578 579 580 581 582 583 584
# Checks that exactly one space is used between a method name and the first
# argument for method calls without parentheses.
Style/SpaceBeforeFirstArg:
  Enabled: false

# No spaces before semicolons.
Style/SpaceBeforeSemicolon:
585
  Enabled: true
586

587 588 589 590
# Checks that block braces have or don't have surrounding space.
# For blocks taking parameters, checks that the left brace has or doesn't
# have trailing space.
Style/SpaceInsideBlockBraces:
591 592
  Enabled: false

593
# No spaces after [ or before ].
594 595 596
Style/SpaceInsideBrackets:
  Enabled: false

597
# Use spaces inside hash literal braces - or don't.
598
Style/SpaceInsideHashLiteralBraces:
599
  Enabled: true
600

601
# No spaces after ( or before ).
602 603 604
Style/SpaceInsideParens:
  Enabled: false

605
# No spaces inside range literals.
606
Style/SpaceInsideRangeLiteral:
607
  Enabled: true
608

609 610
# Checks for padding/surrounding spaces inside string interpolation.
Style/SpaceInsideStringInterpolation:
611 612
  EnforcedStyle: no_space
  Enabled: true
613 614

# Avoid Perl-style global variables.
615 616 617
Style/SpecialGlobalVars:
  Enabled: false

618 619
# Check for the usage of parentheses around stabby lambda arguments.
Style/StabbyLambdaParentheses:
620 621
  EnforcedStyle: require_parentheses
  Enabled: true
622 623

# Checks if uses of quotes match the configured preference.
624 625 626
Style/StringLiterals:
  Enabled: false

627 628
# Checks if uses of quotes inside expressions in interpolated strings match the
# configured preference.
629 630 631
Style/StringLiteralsInInterpolation:
  Enabled: false

632 633
# Checks if configured preferred methods are used over non-preferred.
Style/StringMethods:
634 635 636
  PreferredMethods:
    intern: to_sym
  Enabled: true
637 638 639 640 641 642

# Use %i or %I for arrays of symbols.
Style/SymbolArray:
  Enabled: false

# Use symbols as procs instead of blocks when possible.
643 644 645
Style/SymbolProc:
  Enabled: false

646
# No hard tabs.
647
Style/Tab:
D
Dmitriy Zaporozhets 已提交
648
  Enabled: true
649

650
# Checks trailing blank lines and final newline.
651
Style/TrailingBlankLines:
652
  Enabled: true
653

654 655
# Checks for trailing comma in array and hash literals.
Style/TrailingCommaInLiteral:
656 657
  Enabled: false

658 659 660 661 662
# Checks for trailing comma in argument lists.
Style/TrailingCommaInArguments:
  Enabled: false

# Avoid trailing whitespace.
663 664 665
Style/TrailingWhitespace:
  Enabled: false

666 667
# Checks for the usage of unneeded trailing underscores at the end of
# parallel variable assignment.
668 669 670
Style/TrailingUnderscoreVariable:
  Enabled: false

671
# Prefer attr_* methods to trivial readers/writers.
672 673 674
Style/TrivialAccessors:
  Enabled: false

675
# Do not use unless with else. Rewrite these with the positive case first.
676 677 678
Style/UnlessElse:
  Enabled: false

679
# Checks for %W when interpolation is not needed.
680 681 682
Style/UnneededCapitalW:
  Enabled: false

683 684 685 686 687 688
# TODO: Enable UnneededInterpolation Cop.
# Checks for strings that are just an interpolated expression.
Style/UnneededInterpolation:
  Enabled: false

# Checks for %q/%Q when single quotes or double quotes would do.
689 690 691
Style/UnneededPercentQ:
  Enabled: false

692
# Don't interpolate global, instance and class variables directly in strings.
693
Style/VariableInterpolation:
694
  Enabled: true
695

696
# Use the configured style when naming variables.
697
Style/VariableName:
698 699
  EnforcedStyle: snake_case
  Enabled: true
700

701
# Use when x then ... for one-line cases.
702
Style/WhenThen:
703
  Enabled: true
704

705
# Checks for redundant do after while or until.
706
Style/WhileUntilDo:
707
  Enabled: true
708

709
# Favor modifier while/until usage when you have a single-line body.
710
Style/WhileUntilModifier:
711
  Enabled: true
712

713
# Use %w or %W for arrays of words.
714 715 716
Style/WordArray:
  Enabled: false

717 718 719 720 721 722
# TODO: Enable ZeroLengthPredicate Cop.
# Use #empty? when testing for objects of length 0.
Style/ZeroLengthPredicate:
  Enabled: false


723 724
#################### Metrics ################################

725 726
# A calculated magnitude based on number of assignments,
# branches, and conditions.
727
Metrics/AbcSize:
G
Grzegorz Bizon 已提交
728
  Enabled: true
729
  Max: 60
G
Grzegorz Bizon 已提交
730

731
# Avoid excessive block nesting.
732
Metrics/BlockNesting:
G
Grzegorz Bizon 已提交
733 734
  Enabled: true
  Max: 4
735

736
# Avoid classes longer than 100 lines of code.
737 738 739
Metrics/ClassLength:
  Enabled: false

740 741 742 743 744 745 746
# A complexity metric that is strongly correlated to the number
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity:
  Enabled: true
  Max: 17

# Limit lines to 80 characters.
747 748 749
Metrics/LineLength:
  Enabled: false

750
# Avoid methods longer than 10 lines of code.
751 752 753
Metrics/MethodLength:
  Enabled: false

754
# Avoid modules longer than 100 lines of code.
755 756 757
Metrics/ModuleLength:
  Enabled: false

758 759 760 761 762 763 764 765
# Avoid parameter lists longer than three or four parameters.
Metrics/ParameterLists:
  Enabled: true
  Max: 8

# A complexity metric geared towards measuring complexity for a human reader.
Metrics/PerceivedComplexity:
  Enabled: true
V
Valery Sizov 已提交
766
  Max: 18
767 768


769 770
#################### Lint ################################

771 772
# Checks for ambiguous operators in the first argument of a method invocation
# without parentheses.
773 774 775
Lint/AmbiguousOperator:
  Enabled: false

776 777
# Checks for ambiguous regexp literals in the first argument of a method
# invocation without parentheses.
778 779 780
Lint/AmbiguousRegexpLiteral:
  Enabled: false

781
# Don't use assignment in conditions.
782 783 784
Lint/AssignmentInCondition:
  Enabled: false

785
# Align block ends correctly.
786
Lint/BlockAlignment:
787
  Enabled: true
788

789 790 791
# Default values in optional keyword arguments and optional ordinal arguments
# should not refer back to the name of the argument.
Lint/CircularArgumentReference:
792
  Enabled: true
793 794

# Checks for condition placed in a confusing position relative to the keyword.
795
Lint/ConditionPosition:
796
  Enabled: true
797

798
# Check for debugger calls.
799
Lint/Debugger:
800
  Enabled: true
801

802
# Align ends corresponding to defs correctly.
803
Lint/DefEndAlignment:
804
  Enabled: true
805

806
# Check for deprecated class method calls.
807
Lint/DeprecatedClassMethods:
808
  Enabled: true
809

810 811 812 813 814 815 816 817 818 819
# Check for duplicate method definitions.
Lint/DuplicateMethods:
  Enabled: false

# Check for duplicate keys in hash literals.
Lint/DuplicatedKey:
  Enabled: false

# Check for immutable argument given to each_with_object.
Lint/EachWithObjectArgument:
820
  Enabled: true
821 822

# Check for odd code arrangement in an else block.
823
Lint/ElseLayout:
824
  Enabled: true
825

826
# Checks for empty ensure block.
827
Lint/EmptyEnsure:
828
  Enabled: true
829

830
# Checks for empty string interpolation.
831 832 833
Lint/EmptyInterpolation:
  Enabled: false

834
# Align ends correctly.
835
Lint/EndAlignment:
836
  Enabled: true
837

838
# END blocks should not be placed inside method definitions.
839
Lint/EndInMethod:
840
  Enabled: true
841

842
# Do not use return in an ensure block.
843
Lint/EnsureReturn:
844
  Enabled: true
845

846
# The use of eval represents a serious security risk.
847
Lint/Eval:
848
  Enabled: true
849

850 851
# Catches floating-point literals too large or small for Ruby to represent.
Lint/FloatOutOfRange:
852
  Enabled: true
853 854 855

# The number of parameters to format/sprint must match the fields.
Lint/FormatParameterMismatch:
856
  Enabled: true
857 858

# Don't suppress exception.
859 860 861
Lint/HandleExceptions:
  Enabled: false

862 863 864
# Checks for adjacent string literals on the same line, which could better be
# represented as a single string literal.
Lint/ImplicitStringConcatenation:
865
  Enabled: true
866 867 868 869 870 871 872 873 874

# TODO: Enable IneffectiveAccessModifier Cop.
# Checks for attempts to use `private` or `protected` to set the visibility
# of a class method, which does not work.
Lint/IneffectiveAccessModifier:
  Enabled: false

# Checks for invalid character literals with a non-escaped whitespace
# character.
875
Lint/InvalidCharacterLiteral:
876
  Enabled: true
877

878
# Checks of literals used in conditions.
879
Lint/LiteralInCondition:
880
  Enabled: true
881

882
# Checks for literals used in interpolation.
883
Lint/LiteralInInterpolation:
884
  Enabled: true
885

886 887
# Use Kernel#loop with break rather than begin/end/until or begin/end/while
# for post-loop tests.
888 889 890
Lint/Loop:
  Enabled: false

891 892
# Do not use nested method definitions.
Lint/NestedMethodDefinition:
893
  Enabled: true
894 895 896

# Do not omit the accumulator when calling `next` in a `reduce`/`inject` block.
Lint/NextWithoutAccumulator:
897
  Enabled: true
898 899

# Checks for method calls with a space before the opening parenthesis.
900
Lint/ParenthesesAsGroupedExpression:
901
  Enabled: true
902

903 904 905
# Checks for `rand(1)` calls. Such calls always return `0` and most likely
# a mistake.
Lint/RandOne:
906
  Enabled: true
907 908

# Use parentheses in the method call to avoid confusion about precedence.
909
Lint/RequireParentheses:
910
  Enabled: true
911

912
# Avoid rescuing the Exception class.
913
Lint/RescueException:
914
  Enabled: true
915

916 917
# Do not use the same name as outer local variable for block arguments
# or block local variables.
918 919 920
Lint/ShadowingOuterLocalVariable:
  Enabled: false

921
# 'Checks for Object#to_s usage in string interpolation.
922 923 924
Lint/StringConversionInInterpolation:
  Enabled: false

925
# Do not use prefix `_` for a variable that is used.
926
Lint/UnderscorePrefixedVariableName:
927
  Enabled: true
928

929 930 931 932 933 934 935
# Checks for rubocop:disable comments that can be removed.
# Note: this cop is not disabled when disabling all cops.
# It must be explicitly disabled.
Lint/UnneededDisable:
  Enabled: false

# Checks for unused block arguments.
936 937 938
Lint/UnusedBlockArgument:
  Enabled: false

939
# Checks for unused method arguments.
940 941 942
Lint/UnusedMethodArgument:
  Enabled: false

943
# Unreachable code.
944
Lint/UnreachableCode:
945
  Enabled: true
946

947
# Checks for useless access modifiers.
948 949 950
Lint/UselessAccessModifier:
  Enabled: false

951
# Checks for useless assignment to a local variable.
952
Lint/UselessAssignment:
953
  Enabled: true
954

955
# Checks for comparison of something with itself.
956
Lint/UselessComparison:
957
  Enabled: true
958

959
# Checks for useless `else` in `begin..end` without `rescue`.
960
Lint/UselessElseWithoutRescue:
961
  Enabled: true
962

963
# Checks for useless setter call to a local variable.
964
Lint/UselessSetterCall:
965
  Enabled: true
966

967
# Possible use of operator/literal/variable in void context.
968
Lint/Void:
969
  Enabled: true
970

971 972 973 974 975

##################### Performance ############################

# Use `casecmp` rather than `downcase ==`.
Performance/Casecmp:
976
  Enabled: true
977 978 979 980

# Use `str.{start,end}_with?(x, ..., y, ...)` instead of
# `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
Performance/DoubleStartEndWith:
981
  Enabled: true
982 983 984 985 986 987 988 989

# TODO: Enable EndWith Cop.
# Use `end_with?` instead of a regex match anchored to the end of a string.
Performance/EndWith:
  Enabled: false

# Use `strip` instead of `lstrip.rstrip`.
Performance/LstripRstrip:
C
Connor Shea 已提交
990
  Enabled: true
991 992 993

# Use `Range#cover?` instead of `Range#include?`.
Performance/RangeInclude:
994
  Enabled: true
995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015

# TODO: Enable RedundantBlockCall Cop.
# Use `yield` instead of `block.call`.
Performance/RedundantBlockCall:
  Enabled: false

# TODO: Enable RedundantMatch Cop.
# Use `=~` instead of `String#match` or `Regexp#match` in a context where the
# returned `MatchData` is not needed.
Performance/RedundantMatch:
  Enabled: false

# TODO: Enable RedundantMerge Cop.
# Use `Hash#[]=`, rather than `Hash#merge!` with a single key-value pair.
Performance/RedundantMerge:
  # Max number of key-value pairs to consider an offense
  MaxKeyValuePairs: 2
  Enabled: false

# Use `sort` instead of `sort_by { |x| x }`.
Performance/RedundantSortBy:
1016
  Enabled: true
1017 1018 1019 1020

# Use `start_with?` instead of a regex match anchored to the beginning of a
# string.
Performance/StartWith:
1021
  Enabled: true
C
Connor Shea 已提交
1022

1023 1024 1025 1026
# Use `tr` instead of `gsub` when you are replacing the same number of
# characters. Use `delete` instead of `gsub` when you are deleting
# characters.
Performance/StringReplacement:
C
Connor Shea 已提交
1027
  Enabled: true
1028 1029 1030

# Checks for `.times.map` calls.
Performance/TimesMap:
1031
  Enabled: true
1032 1033


1034 1035
##################### Rails ##################################

1036 1037 1038 1039 1040
# Enables Rails cops.
Rails:
  Enabled: true

# Enforces consistent use of action filter methods.
1041
Rails/ActionFilter:
1042
  Enabled: true
1043
  EnforcedStyle: action
1044

1045 1046
# Checks the correct usage of date aware methods, such as `Date.today`,
# `Date.current`, etc.
G
Gabriel Mazetto 已提交
1047 1048 1049
Rails/Date:
  Enabled: false

1050 1051
# Prefer delegate method for delegations.
Rails/Delegate:
1052 1053
  Enabled: false

1054 1055
# Prefer `find_by` over `where.first`.
Rails/FindBy:
1056
  Enabled: true
1057 1058 1059

# Prefer `all.find_each` over `all.find`.
Rails/FindEach:
1060
  Enabled: true
1061

1062
# Prefer has_many :through to has_and_belongs_to_many.
1063
Rails/HasAndBelongsToMany:
1064
  Enabled: true
1065

1066
# Checks for calls to puts, print, etc.
1067
Rails/Output:
1068
  Enabled: true
1069

1070 1071
# Checks for incorrect grammar when using methods like `3.day.ago`.
Rails/PluralizationGrammar:
1072
  Enabled: true
1073 1074

# Checks for `read_attribute(:attr)` and `write_attribute(:attr, val)`.
1075 1076 1077
Rails/ReadWriteAttribute:
  Enabled: false

1078
# Checks the arguments of ActiveRecord scopes.
1079
Rails/ScopeArgs:
1080
  Enabled: true
1081

1082 1083
# Checks the correct usage of time zone aware methods.
# http://danilenko.org/2012/7/6/rails_timezones
1084 1085 1086
Rails/TimeZone:
  Enabled: false

1087
# Use validates :attribute, hash of validations.
1088 1089
Rails/Validation:
  Enabled: false
R
Robert Speicher 已提交
1090 1091 1092

##################### RSpec ##################################

1093
# Check that instances are not being stubbed globally.
R
Robert Speicher 已提交
1094 1095 1096
RSpec/AnyInstance:
  Enabled: false

1097 1098
# Check that the first argument to the top level describe is the tested class or
# module.
R
Robert Speicher 已提交
1099 1100 1101
RSpec/DescribeClass:
  Enabled: false

1102
# Use `described_class` for tested class / module.
R
Robert Speicher 已提交
1103 1104 1105
RSpec/DescribeMethod:
  Enabled: false

1106 1107
# Checks that the second argument to top level describe is the tested method
# name.
R
Robert Speicher 已提交
1108 1109 1110
RSpec/DescribedClass:
  Enabled: false

1111
# Checks for long example.
R
Robert Speicher 已提交
1112 1113 1114 1115
RSpec/ExampleLength:
  Enabled: false
  Max: 5

1116
# Do not use should when describing your tests.
R
Robert Speicher 已提交
1117 1118 1119 1120 1121 1122 1123 1124
RSpec/ExampleWording:
  Enabled: false
  CustomTransform:
    be: is
    have: has
    not: does not
  IgnoredWords: []

1125
# Checks the file and folder naming of the spec file.
R
Robert Speicher 已提交
1126 1127 1128 1129 1130 1131
RSpec/FilePath:
  Enabled: false
  CustomTransform:
    RuboCop: rubocop
    RSpec: rspec

1132
# Checks if there are focused specs.
R
Robert Speicher 已提交
1133 1134 1135
RSpec/Focus:
  Enabled: true

1136
# Checks for the usage of instance variables.
R
Robert Speicher 已提交
1137 1138 1139
RSpec/InstanceVariable:
  Enabled: false

1140
# Checks for multiple top-level describes.
R
Robert Speicher 已提交
1141 1142 1143
RSpec/MultipleDescribes:
  Enabled: false

1144
# Enforces the usage of the same method on all negative message expectations.
R
Robert Speicher 已提交
1145 1146
RSpec/NotToNot:
  EnforcedStyle: not_to
1147
  Enabled: true
R
Robert Speicher 已提交
1148

1149
# Prefer using verifying doubles over normal doubles.
R
Robert Speicher 已提交
1150 1151
RSpec/VerifiedDoubles:
  Enabled: false