BigW Consortium Gitlab

.rubocop.yml 29.1 KB
Newer Older
1 2
require:
  - rubocop-rspec
3
  - rubocop-gitlab-security
4
  - ./rubocop/rubocop
Robert Speicher committed
5

6 7
inherit_from: .rubocop_todo.yml

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

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

34
# Layout ######################################################################
35 36

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

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

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

Douwe Maan committed
48 49
# Here we check if the parameters on a multi-line method call or
# definition are aligned.
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
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

210 211 212 213 214 215 216
# Checks that block braces have or don't have a space before the opening
# brace depending on configuration.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Layout/SpaceBeforeBlockBraces:
  Enabled: true

217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
# 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

254 255 256 257
# Avoid trailing whitespace.
Layout/TrailingWhitespace:
  Enabled: true

258 259 260 261
# Style #######################################################################

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

264 265 266 267 268
# Use alias_method instead of alias.
Style/Alias:
  EnforcedStyle: prefer_alias_method
  Enabled: true

Douwe Maan committed
269 270 271 272 273
# Whether `and` and `or` are banned only in conditionals (conditionals)
# or completely (always).
Style/AndOr:
  Enabled: true

274
# Use `Array#join` instead of `Array#*`.
275
Style/ArrayJoin:
276
  Enabled: true
277

278
# Use only ascii symbols in comments.
279
Style/AsciiComments:
280
  Enabled: true
281

282
# Use only ascii symbols in identifiers.
283
Style/AsciiIdentifiers:
284
  Enabled: true
285

286
# Checks for uses of Module#attr.
287
Style/Attr:
288
  Enabled: true
289

290
# Avoid the use of BEGIN blocks.
291
Style/BeginBlock:
292
  Enabled: true
293

294
# Do not use block comments.
295
Style/BlockComments:
296
  Enabled: true
297

298 299
# Avoid using {...} for multi-line blocks (multiline chaining is # always
# ugly). Prefer {...} over do...end for single-line blocks.
300
Style/BlockDelimiters:
301
  Enabled: true
302

Douwe Maan committed
303 304
 # This cop checks for braces around the last parameter in a method call
# if the last parameter is a hash.
Douwe Maan committed
305 306 307
Style/BracesAroundHashParameters:
  Enabled: false

Douwe Maan committed
308
# This cop checks for uses of the case equality operator(===).
Douwe Maan committed
309 310 311
Style/CaseEquality:
  Enabled: false

312
# Checks for uses of character literals.
313
Style/CharacterLiteral:
314
  Enabled: true
315

316
# Use CamelCase for classes and modules.'
317
Style/ClassAndModuleCamelCase:
318
  Enabled: true
319

320
# Checks style of children classes and modules.
321 322 323
Style/ClassAndModuleChildren:
  Enabled: false

324
# Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.
325
Style/ClassCheck:
Douwe Maan committed
326
  Enabled: true
327

328
# Use self when defining module/class methods.
329
Style/ClassMethods:
330
  Enabled: true
331

332
# Avoid the use of class variables.
333
Style/ClassVars:
334
  Enabled: true
335

Douwe Maan committed
336 337
# This cop checks for methods invoked via the :: operator instead
# of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).
Douwe Maan committed
338 339 340
Style/ColonMethodCall:
  Enabled: true

Douwe Maan committed
341 342
# This cop checks that comment annotation keywords are written according
# to guidelines.
Douwe Maan committed
343 344 345
Style/CommentAnnotation:
  Enabled: false

Douwe Maan committed
346 347 348
# 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
349 350 351
Style/ConditionalAssignment:
  Enabled: true

352
# Constants should use SCREAMING_SNAKE_CASE.
353
Style/ConstantName:
354
  Enabled: true
355

356
# Use def with parentheses when there are arguments.
357
Style/DefWithParentheses:
358
  Enabled: true
359

360
# Document classes and non-namespace modules.
361 362 363
Style/Documentation:
  Enabled: false

Douwe Maan committed
364 365 366
# 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
367 368 369
Style/DoubleNegation:
  Enabled: false

370
# Avoid the use of END blocks.
371
Style/EndBlock:
372
  Enabled: true
373

374
# Favor the use of Fixnum#even? && Fixnum#odd?
375
Style/EvenOdd:
376
  Enabled: true
377

378
# Use snake_case for source file names.
379
Style/FileName:
380 381
  Enabled: true

382
# Checks for flip flops.
383
Style/FlipFlop:
384
  Enabled: true
385

386
# Checks use of for or each in multiline loops.
387
Style/For:
388
  Enabled: true
389

390 391 392 393
# Use a consistent style for format string tokens.
Style/FormatStringToken:
  Enabled: false

Z.J. van de Weg committed
394 395 396
# Checks if there is a magic comment to enforce string literals
Style/FrozenStringLiteralComment:
  Enabled: false
397

398
# Do not introduce global variables.
399
Style/GlobalVars:
400
  Enabled: true
401 402 403
  Exclude:
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
404

405 406
# Prefer Ruby 1.9 hash syntax `{ a: 1, b: 2 }`
# over 1.8 syntax `{ :a => 1, :b => 2 }`.
407
Style/HashSyntax:
408
  Enabled: true
409

410 411 412
# 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:
413
  Enabled: true
414

Douwe Maan committed
415 416 417 418
# Do not use if x; .... Use the ternary operator instead.
Style/IfWithSemicolon:
  Enabled: true

419
# Use Kernel#loop for infinite loops.
420
Style/InfiniteLoop:
421
  Enabled: true
422

423 424 425 426 427
# Use the inverse method instead of `!.method`
# if an inverse method is defined.
Style/InverseMethods:
  Enabled: false

428
# Use lambda.call(...) instead of lambda.(...).
429
Style/LambdaCall:
430
  Enabled: true
431

432
# Checks if the method definitions have or don't have parentheses.
433
Style/MethodDefParentheses:
434
  Enabled: true
435

436
# Use the configured style when naming methods.
437
Style/MethodName:
438
  Enabled: true
439

440 441 442 443
# Checks for usage of `extend self` in modules.
Style/ModuleFunction:
  Enabled: false

444
# Avoid multi-line chains of blocks.
445
Style/MultilineBlockChain:
446
  Enabled: true
447

448
# Do not use then for multi-line if/unless.
449
Style/MultilineIfThen:
450
  Enabled: true
451

452 453 454 455
# Avoid multi-line `? :` (the ternary operator), use if/unless instead.
Style/MultilineTernaryOperator:
  Enabled: true

456 457 458 459 460
# Avoid comparing a variable with multiple items in a conditional,
# use Array#include? instead.
Style/MultipleComparison:
  Enabled: false

Douwe Maan committed
461 462
# This cop checks whether some constant value isn't a
# mutable literal (e.g. array or hash).
463 464
Style/MutableConstant:
  Enabled: true
465 466 467
  Exclude:
    - 'db/migrate/**/*'
    - 'db/post_migrate/**/*'
468

469
# Favor unless over if for negative conditions (or control flow or).
470
Style/NegatedIf:
471
  Enabled: true
472

473 474
# Avoid using nested modifiers.
Style/NestedModifier:
475
  Enabled: true
476 477

# Use one expression per branch in a ternary operator.
478
Style/NestedTernaryOperator:
479
  Enabled: true
480

481
# Prefer x.nil? to x == nil.
482
Style/NilComparison:
483
  Enabled: true
484

485
# Checks for redundant nil checks.
486
Style/NonNilCheck:
487
  Enabled: true
488

489
# Use ! instead of not.
490
Style/Not:
491
  Enabled: true
492

493
# Add underscores to large numeric literals to improve their readability.
494 495 496
Style/NumericLiterals:
  Enabled: false

497
# Favor the ternary operator(?:) over if/then/else/end constructs.
498
Style/OneLineConditional:
499
  Enabled: true
500

501
# When defining binary operators, name the argument other.
502
Style/OpMethod:
503
  Enabled: true
504

505
# Don't use parentheses around the condition of an if/unless/while.
506
Style/ParenthesesAroundCondition:
507
  Enabled: true
508

509 510 511 512 513 514 515
# 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:
516
  Enabled: false
517

518 519 520 521
# Checks for an obsolete RuntimeException argument in raise/fail.
Style/RedundantException:
  Enabled: true

522 523
# Checks for parentheses that seem not to serve any purpose.
Style/RedundantParentheses:
524
  Enabled: true
525 526

# Don't use semicolons to terminate expressions.
527
Style/Semicolon:
528
  Enabled: true
529

530
# Checks for proper usage of fail and raise.
531
Style/SignalException:
532 533
  EnforcedStyle: only_raise
  Enabled: true
534

535 536
# Check for the usage of parentheses around stabby lambda arguments.
Style/StabbyLambdaParentheses:
537 538
  EnforcedStyle: require_parentheses
  Enabled: true
539 540

# Checks if uses of quotes match the configured preference.
541 542 543
Style/StringLiterals:
  Enabled: false

544 545
# Checks if configured preferred methods are used over non-preferred.
Style/StringMethods:
546 547 548
  PreferredMethods:
    intern: to_sym
  Enabled: true
549

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

Douwe Maan committed
554
# This cop checks for trailing comma in array and hash literals.
555
Style/TrailingCommaInLiteral:
556 557
  Enabled: true
  EnforcedStyleForMultiline: no_comma
558

559 560 561 562 563
# This cop checks for trailing comma in argument lists.
Style/TrailingCommaInArguments:
  Enabled: true
  EnforcedStyleForMultiline: no_comma

564
# Checks for %W when interpolation is not needed.
565
Style/UnneededCapitalW:
566
  Enabled: true
567

568
# Checks for %q/%Q when single quotes or double quotes would do.
569 570 571
Style/UnneededPercentQ:
  Enabled: false

572
# Don't interpolate global, instance and class variables directly in strings.
573
Style/VariableInterpolation:
574
  Enabled: true
575

576
# Use the configured style when naming variables.
577
Style/VariableName:
578 579
  EnforcedStyle: snake_case
  Enabled: true
580

581 582 583 584
# Use the configured style when numbering variables.
Style/VariableNumber:
  Enabled: false

585
# Use when x then ... for one-line cases.
586
Style/WhenThen:
587
  Enabled: true
588

589
# Checks for redundant do after while or until.
590
Style/WhileUntilDo:
591
  Enabled: true
592

593
# Favor modifier while/until usage when you have a single-line body.
594
Style/WhileUntilModifier:
595
  Enabled: true
596

597
# Use %w or %W for arrays of words.
598
Style/WordArray:
Douwe Maan committed
599
  Enabled: true
600

601 602 603 604
# Do not use literals as the first operand of a comparison.
Style/YodaCondition:
  Enabled: false

605 606 607 608
# Use `proc` instead of `Proc.new`.
Style/Proc:
  Enabled: true

609
# Metrics #####################################################################
610

611 612
# A calculated magnitude based on number of assignments,
# branches, and conditions.
613
Metrics/AbcSize:
614
  Enabled: true
615
  Max: 56.96
616

Douwe Maan committed
617
# This cop checks if the length of a block exceeds some maximum value.
Douwe Maan committed
618 619 620
Metrics/BlockLength:
  Enabled: false

621
# Avoid excessive block nesting.
622
Metrics/BlockNesting:
623 624
  Enabled: true
  Max: 4
625

626
# Avoid classes longer than 100 lines of code.
627 628 629
Metrics/ClassLength:
  Enabled: false

630 631 632 633
# A complexity metric that is strongly correlated to the number
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity:
  Enabled: true
634
  Max: 16
635 636

# Limit lines to 80 characters.
637 638 639
Metrics/LineLength:
  Enabled: false

640
# Avoid methods longer than 10 lines of code.
641 642 643
Metrics/MethodLength:
  Enabled: false

644
# Avoid modules longer than 100 lines of code.
645 646 647
Metrics/ModuleLength:
  Enabled: false

648 649 650 651 652 653 654 655
# 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
656
  Max: 18
657

658
# Lint ########################################################################
659

660 661 662 663 664
# Checks for ambiguous block association with method when param passed without
# parentheses.
Lint/AmbiguousBlockAssociation:
  Enabled: false

665 666
# Checks for ambiguous operators in the first argument of a method invocation
# without parentheses.
667
Lint/AmbiguousOperator:
668
  Enabled: true
669

Douwe Maan committed
670 671
# This cop checks for ambiguous regexp literals in the first argument of
# a method invocation without parentheses.
Douwe Maan committed
672 673 674
Lint/AmbiguousRegexpLiteral:
  Enabled: false

Douwe Maan committed
675 676
# This cop checks for assignments in the conditions of
# if/while/until.
Douwe Maan committed
677 678 679
Lint/AssignmentInCondition:
  Enabled: false

680
# Align block ends correctly.
681
Lint/BlockAlignment:
682
  Enabled: true
683

684 685 686
# Default values in optional keyword arguments and optional ordinal arguments
# should not refer back to the name of the argument.
Lint/CircularArgumentReference:
687
  Enabled: true
688 689

# Checks for condition placed in a confusing position relative to the keyword.
690
Lint/ConditionPosition:
691
  Enabled: true
692

693
# Check for debugger calls.
694
Lint/Debugger:
695
  Enabled: true
696

697
# Align ends corresponding to defs correctly.
698
Lint/DefEndAlignment:
699
  Enabled: true
700

701
# Check for deprecated class method calls.
702
Lint/DeprecatedClassMethods:
703
  Enabled: true
704

705 706
# Check for immutable argument given to each_with_object.
Lint/EachWithObjectArgument:
707
  Enabled: true
708 709

# Check for odd code arrangement in an else block.
710
Lint/ElseLayout:
711
  Enabled: true
712

713
# Checks for empty ensure block.
714
Lint/EmptyEnsure:
715
  Enabled: true
716

717 718 719 720
# Checks for the presence of `when` branches without a body.
Lint/EmptyWhen:
  Enabled: true

721
# Align ends correctly.
722
Lint/EndAlignment:
723
  Enabled: true
724

725
# END blocks should not be placed inside method definitions.
726
Lint/EndInMethod:
727
  Enabled: true
728

729
# Do not use return in an ensure block.
730
Lint/EnsureReturn:
731
  Enabled: true
732

733 734
# Catches floating-point literals too large or small for Ruby to represent.
Lint/FloatOutOfRange:
735
  Enabled: true
736 737 738

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

Douwe Maan committed
741
# This cop checks for *rescue* blocks with no body.
Douwe Maan committed
742 743 744
Lint/HandleExceptions:
  Enabled: false

745 746 747
# Checks for adjacent string literals on the same line, which could better be
# represented as a single string literal.
Lint/ImplicitStringConcatenation:
748
  Enabled: true
749

Douwe Maan committed
750 751 752 753 754
# Checks for attempts to use `private` or `protected` to set the visibility
# of a class method, which does not work.
Lint/IneffectiveAccessModifier:
  Enabled: false

755 756
# Checks for invalid character literals with a non-escaped whitespace
# character.
757
Lint/InvalidCharacterLiteral:
758
  Enabled: true
759

760
# Checks of literals used in conditions.
761
Lint/LiteralInCondition:
762
  Enabled: true
763

764
# Checks for literals used in interpolation.
765
Lint/LiteralInInterpolation:
766
  Enabled: true
767

Douwe Maan committed
768
# This cop checks for uses of *begin...end while/until something*.
Douwe Maan committed
769 770 771
Lint/Loop:
  Enabled: false

772 773
# Do not use nested method definitions.
Lint/NestedMethodDefinition:
774
  Enabled: true
775 776 777

# Do not omit the accumulator when calling `next` in a `reduce`/`inject` block.
Lint/NextWithoutAccumulator:
778
  Enabled: true
779 780

# Checks for method calls with a space before the opening parenthesis.
781
Lint/ParenthesesAsGroupedExpression:
782
  Enabled: true
783

784 785 786
# Checks for `rand(1)` calls. Such calls always return `0` and most likely
# a mistake.
Lint/RandOne:
787
  Enabled: true
788 789

# Use parentheses in the method call to avoid confusion about precedence.
790
Lint/RequireParentheses:
791
  Enabled: true
792

793
# Avoid rescuing the Exception class.
794
Lint/RescueException:
795
  Enabled: true
796

797 798
# Checks for the order which exceptions are rescued to avoid rescueing a less specific exception before a more specific exception.
Lint/ShadowedException:
799 800
  Enabled: false

Douwe Maan committed
801 802
# This cop looks for use of the same name as outer local variables
# for block arguments or block local variables.
Douwe Maan committed
803 804 805
Lint/ShadowingOuterLocalVariable:
  Enabled: false

806 807 808 809
# Checks for Object#to_s usage in string interpolation.
Lint/StringConversionInInterpolation:
  Enabled: true

810
# Do not use prefix `_` for a variable that is used.
811
Lint/UnderscorePrefixedVariableName:
812
  Enabled: true
813

Douwe Maan committed
814
# This cop checks for using Fixnum or Bignum constant
Douwe Maan committed
815 816 817
Lint/UnifiedInteger:
  Enabled: true

818 819 820 821 822 823
# 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
824
# This cop checks for unneeded usages of splat expansion
Douwe Maan committed
825 826 827
Lint/UnneededSplatExpansion:
  Enabled: false

828
# Unreachable code.
829
Lint/UnreachableCode:
830
  Enabled: true
831

Douwe Maan committed
832
# This cop checks for unused block arguments.
Douwe Maan committed
833 834 835
Lint/UnusedBlockArgument:
  Enabled: false

Douwe Maan committed
836
# This cop checks for unused method arguments.
837 838 839
Lint/UnusedMethodArgument:
  Enabled: false

Douwe Maan committed
840 841 842 843
# Checks for useless access modifiers.
Lint/UselessAccessModifier:
  Enabled: true

844
# Checks for useless assignment to a local variable.
845
Lint/UselessAssignment:
846
  Enabled: true
847

848
# Checks for comparison of something with itself.
849
Lint/UselessComparison:
850
  Enabled: true
851

852
# Checks for useless `else` in `begin..end` without `rescue`.
853
Lint/UselessElseWithoutRescue:
854
  Enabled: true
855

856
# Checks for useless setter call to a local variable.
857
Lint/UselessSetterCall:
858
  Enabled: true
859

860
# Possible use of operator/literal/variable in void context.
861
Lint/Void:
862
  Enabled: true
863

864
# Performance #################################################################
865

866 867 868 869
# Use `caller(n..n)` instead of `caller`.
Performance/Caller:
  Enabled: false

870 871
# Use `casecmp` rather than `downcase ==`.
Performance/Casecmp:
872
  Enabled: true
873 874 875 876

# Use `str.{start,end}_with?(x, ..., y, ...)` instead of
# `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
Performance/DoubleStartEndWith:
877
  Enabled: true
878 879 880

# Use `strip` instead of `lstrip.rstrip`.
Performance/LstripRstrip:
Connor Shea committed
881
  Enabled: true
882 883 884

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

Douwe Maan committed
887 888
# This cop identifies the use of a `&block` parameter and `block.call`
# where `yield` would do just as well.
Douwe Maan committed
889 890 891
Performance/RedundantBlockCall:
  Enabled: true

Douwe Maan committed
892 893
# 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
894 895 896
Performance/RedundantMatch:
  Enabled: true

Douwe Maan committed
897 898
# This cop identifies places where `Hash#merge!` can be replaced by
# `Hash#[]=`.
Douwe Maan committed
899 900 901 902
Performance/RedundantMerge:
  Enabled: true
  MaxKeyValuePairs: 1

903 904
# Use `sort` instead of `sort_by { |x| x }`.
Performance/RedundantSortBy:
905
  Enabled: true
906 907 908 909

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

912 913 914 915
# 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:
916
  Enabled: true
917 918 919

# Checks for `.times.map` calls.
Performance/TimesMap:
920
  Enabled: true
921

Douwe Maan committed
922 923
# Security ####################################################################

Douwe Maan committed
924 925
# This cop checks for the use of JSON class methods which have potential
# security issues.
Douwe Maan committed
926 927 928
Security/JSONLoad:
  Enabled: true

929 930 931 932
# This cop checks for the use of *Kernel#eval*.
Security/Eval:
  Enabled: true

933
# Rails #######################################################################
934

935 936 937 938 939
# Enables Rails cops.
Rails:
  Enabled: true

# Enforces consistent use of action filter methods.
940
Rails/ActionFilter:
941
  Enabled: true
942
  EnforcedStyle: action
943

944 945 946 947 948 949 950 951
# Check that models subclass ApplicationRecord.
Rails/ApplicationRecord:
  Enabled: false

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

952 953
# Checks the correct usage of date aware methods, such as `Date.today`,
# `Date.current`, etc.
954 955 956
Rails/Date:
  Enabled: false

957
# Prefer delegate method for delegations.
958
# Disabled per https://gitlab.com/gitlab-org/gitlab-ce/issues/35869
959
Rails/Delegate:
960
  Enabled: false
961

Douwe Maan committed
962
# This cop checks dynamic `find_by_*` methods.
Douwe Maan committed
963 964 965
Rails/DynamicFindBy:
  Enabled: false

Douwe Maan committed
966
# This cop enforces that 'exit' calls are not used within a rails app.
Douwe Maan committed
967 968 969 970 971 972
Rails/Exit:
  Enabled: true
  Exclude:
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'

973 974
# Prefer `find_by` over `where.first`.
Rails/FindBy:
975
  Enabled: true
976 977 978

# Prefer `all.find_each` over `all.find`.
Rails/FindEach:
979
  Enabled: true
980

981
# Prefer has_many :through to has_and_belongs_to_many.
982
Rails/HasAndBelongsToMany:
983
  Enabled: true
984

Douwe Maan committed
985 986 987
# 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
988 989 990
Rails/HttpPositionalArguments:
  Enabled: false

991
# Checks for calls to puts, print, etc.
992
Rails/Output:
993
  Enabled: true
994 995 996 997 998
  Exclude:
    - lib/gitlab/seeder.rb
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
999

Douwe Maan committed
1000 1001
# This cop checks for the use of output safety calls like html_safe and
# raw.
Douwe Maan committed
1002 1003 1004
Rails/OutputSafety:
  Enabled: false

1005 1006
# Checks for incorrect grammar when using methods like `3.day.ago`.
Rails/PluralizationGrammar:
1007
  Enabled: true
1008

1009 1010 1011 1012
# Enforce using `blank?` and `present?`.
Rails/Present:
  Enabled: false

1013
# Checks for `read_attribute(:attr)` and `write_attribute(:attr, val)`.
1014 1015 1016
Rails/ReadWriteAttribute:
  Enabled: false

1017 1018 1019 1020
# Do not assign relative date to constants.
Rails/RelativeDateConstant:
  Enabled: false

1021
# Checks the arguments of ActiveRecord scopes.
1022
Rails/ScopeArgs:
1023
  Enabled: true
1024

Douwe Maan committed
1025
# This cop checks for the use of Time methods without zone.
Douwe Maan committed
1026 1027 1028
Rails/TimeZone:
  Enabled: false

Douwe Maan committed
1029
# This cop checks for the use of old-style attribute validation macros.
Douwe Maan committed
1030 1031 1032
Rails/Validation:
  Enabled: true

1033
# RSpec #######################################################################
Robert Speicher committed
1034

1035
# Check that instances are not being stubbed globally.
Robert Speicher committed
1036 1037 1038
RSpec/AnyInstance:
  Enabled: false

1039 1040
# Check for expectations where `be(...)` can replace `eql(...)`.
RSpec/BeEql:
1041
  Enabled: true
1042

1043 1044 1045 1046
# We don't enforce this as we use this technique in a few places.
RSpec/BeforeAfterAll:
  Enabled: false

1047 1048
# Check that the first argument to the top level describe is the tested class or
# module.
Robert Speicher committed
1049 1050 1051
RSpec/DescribeClass:
  Enabled: false

Rémy Coutable committed
1052
# Checks that the second argument to `describe` specifies a method.
Robert Speicher committed
1053 1054 1055
RSpec/DescribeMethod:
  Enabled: false

1056 1057 1058 1059
# Avoid describing symbols.
RSpec/DescribeSymbol:
  Enabled: true

Rémy Coutable committed
1060
# Checks that tests use `described_class`.
1061
RSpec/DescribedClass:
1062
  Enabled: true
Robert Speicher committed
1063

1064
# Checks if an example group does not include any tests.
1065 1066 1067 1068 1069
RSpec/EmptyExampleGroup:
  Enabled: true
  CustomIncludeMethods:
    - run_permission_checks

1070
# Checks for long example.
Robert Speicher committed
1071 1072 1073 1074
RSpec/ExampleLength:
  Enabled: false
  Max: 5

1075
# Do not use should when describing your tests.
Robert Speicher committed
1076 1077 1078 1079 1080 1081 1082 1083
RSpec/ExampleWording:
  Enabled: false
  CustomTransform:
    be: is
    have: has
    not: does not
  IgnoredWords: []

1084 1085 1086 1087
# Checks for `expect(...)` calls containing literal values.
RSpec/ExpectActual:
  Enabled: true

1088
# Checks for opportunities to use `expect { … }.to output`.
1089 1090 1091
RSpec/ExpectOutput:
  Enabled: true

1092
# Checks the file and folder naming of the spec file.
Robert Speicher committed
1093
RSpec/FilePath:
1094 1095 1096 1097 1098 1099
  Enabled: true
  IgnoreMethods: true
  Exclude:
    - 'qa/**/*'
    - 'spec/javascripts/fixtures/*'
    - 'spec/requests/api/v3/*'
Robert Speicher committed
1100

1101
# Checks if there are focused specs.
Robert Speicher committed
1102 1103 1104
RSpec/Focus:
  Enabled: true

1105 1106 1107 1108 1109
# Checks the arguments passed to `before`, `around`, and `after`.
RSpec/HookArgument:
  Enabled: true
  EnforcedStyle: implicit

1110 1111 1112 1113 1114 1115
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: is_expected, should
RSpec/ImplicitExpect:
  Enabled: true
  EnforcedStyle: is_expected

1116
# Checks for the usage of instance variables.
Robert Speicher committed
1117 1118 1119
RSpec/InstanceVariable:
  Enabled: false

Douwe Maan committed
1120
# Checks for `subject` definitions that come after `let` definitions.
Douwe Maan committed
1121 1122 1123
RSpec/LeadingSubject:
  Enabled: false

Douwe Maan committed
1124
# Checks unreferenced `let!` calls being used for test setup.
Douwe Maan committed
1125 1126 1127
RSpec/LetSetup:
  Enabled: false

Douwe Maan committed
1128
# Check that chains of messages are not being stubbed.
Douwe Maan committed
1129 1130 1131
RSpec/MessageChain:
  Enabled: false

Douwe Maan committed
1132
# Checks that message expectations are set using spies.
Douwe Maan committed
1133 1134 1135
RSpec/MessageSpies:
  Enabled: false

Douwe Maan committed
1136 1137
# Checks for multiple top-level describes.
RSpec/MultipleDescribes:
Douwe Maan committed
1138 1139
  Enabled: false

Douwe Maan committed
1140
# Checks if examples contain too many `expect` calls.
Douwe Maan committed
1141
RSpec/MultipleExpectations:
1142 1143
  Enabled: false

Douwe Maan committed
1144
# Checks for explicitly referenced test subjects.
Douwe Maan committed
1145
RSpec/NamedSubject:
Douwe Maan committed
1146 1147
  Enabled: false

Douwe Maan committed
1148
# Checks for nested example groups.
Douwe Maan committed
1149
RSpec/NestedGroups:
Douwe Maan committed
1150 1151
  Enabled: false

Douwe Maan committed
1152 1153 1154
# Enforces the usage of the same method on all negative message expectations.
RSpec/NotToNot:
  EnforcedStyle: not_to
1155
  Enabled: true
1156

Douwe Maan committed
1157
# Check for repeated description strings in example groups.
Douwe Maan committed
1158
RSpec/RepeatedDescription:
Douwe Maan committed
1159 1160
  Enabled: false

1161 1162
# Ensure RSpec hook blocks are always multi-line.
RSpec/SingleLineHook:
1163
  Enabled: true
1164 1165 1166 1167
  Exclude:
    - 'spec/factories/*'
    - 'spec/requests/api/v3/*'

Douwe Maan committed
1168
# Checks for stubbed test subjects.
Douwe Maan committed
1169
RSpec/SubjectStub:
Douwe Maan committed
1170 1171
  Enabled: false

Douwe Maan committed
1172 1173
# Prefer using verifying doubles over normal doubles.
RSpec/VerifiedDoubles:
Douwe Maan committed
1174
  Enabled: false
1175 1176 1177 1178 1179 1180 1181

# GitlabSecurity ##############################################################

GitlabSecurity/DeepMunge:
  Enabled: true
  Exclude:
    - 'lib/**/*.rake'
1182
    - 'spec/**/*'
1183 1184 1185 1186

GitlabSecurity/PublicSend:
  Enabled: true
  Exclude:
1187 1188 1189
    - 'config/**/*'
    - 'db/**/*'
    - 'features/**/*'
1190
    - 'lib/**/*.rake'
1191 1192
    - 'qa/**/*'
    - 'spec/**/*'
1193 1194 1195 1196 1197

GitlabSecurity/RedirectToParamsUpdate:
  Enabled: true
  Exclude:
    - 'lib/**/*.rake'
1198
    - 'spec/**/*'
1199 1200 1201 1202 1203

GitlabSecurity/SqlInjection:
  Enabled: true
  Exclude:
    - 'lib/**/*.rake'
1204
    - 'spec/**/*'
1205 1206 1207 1208 1209

GitlabSecurity/SystemCommandInjection:
  Enabled: true
  Exclude:
    - 'lib/**/*.rake'
1210
    - 'spec/**/*'