.rubocop.yml 27.3 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 197 198
Style/EmptyLinesAroundAccessModifier:
  Enabled: false

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 225 226
Style/EndOfLine:
  Enabled: false

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 240 241 242
  Enabled: true

# Checks for a line break before the first parameter in a multi-line method
#   parameter definition.
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 250 251
Style/For:
  Enabled: false

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 289 290 291
Style/IndentAssignment:
  Enabled: false

# 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 321 322
Style/LeadingCommentSpace:
  Enabled: false

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 333 334
Style/MethodDefParentheses:
  Enabled: false

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 365 366
Style/MultilineIfThen:
  Enabled: false

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 397 398
Style/NegatedIf:
  Enabled: false

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 491 492 493 494
# Checks usages of Object#freeze on immutable objects.
Style/RedundantFreeze:
  Enabled: false

# TODO: Enable RedundantParentheses Cop.
# Checks for parentheses that seem not to serve any purpose.
Style/RedundantParentheses:
  Enabled: false

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

571 572
# No spaces before commas.
Style/SpaceBeforeComma:
573 574
  Enabled: false

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

579 580 581 582 583 584 585
# 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:
586
  Enabled: true
587

588 589 590 591
# 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:
592 593
  Enabled: false

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

684 685 686 687 688 689
# 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.
690 691 692
Style/UnneededPercentQ:
  Enabled: false

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

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

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

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

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

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

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


724 725
#################### Metrics ################################

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

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

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

741 742 743 744 745 746 747
# 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.
748 749 750
Metrics/LineLength:
  Enabled: false

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

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

759 760 761 762 763 764 765 766
# 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 已提交
767
  Max: 18
768 769


770 771
#################### Lint ################################

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

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

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

786
# Align block ends correctly.
787 788 789
Lint/BlockAlignment:
  Enabled: false

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

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

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

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

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

811 812 813 814 815 816 817 818 819 820
# 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:
821
  Enabled: true
822 823

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

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

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

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

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

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

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

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

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

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

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

# 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.
876
Lint/InvalidCharacterLiteral:
877
  Enabled: true
878

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

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

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

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

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

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

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

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

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

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

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

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

930 931 932 933 934 935 936
# 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.
937 938 939
Lint/UnusedBlockArgument:
  Enabled: false

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

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

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

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

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

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

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

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

972 973 974 975 976

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

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

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

# 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 已提交
991
  Enabled: true
992 993 994

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

# 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:
1017
  Enabled: true
1018 1019 1020 1021

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

1024 1025 1026 1027
# 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 已提交
1028
  Enabled: true
1029 1030 1031 1032 1033 1034 1035

# TODO: Enable TimesMap Cop.
# Checks for `.times.map` calls.
Performance/TimesMap:
  Enabled: false


1036 1037
##################### Rails ##################################

1038 1039 1040 1041 1042
# Enables Rails cops.
Rails:
  Enabled: true

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

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

1052 1053
# Prefer delegate method for delegations.
Rails/Delegate:
1054 1055
  Enabled: false

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

# Prefer `all.find_each` over `all.find`.
Rails/FindEach:
1062
  Enabled: true
1063

1064
# Prefer has_many :through to has_and_belongs_to_many.
1065
Rails/HasAndBelongsToMany:
1066
  Enabled: true
1067

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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