BigW Consortium Gitlab

.rubocop.yml 28 KB
Newer Older
1 2 3
require:
  - rubocop-rspec
  - ./rubocop/rubocop
Robert Speicher committed
4

5 6
inherit_from: .rubocop_todo.yml

7
AllCops:
8
  TargetRubyVersion: 2.3
9
  TargetRailsVersion: 4.2
Z.J. van de Weg committed
10
  # Cop names are not d§splayed in offense messages by default. Change behavior
11 12 13 14 15 16 17 18 19 20
  # 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/**/*'
21
    - 'node_modules/**/*'
22 23
    - 'db/*'
    - 'db/fixtures/**/*'
24 25
    - 'tmp/**/*'
    - 'bin/**/*'
26
    - 'generator_templates/**/*'
27
    - 'builds/**/*'
28

Douwe Maan committed
29
# Gems in consecutive lines should be alphabetically sorted
Douwe Maan committed
30 31 32
Bundler/OrderedGems:
  Enabled: false

33
# Layout ######################################################################
34 35

# Check indentation of private/protected visibility modifiers.
36
Layout/AccessModifierIndentation:
37
  Enabled: true
38

39
# Align the elements of an array literal if they span more than one line.
40
Layout/AlignArray:
41
  Enabled: true
42

43
# Align the elements of a hash literal if they span more than one line.
44
Layout/AlignHash:
45
  Enabled: true
46

Douwe Maan committed
47 48
# Here we check if the parameters on a multi-line method call or
# definition are aligned.
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
Layout/AlignParameters:
  Enabled: false

# Put end statement of multiline block on its own line.
Layout/BlockEndNewline:
  Enabled: true

# Indentation of when in a case/when/[else/]end.
Layout/CaseIndentation:
  Enabled: true

# Indentation of comments.
Layout/CommentIndentation:
  Enabled: true

# Multi-line method chaining should be done with leading dots.
Layout/DotPosition:
  Enabled: true
  EnforcedStyle: leading

# Align elses and elsifs correctly.
Layout/ElseAlignment:
  Enabled: true

# Add an empty line after magic comments to separate them from code.
Layout/EmptyLineAfterMagicComment:
  Enabled: false

# Use empty lines between defs.
Layout/EmptyLineBetweenDefs:
  Enabled: true

# Don't use several empty lines in a row.
Layout/EmptyLines:
  Enabled: true

# Keep blank lines around access modifiers.
Layout/EmptyLinesAroundAccessModifier:
  Enabled: true

# Keeps track of empty lines around block bodies.
Layout/EmptyLinesAroundBlockBody:
  Enabled: true

# Keeps track of empty lines around class bodies.
Layout/EmptyLinesAroundClassBody:
  Enabled: true

# Keeps track of empty lines around exception handling keywords.
Layout/EmptyLinesAroundExceptionHandlingKeywords:
  Enabled: false

# Keeps track of empty lines around method bodies.
Layout/EmptyLinesAroundMethodBody:
  Enabled: true

# Keeps track of empty lines around module bodies.
Layout/EmptyLinesAroundModuleBody:
  Enabled: true

# Use Unix-style line endings.
Layout/EndOfLine:
  Enabled: true

# Checks for a line break before the first parameter in a multi-line method
# parameter definition.
Layout/FirstMethodParameterLineBreak:
  Enabled: true

# Keep indentation straight.
Layout/IndentationConsistency:
  Enabled: true

# Use 2 spaces for indentation.
Layout/IndentationWidth:
  Enabled: true

# Checks the indentation of the first line of the right-hand-side of a
# multi-line assignment.
Layout/IndentAssignment:
  Enabled: true

# This cops checks the indentation of the here document bodies.
Layout/IndentHeredoc:
  Enabled: false

# Comments should start with a space.
Layout/LeadingCommentSpace:
  Enabled: true

# Checks that the closing brace in an array literal is either on the same line
# as the last array element, or a new line.
Layout/MultilineArrayBraceLayout:
  Enabled: true
  EnforcedStyle: symmetrical

# Ensures newlines after multiline block do statements.
Layout/MultilineBlockLayout:
  Enabled: true

# Checks that the closing brace in a hash literal is either on the same line as
# the last hash element, or a new line.
Layout/MultilineHashBraceLayout:
  Enabled: true
  EnforcedStyle: symmetrical

# Checks that the closing brace in a method call is either on the same line as
# the last method argument, or a new line.
Layout/MultilineMethodCallBraceLayout:
  Enabled: false
  EnforcedStyle: symmetrical

# Checks indentation of method calls with the dot operator that span more than
# one line.
Layout/MultilineMethodCallIndentation:
  Enabled: false

# Checks that the closing brace in a method definition is symmetrical with
# respect to the opening brace and the method parameters.
Layout/MultilineMethodDefinitionBraceLayout:
  Enabled: false

# Checks indentation of binary operations that span more than one line.
Layout/MultilineOperationIndentation:
  Enabled: true
  EnforcedStyle: indented

# Use spaces after colons.
Layout/SpaceAfterColon:
  Enabled: true

# Use spaces after commas.
Layout/SpaceAfterComma:
  Enabled: true

# Do not put a space between a method name and the opening parenthesis in a
# method definition.
Layout/SpaceAfterMethodName:
  Enabled: true

# Tracks redundant space after the ! operator.
Layout/SpaceAfterNot:
  Enabled: true

# Use spaces after semicolons.
Layout/SpaceAfterSemicolon:
  Enabled: true

# Use space around equals in parameter default
Layout/SpaceAroundEqualsInParameterDefault:
  Enabled: true

# Use a space around keywords if appropriate.
Layout/SpaceAroundKeyword:
  Enabled: true

# Use a single space around operators.
Layout/SpaceAroundOperators:
  Enabled: true

# No spaces before commas.
Layout/SpaceBeforeComma:
  Enabled: true

# Checks for missing space between code and a comment on the same line.
Layout/SpaceBeforeComment:
  Enabled: true

# No spaces before semicolons.
Layout/SpaceBeforeSemicolon:
  Enabled: true

# Checks for spaces inside square brackets.
Layout/SpaceInsideBrackets:
  Enabled: true

# Use spaces inside hash literal braces - or don't.
Layout/SpaceInsideHashLiteralBraces:
  Enabled: true

# No spaces inside range literals.
Layout/SpaceInsideRangeLiteral:
  Enabled: true

# Checks for padding/surrounding spaces inside string interpolation.
Layout/SpaceInsideStringInterpolation:
  EnforcedStyle: no_space
  Enabled: true

# No hard tabs.
Layout/Tab:
  Enabled: true

# Checks trailing blank lines and final newline.
Layout/TrailingBlankLines:
  Enabled: true

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

# Check the naming of accessor methods for get_/set_.
Style/AccessorMethodName:
Douwe Maan committed
250 251
  Enabled: false

252 253 254 255 256
# Use alias_method instead of alias.
Style/Alias:
  EnforcedStyle: prefer_alias_method
  Enabled: true

Douwe Maan committed
257 258 259 260 261
# Whether `and` and `or` are banned only in conditionals (conditionals)
# or completely (always).
Style/AndOr:
  Enabled: true

262
# Use `Array#join` instead of `Array#*`.
263
Style/ArrayJoin:
264
  Enabled: true
265

266
# Use only ascii symbols in comments.
267
Style/AsciiComments:
268
  Enabled: true
269

270
# Use only ascii symbols in identifiers.
271
Style/AsciiIdentifiers:
272
  Enabled: true
273

274
# Checks for uses of Module#attr.
275
Style/Attr:
276
  Enabled: true
277

278
# Avoid the use of BEGIN blocks.
279
Style/BeginBlock:
280
  Enabled: true
281

282
# Do not use block comments.
283
Style/BlockComments:
284
  Enabled: true
285

286 287
# Avoid using {...} for multi-line blocks (multiline chaining is # always
# ugly). Prefer {...} over do...end for single-line blocks.
288
Style/BlockDelimiters:
289
  Enabled: true
290

Douwe Maan committed
291 292
 # This cop checks for braces around the last parameter in a method call
# if the last parameter is a hash.
Douwe Maan committed
293 294 295
Style/BracesAroundHashParameters:
  Enabled: false

Douwe Maan committed
296
# This cop checks for uses of the case equality operator(===).
Douwe Maan committed
297 298 299
Style/CaseEquality:
  Enabled: false

300
# Checks for uses of character literals.
301
Style/CharacterLiteral:
302
  Enabled: true
303

304
# Use CamelCase for classes and modules.'
305
Style/ClassAndModuleCamelCase:
306
  Enabled: true
307

308
# Checks style of children classes and modules.
309 310 311
Style/ClassAndModuleChildren:
  Enabled: false

312
# Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.
313
Style/ClassCheck:
Douwe Maan committed
314
  Enabled: true
315

316
# Use self when defining module/class methods.
317
Style/ClassMethods:
318
  Enabled: true
319

320
# Avoid the use of class variables.
321
Style/ClassVars:
322
  Enabled: true
323

Douwe Maan committed
324 325
# This cop checks for methods invoked via the :: operator instead
# of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).
Douwe Maan committed
326 327 328
Style/ColonMethodCall:
  Enabled: true

Douwe Maan committed
329 330
# This cop checks that comment annotation keywords are written according
# to guidelines.
Douwe Maan committed
331 332 333
Style/CommentAnnotation:
  Enabled: false

Douwe Maan committed
334 335 336
# Check for `if` and `case` statements where each branch is used for
# assignment to the same variable when using the return of the
# condition can be used instead.
Douwe Maan committed
337 338 339
Style/ConditionalAssignment:
  Enabled: true

340
# Constants should use SCREAMING_SNAKE_CASE.
341
Style/ConstantName:
342
  Enabled: true
343

344
# Use def with parentheses when there are arguments.
345
Style/DefWithParentheses:
346
  Enabled: true
347

348
# Document classes and non-namespace modules.
349 350 351
Style/Documentation:
  Enabled: false

Douwe Maan committed
352 353 354
# This cop checks for uses of double negation (!!) to convert something
# to a boolean value. As this is both cryptic and usually redundant, it
# should be avoided.
Douwe Maan committed
355 356 357
Style/DoubleNegation:
  Enabled: false

358
# Avoid the use of END blocks.
359
Style/EndBlock:
360
  Enabled: true
361

362
# Favor the use of Fixnum#even? && Fixnum#odd?
363
Style/EvenOdd:
364
  Enabled: true
365

366
# Use snake_case for source file names.
367
Style/FileName:
368 369
  Enabled: true

370
# Checks for flip flops.
371
Style/FlipFlop:
372
  Enabled: true
373

374
# Checks use of for or each in multiline loops.
375
Style/For:
376
  Enabled: true
377

378 379 380 381
# Use a consistent style for format string tokens.
Style/FormatStringToken:
  Enabled: false

Z.J. van de Weg committed
382 383 384
# Checks if there is a magic comment to enforce string literals
Style/FrozenStringLiteralComment:
  Enabled: false
385

386
# Do not introduce global variables.
387
Style/GlobalVars:
388
  Enabled: true
389 390 391
  Exclude:
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
392

393 394
# Prefer Ruby 1.9 hash syntax `{ a: 1, b: 2 }`
# over 1.8 syntax `{ :a => 1, :b => 2 }`.
395
Style/HashSyntax:
396
  Enabled: true
397

398 399 400
# 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:
401
  Enabled: true
402

Douwe Maan committed
403 404 405 406
# Do not use if x; .... Use the ternary operator instead.
Style/IfWithSemicolon:
  Enabled: true

407
# Use Kernel#loop for infinite loops.
408
Style/InfiniteLoop:
409
  Enabled: true
410

411 412 413 414 415
# Use the inverse method instead of `!.method`
# if an inverse method is defined.
Style/InverseMethods:
  Enabled: false

416
# Use lambda.call(...) instead of lambda.(...).
417
Style/LambdaCall:
418
  Enabled: true
419

420
# Checks if the method definitions have or don't have parentheses.
421
Style/MethodDefParentheses:
422
  Enabled: true
423

424
# Use the configured style when naming methods.
425
Style/MethodName:
426
  Enabled: true
427

428 429 430 431
# Checks for usage of `extend self` in modules.
Style/ModuleFunction:
  Enabled: false

432
# Avoid multi-line chains of blocks.
433
Style/MultilineBlockChain:
434
  Enabled: true
435

436
# Do not use then for multi-line if/unless.
437
Style/MultilineIfThen:
438
  Enabled: true
439

440 441 442 443
# Avoid multi-line `? :` (the ternary operator), use if/unless instead.
Style/MultilineTernaryOperator:
  Enabled: true

444 445 446 447 448
# Avoid comparing a variable with multiple items in a conditional,
# use Array#include? instead.
Style/MultipleComparison:
  Enabled: false

Douwe Maan committed
449 450
# This cop checks whether some constant value isn't a
# mutable literal (e.g. array or hash).
451 452
Style/MutableConstant:
  Enabled: true
453 454 455
  Exclude:
    - 'db/migrate/**/*'
    - 'db/post_migrate/**/*'
456

457
# Favor unless over if for negative conditions (or control flow or).
458
Style/NegatedIf:
459
  Enabled: true
460

461 462
# Avoid using nested modifiers.
Style/NestedModifier:
463
  Enabled: true
464 465

# Use one expression per branch in a ternary operator.
466
Style/NestedTernaryOperator:
467
  Enabled: true
468

469
# Prefer x.nil? to x == nil.
470
Style/NilComparison:
471
  Enabled: true
472

473
# Checks for redundant nil checks.
474
Style/NonNilCheck:
475
  Enabled: true
476

477
# Use ! instead of not.
478
Style/Not:
479
  Enabled: true
480

481
# Add underscores to large numeric literals to improve their readability.
482 483 484
Style/NumericLiterals:
  Enabled: false

485
# Favor the ternary operator(?:) over if/then/else/end constructs.
486
Style/OneLineConditional:
487
  Enabled: true
488

489
# When defining binary operators, name the argument other.
490
Style/OpMethod:
491
  Enabled: true
492

493
# Don't use parentheses around the condition of an if/unless/while.
494
Style/ParenthesesAroundCondition:
495
  Enabled: true
496

497 498 499 500 501 502 503
# This cop (by default) checks for uses of methods Hash#has_key? and
# Hash#has_value? where it enforces Hash#key? and Hash#value?
# It is configurable to enforce the inverse, using `verbose` method
# names also.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: short, verbose
Style/PreferredHashMethods:
504
  Enabled: false
505

506 507 508 509
# Checks for an obsolete RuntimeException argument in raise/fail.
Style/RedundantException:
  Enabled: true

510 511
# Checks for parentheses that seem not to serve any purpose.
Style/RedundantParentheses:
512
  Enabled: true
513 514

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

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

523 524
# Check for the usage of parentheses around stabby lambda arguments.
Style/StabbyLambdaParentheses:
525 526
  EnforcedStyle: require_parentheses
  Enabled: true
527 528

# Checks if uses of quotes match the configured preference.
529 530 531
Style/StringLiterals:
  Enabled: false

532 533
# Checks if configured preferred methods are used over non-preferred.
Style/StringMethods:
534 535 536
  PreferredMethods:
    intern: to_sym
  Enabled: true
537

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

Douwe Maan committed
542
# This cop checks for trailing comma in array and hash literals.
543
Style/TrailingCommaInLiteral:
544 545
  Enabled: true
  EnforcedStyleForMultiline: no_comma
546

547 548 549 550 551
# This cop checks for trailing comma in argument lists.
Style/TrailingCommaInArguments:
  Enabled: true
  EnforcedStyleForMultiline: no_comma

552
# Checks for %W when interpolation is not needed.
553
Style/UnneededCapitalW:
554
  Enabled: true
555

556
# Checks for %q/%Q when single quotes or double quotes would do.
557 558 559
Style/UnneededPercentQ:
  Enabled: false

560
# Don't interpolate global, instance and class variables directly in strings.
561
Style/VariableInterpolation:
562
  Enabled: true
563

564
# Use the configured style when naming variables.
565
Style/VariableName:
566 567
  EnforcedStyle: snake_case
  Enabled: true
568

569 570 571 572
# Use the configured style when numbering variables.
Style/VariableNumber:
  Enabled: false

573
# Use when x then ... for one-line cases.
574
Style/WhenThen:
575
  Enabled: true
576

577
# Checks for redundant do after while or until.
578
Style/WhileUntilDo:
579
  Enabled: true
580

581
# Favor modifier while/until usage when you have a single-line body.
582
Style/WhileUntilModifier:
583
  Enabled: true
584

585
# Use %w or %W for arrays of words.
586
Style/WordArray:
Douwe Maan committed
587
  Enabled: true
588

589 590 591 592
# Do not use literals as the first operand of a comparison.
Style/YodaCondition:
  Enabled: false

593 594 595 596
# Use `proc` instead of `Proc.new`.
Style/Proc:
  Enabled: true

597
# Metrics #####################################################################
598

599 600
# A calculated magnitude based on number of assignments,
# branches, and conditions.
601
Metrics/AbcSize:
602
  Enabled: true
603
  Max: 56.96
604

Douwe Maan committed
605
# This cop checks if the length of a block exceeds some maximum value.
Douwe Maan committed
606 607 608
Metrics/BlockLength:
  Enabled: false

609
# Avoid excessive block nesting.
610
Metrics/BlockNesting:
611 612
  Enabled: true
  Max: 4
613

614
# Avoid classes longer than 100 lines of code.
615 616 617
Metrics/ClassLength:
  Enabled: false

618 619 620 621
# A complexity metric that is strongly correlated to the number
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity:
  Enabled: true
622
  Max: 16
623 624

# Limit lines to 80 characters.
625 626 627
Metrics/LineLength:
  Enabled: false

628
# Avoid methods longer than 10 lines of code.
629 630 631
Metrics/MethodLength:
  Enabled: false

632
# Avoid modules longer than 100 lines of code.
633 634 635
Metrics/ModuleLength:
  Enabled: false

636 637 638 639 640 641 642 643
# 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
644
  Max: 18
645

646
# Lint ########################################################################
647

648 649 650 651 652
# Checks for ambiguous block association with method when param passed without
# parentheses.
Lint/AmbiguousBlockAssociation:
  Enabled: false

653 654
# Checks for ambiguous operators in the first argument of a method invocation
# without parentheses.
655
Lint/AmbiguousOperator:
656
  Enabled: true
657

Douwe Maan committed
658 659
# This cop checks for ambiguous regexp literals in the first argument of
# a method invocation without parentheses.
Douwe Maan committed
660 661 662
Lint/AmbiguousRegexpLiteral:
  Enabled: false

Douwe Maan committed
663 664
# This cop checks for assignments in the conditions of
# if/while/until.
Douwe Maan committed
665 666 667
Lint/AssignmentInCondition:
  Enabled: false

668
# Align block ends correctly.
669
Lint/BlockAlignment:
670
  Enabled: true
671

672 673 674
# Default values in optional keyword arguments and optional ordinal arguments
# should not refer back to the name of the argument.
Lint/CircularArgumentReference:
675
  Enabled: true
676 677

# Checks for condition placed in a confusing position relative to the keyword.
678
Lint/ConditionPosition:
679
  Enabled: true
680

681
# Check for debugger calls.
682
Lint/Debugger:
683
  Enabled: true
684

685
# Align ends corresponding to defs correctly.
686
Lint/DefEndAlignment:
687
  Enabled: true
688

689
# Check for deprecated class method calls.
690
Lint/DeprecatedClassMethods:
691
  Enabled: true
692

693 694
# Check for immutable argument given to each_with_object.
Lint/EachWithObjectArgument:
695
  Enabled: true
696 697

# Check for odd code arrangement in an else block.
698
Lint/ElseLayout:
699
  Enabled: true
700

701
# Checks for empty ensure block.
702
Lint/EmptyEnsure:
703
  Enabled: true
704

705 706 707 708
# Checks for the presence of `when` branches without a body.
Lint/EmptyWhen:
  Enabled: true

709
# Align ends correctly.
710
Lint/EndAlignment:
711
  Enabled: true
712

713
# END blocks should not be placed inside method definitions.
714
Lint/EndInMethod:
715
  Enabled: true
716

717
# Do not use return in an ensure block.
718
Lint/EnsureReturn:
719
  Enabled: true
720

721 722
# Catches floating-point literals too large or small for Ruby to represent.
Lint/FloatOutOfRange:
723
  Enabled: true
724 725 726

# The number of parameters to format/sprint must match the fields.
Lint/FormatParameterMismatch:
727
  Enabled: true
728

Douwe Maan committed
729
# This cop checks for *rescue* blocks with no body.
Douwe Maan committed
730 731 732
Lint/HandleExceptions:
  Enabled: false

733 734 735
# Checks for adjacent string literals on the same line, which could better be
# represented as a single string literal.
Lint/ImplicitStringConcatenation:
736
  Enabled: true
737

Douwe Maan committed
738 739 740 741 742
# Checks for attempts to use `private` or `protected` to set the visibility
# of a class method, which does not work.
Lint/IneffectiveAccessModifier:
  Enabled: false

743 744
# Checks for invalid character literals with a non-escaped whitespace
# character.
745
Lint/InvalidCharacterLiteral:
746
  Enabled: true
747

748
# Checks of literals used in conditions.
749
Lint/LiteralInCondition:
750
  Enabled: true
751

752
# Checks for literals used in interpolation.
753
Lint/LiteralInInterpolation:
754
  Enabled: true
755

Douwe Maan committed
756
# This cop checks for uses of *begin...end while/until something*.
Douwe Maan committed
757 758 759
Lint/Loop:
  Enabled: false

760 761
# Do not use nested method definitions.
Lint/NestedMethodDefinition:
762
  Enabled: true
763 764 765

# Do not omit the accumulator when calling `next` in a `reduce`/`inject` block.
Lint/NextWithoutAccumulator:
766
  Enabled: true
767 768

# Checks for method calls with a space before the opening parenthesis.
769
Lint/ParenthesesAsGroupedExpression:
770
  Enabled: true
771

772 773 774
# Checks for `rand(1)` calls. Such calls always return `0` and most likely
# a mistake.
Lint/RandOne:
775
  Enabled: true
776 777

# Use parentheses in the method call to avoid confusion about precedence.
778
Lint/RequireParentheses:
779
  Enabled: true
780

781
# Avoid rescuing the Exception class.
782
Lint/RescueException:
783
  Enabled: true
784

785 786
# Checks for the order which exceptions are rescued to avoid rescueing a less specific exception before a more specific exception.
Lint/ShadowedException:
787 788
  Enabled: false

Douwe Maan committed
789 790
# This cop looks for use of the same name as outer local variables
# for block arguments or block local variables.
Douwe Maan committed
791 792 793
Lint/ShadowingOuterLocalVariable:
  Enabled: false

794 795 796 797
# Checks for Object#to_s usage in string interpolation.
Lint/StringConversionInInterpolation:
  Enabled: true

798
# Do not use prefix `_` for a variable that is used.
799
Lint/UnderscorePrefixedVariableName:
800
  Enabled: true
801

Douwe Maan committed
802
# This cop checks for using Fixnum or Bignum constant
Douwe Maan committed
803 804 805
Lint/UnifiedInteger:
  Enabled: true

806 807 808 809 810 811
# 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

Douwe Maan committed
812
# This cop checks for unneeded usages of splat expansion
Douwe Maan committed
813 814 815
Lint/UnneededSplatExpansion:
  Enabled: false

816
# Unreachable code.
817
Lint/UnreachableCode:
818
  Enabled: true
819

Douwe Maan committed
820
# This cop checks for unused block arguments.
Douwe Maan committed
821 822 823
Lint/UnusedBlockArgument:
  Enabled: false

Douwe Maan committed
824
# This cop checks for unused method arguments.
825 826 827
Lint/UnusedMethodArgument:
  Enabled: false

Douwe Maan committed
828 829 830 831
# Checks for useless access modifiers.
Lint/UselessAccessModifier:
  Enabled: true

832
# Checks for useless assignment to a local variable.
833
Lint/UselessAssignment:
834
  Enabled: true
835

836
# Checks for comparison of something with itself.
837
Lint/UselessComparison:
838
  Enabled: true
839

840
# Checks for useless `else` in `begin..end` without `rescue`.
841
Lint/UselessElseWithoutRescue:
842
  Enabled: true
843

844
# Checks for useless setter call to a local variable.
845
Lint/UselessSetterCall:
846
  Enabled: true
847

848
# Possible use of operator/literal/variable in void context.
849
Lint/Void:
850
  Enabled: true
851

852
# Performance #################################################################
853

854 855 856 857
# Use `caller(n..n)` instead of `caller`.
Performance/Caller:
  Enabled: false

858 859
# Use `casecmp` rather than `downcase ==`.
Performance/Casecmp:
860
  Enabled: true
861 862 863 864

# Use `str.{start,end}_with?(x, ..., y, ...)` instead of
# `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
Performance/DoubleStartEndWith:
865
  Enabled: true
866 867 868

# Use `strip` instead of `lstrip.rstrip`.
Performance/LstripRstrip:
Connor Shea committed
869
  Enabled: true
870 871 872

# Use `Range#cover?` instead of `Range#include?`.
Performance/RangeInclude:
873
  Enabled: true
874

Douwe Maan committed
875 876
# This cop identifies the use of a `&block` parameter and `block.call`
# where `yield` would do just as well.
Douwe Maan committed
877 878 879
Performance/RedundantBlockCall:
  Enabled: true

Douwe Maan committed
880 881
# This cop identifies use of `Regexp#match` or `String#match in a context
# where the integral return value of `=~` would do just as well.
Douwe Maan committed
882 883 884
Performance/RedundantMatch:
  Enabled: true

Douwe Maan committed
885 886
# This cop identifies places where `Hash#merge!` can be replaced by
# `Hash#[]=`.
Douwe Maan committed
887 888 889 890
Performance/RedundantMerge:
  Enabled: true
  MaxKeyValuePairs: 1

891 892
# Use `sort` instead of `sort_by { |x| x }`.
Performance/RedundantSortBy:
893
  Enabled: true
894 895 896 897

# Use `start_with?` instead of a regex match anchored to the beginning of a
# string.
Performance/StartWith:
898
  Enabled: true
899

900 901 902 903
# 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:
904
  Enabled: true
905 906 907

# Checks for `.times.map` calls.
Performance/TimesMap:
908
  Enabled: true
909

Douwe Maan committed
910 911
# Security ####################################################################

Douwe Maan committed
912 913
# This cop checks for the use of JSON class methods which have potential
# security issues.
Douwe Maan committed
914 915 916
Security/JSONLoad:
  Enabled: true

917 918 919 920
# This cop checks for the use of *Kernel#eval*.
Security/Eval:
  Enabled: true

921
# Rails #######################################################################
922

923 924 925 926 927
# Enables Rails cops.
Rails:
  Enabled: true

# Enforces consistent use of action filter methods.
928
Rails/ActionFilter:
929
  Enabled: true
930
  EnforcedStyle: action
931

932 933 934 935 936 937 938 939
# Check that models subclass ApplicationRecord.
Rails/ApplicationRecord:
  Enabled: false

# Enforce using `blank?` and `present?`.
Rails/Blank:
  Enabled: false

940 941
# Checks the correct usage of date aware methods, such as `Date.today`,
# `Date.current`, etc.
942 943 944
Rails/Date:
  Enabled: false

945
# Prefer delegate method for delegations.
946
# Disabled per https://gitlab.com/gitlab-org/gitlab-ce/issues/35869
947
Rails/Delegate:
948
  Enabled: false
949

Douwe Maan committed
950
# This cop checks dynamic `find_by_*` methods.
Douwe Maan committed
951 952 953
Rails/DynamicFindBy:
  Enabled: false

Douwe Maan committed
954
# This cop enforces that 'exit' calls are not used within a rails app.
Douwe Maan committed
955 956 957 958 959 960
Rails/Exit:
  Enabled: true
  Exclude:
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'

961 962
# Prefer `find_by` over `where.first`.
Rails/FindBy:
963
  Enabled: true
964 965 966

# Prefer `all.find_each` over `all.find`.
Rails/FindEach:
967
  Enabled: true
968

969
# Prefer has_many :through to has_and_belongs_to_many.
970
Rails/HasAndBelongsToMany:
971
  Enabled: true
972

Douwe Maan committed
973 974 975
# This cop is used to identify usages of http methods like `get`, `post`,
# `put`, `patch` without the usage of keyword arguments in your tests and
# change them to use keyword args.
Douwe Maan committed
976 977 978
Rails/HttpPositionalArguments:
  Enabled: false

979
# Checks for calls to puts, print, etc.
980
Rails/Output:
981
  Enabled: true
982 983 984 985 986
  Exclude:
    - lib/gitlab/seeder.rb
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
987

Douwe Maan committed
988 989
# This cop checks for the use of output safety calls like html_safe and
# raw.
Douwe Maan committed
990 991 992
Rails/OutputSafety:
  Enabled: false

993 994
# Checks for incorrect grammar when using methods like `3.day.ago`.
Rails/PluralizationGrammar:
995
  Enabled: true
996

997 998 999 1000
# Enforce using `blank?` and `present?`.
Rails/Present:
  Enabled: false

1001
# Checks for `read_attribute(:attr)` and `write_attribute(:attr, val)`.
1002 1003 1004
Rails/ReadWriteAttribute:
  Enabled: false

1005 1006 1007 1008
# Do not assign relative date to constants.
Rails/RelativeDateConstant:
  Enabled: false

1009
# Checks the arguments of ActiveRecord scopes.
1010
Rails/ScopeArgs:
1011
  Enabled: true
1012

Douwe Maan committed
1013
# This cop checks for the use of Time methods without zone.
Douwe Maan committed
1014 1015 1016
Rails/TimeZone:
  Enabled: false

Douwe Maan committed
1017
# This cop checks for the use of old-style attribute validation macros.
Douwe Maan committed
1018 1019 1020
Rails/Validation:
  Enabled: true

1021
# RSpec #######################################################################
Robert Speicher committed
1022

1023
# Check that instances are not being stubbed globally.
Robert Speicher committed
1024 1025 1026
RSpec/AnyInstance:
  Enabled: false

1027 1028
# Check for expectations where `be(...)` can replace `eql(...)`.
RSpec/BeEql:
1029
  Enabled: true
1030

1031 1032 1033 1034
# We don't enforce this as we use this technique in a few places.
RSpec/BeforeAfterAll:
  Enabled: false

1035 1036
# Check that the first argument to the top level describe is the tested class or
# module.
Robert Speicher committed
1037 1038 1039
RSpec/DescribeClass:
  Enabled: false

1040
# Use `described_class` for tested class / module.
Robert Speicher committed
1041 1042 1043
RSpec/DescribeMethod:
  Enabled: false

1044 1045 1046 1047
# Avoid describing symbols.
RSpec/DescribeSymbol:
  Enabled: true

1048 1049 1050
# Checks that the second argument to top level describe is the tested method
# name.
RSpec/DescribedClass:
1051
  Enabled: true
Robert Speicher committed
1052

1053
# Checks if an example group does not include any tests.
1054 1055 1056 1057 1058
RSpec/EmptyExampleGroup:
  Enabled: true
  CustomIncludeMethods:
    - run_permission_checks

1059
# Checks for long example.
Robert Speicher committed
1060 1061 1062 1063
RSpec/ExampleLength:
  Enabled: false
  Max: 5

1064
# Do not use should when describing your tests.
Robert Speicher committed
1065 1066 1067 1068 1069 1070 1071 1072
RSpec/ExampleWording:
  Enabled: false
  CustomTransform:
    be: is
    have: has
    not: does not
  IgnoredWords: []

1073 1074 1075 1076
# Checks for `expect(...)` calls containing literal values.
RSpec/ExpectActual:
  Enabled: true

1077
# Checks for opportunities to use `expect { … }.to output`.
1078 1079 1080
RSpec/ExpectOutput:
  Enabled: true

1081
# Checks the file and folder naming of the spec file.
Robert Speicher committed
1082
RSpec/FilePath:
1083 1084 1085 1086 1087 1088
  Enabled: true
  IgnoreMethods: true
  Exclude:
    - 'qa/**/*'
    - 'spec/javascripts/fixtures/*'
    - 'spec/requests/api/v3/*'
Robert Speicher committed
1089

1090
# Checks if there are focused specs.
Robert Speicher committed
1091 1092 1093
RSpec/Focus:
  Enabled: true

1094 1095 1096 1097 1098 1099
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: is_expected, should
RSpec/ImplicitExpect:
  Enabled: true
  EnforcedStyle: is_expected

1100
# Checks for the usage of instance variables.
Robert Speicher committed
1101 1102 1103
RSpec/InstanceVariable:
  Enabled: false

Douwe Maan committed
1104
# Checks for `subject` definitions that come after `let` definitions.
Douwe Maan committed
1105 1106 1107
RSpec/LeadingSubject:
  Enabled: false

Douwe Maan committed
1108
# Checks unreferenced `let!` calls being used for test setup.
Douwe Maan committed
1109 1110 1111
RSpec/LetSetup:
  Enabled: false

Douwe Maan committed
1112
# Check that chains of messages are not being stubbed.
Douwe Maan committed
1113 1114 1115
RSpec/MessageChain:
  Enabled: false

Douwe Maan committed
1116
# Checks that message expectations are set using spies.
Douwe Maan committed
1117 1118 1119
RSpec/MessageSpies:
  Enabled: false

Douwe Maan committed
1120 1121
# Checks for multiple top-level describes.
RSpec/MultipleDescribes:
Douwe Maan committed
1122 1123
  Enabled: false

Douwe Maan committed
1124
# Checks if examples contain too many `expect` calls.
Douwe Maan committed
1125
RSpec/MultipleExpectations:
1126 1127
  Enabled: false

Douwe Maan committed
1128
# Checks for explicitly referenced test subjects.
Douwe Maan committed
1129
RSpec/NamedSubject:
Douwe Maan committed
1130 1131
  Enabled: false

Douwe Maan committed
1132
# Checks for nested example groups.
Douwe Maan committed
1133
RSpec/NestedGroups:
Douwe Maan committed
1134 1135
  Enabled: false

Douwe Maan committed
1136 1137 1138
# Enforces the usage of the same method on all negative message expectations.
RSpec/NotToNot:
  EnforcedStyle: not_to
1139
  Enabled: true
1140

Douwe Maan committed
1141
# Check for repeated description strings in example groups.
Douwe Maan committed
1142
RSpec/RepeatedDescription:
Douwe Maan committed
1143 1144
  Enabled: false

1145 1146
# Ensure RSpec hook blocks are always multi-line.
RSpec/SingleLineHook:
1147
  Enabled: true
1148 1149 1150 1151
  Exclude:
    - 'spec/factories/*'
    - 'spec/requests/api/v3/*'

Douwe Maan committed
1152
# Checks for stubbed test subjects.
Douwe Maan committed
1153
RSpec/SubjectStub:
Douwe Maan committed
1154 1155
  Enabled: false

Douwe Maan committed
1156 1157
# Prefer using verifying doubles over normal doubles.
RSpec/VerifiedDoubles:
Douwe Maan committed
1158
  Enabled: false