.rubocop.yml 29.0 KB
Newer Older
1 2
require:
  - rubocop-rspec
3
  - rubocop-gitlab-security
4
  - ./rubocop/rubocop
R
Robert Speicher 已提交
5

Z
Z.J. van de Weg 已提交
6 7
inherit_from: .rubocop_todo.yml

8
AllCops:
Z
Z.J. van de Weg 已提交
9
  TargetRubyVersion: 2.3
10
  TargetRailsVersion: 4.2
Z
Z.J. van de Weg 已提交
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/**/*'
M
Mike Greiling 已提交
22
    - 'node_modules/**/*'
S
Sean McGivern 已提交
23 24
    - 'db/*'
    - 'db/fixtures/**/*'
25 26
    - 'tmp/**/*'
    - 'bin/**/*'
27
    - 'generator_templates/**/*'
28
    - 'builds/**/*'
29

D
Douwe Maan 已提交
30
# Gems in consecutive lines should be alphabetically sorted
D
Douwe Maan 已提交
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

D
Douwe Maan 已提交
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 254 255 256 257
# 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:
D
Douwe Maan 已提交
258 259
  Enabled: false

260 261 262 263 264
# Use alias_method instead of alias.
Style/Alias:
  EnforcedStyle: prefer_alias_method
  Enabled: true

D
Douwe Maan 已提交
265 266 267 268 269
# Whether `and` and `or` are banned only in conditionals (conditionals)
# or completely (always).
Style/AndOr:
  Enabled: true

270
# Use `Array#join` instead of `Array#*`.
271
Style/ArrayJoin:
272
  Enabled: true
273

274
# Use only ascii symbols in comments.
275
Style/AsciiComments:
276
  Enabled: true
277

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

282
# Checks for uses of Module#attr.
283
Style/Attr:
284
  Enabled: true
285

286
# Avoid the use of BEGIN blocks.
287
Style/BeginBlock:
D
Dmitriy Zaporozhets 已提交
288
  Enabled: true
289

290
# Do not use block comments.
291
Style/BlockComments:
292
  Enabled: true
293

294 295
# Avoid using {...} for multi-line blocks (multiline chaining is # always
# ugly). Prefer {...} over do...end for single-line blocks.
296
Style/BlockDelimiters:
297
  Enabled: true
298

D
Douwe Maan 已提交
299 300
 # This cop checks for braces around the last parameter in a method call
# if the last parameter is a hash.
D
Douwe Maan 已提交
301 302 303
Style/BracesAroundHashParameters:
  Enabled: false

D
Douwe Maan 已提交
304
# This cop checks for uses of the case equality operator(===).
D
Douwe Maan 已提交
305 306 307
Style/CaseEquality:
  Enabled: false

308
# Checks for uses of character literals.
309
Style/CharacterLiteral:
D
Dmitriy Zaporozhets 已提交
310
  Enabled: true
311

312
# Use CamelCase for classes and modules.'
313
Style/ClassAndModuleCamelCase:
D
Dmitriy Zaporozhets 已提交
314
  Enabled: true
315

316
# Checks style of children classes and modules.
317 318 319
Style/ClassAndModuleChildren:
  Enabled: false

320
# Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.
321
Style/ClassCheck:
D
Douwe Maan 已提交
322
  Enabled: true
323

324
# Use self when defining module/class methods.
325
Style/ClassMethods:
326
  Enabled: true
327

328
# Avoid the use of class variables.
329
Style/ClassVars:
D
Dmitriy Zaporozhets 已提交
330
  Enabled: true
331

D
Douwe Maan 已提交
332 333
# This cop checks for methods invoked via the :: operator instead
# of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).
D
Douwe Maan 已提交
334 335 336
Style/ColonMethodCall:
  Enabled: true

D
Douwe Maan 已提交
337 338
# This cop checks that comment annotation keywords are written according
# to guidelines.
D
Douwe Maan 已提交
339 340 341
Style/CommentAnnotation:
  Enabled: false

D
Douwe Maan 已提交
342 343 344
# 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.
D
Douwe Maan 已提交
345 346 347
Style/ConditionalAssignment:
  Enabled: true

348
# Constants should use SCREAMING_SNAKE_CASE.
349
Style/ConstantName:
350
  Enabled: true
351

352
# Use def with parentheses when there are arguments.
353
Style/DefWithParentheses:
354
  Enabled: true
355

356
# Document classes and non-namespace modules.
357 358 359
Style/Documentation:
  Enabled: false

D
Douwe Maan 已提交
360 361 362
# 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.
D
Douwe Maan 已提交
363 364 365
Style/DoubleNegation:
  Enabled: false

366
# Avoid the use of END blocks.
367
Style/EndBlock:
368
  Enabled: true
369

370
# Favor the use of Fixnum#even? && Fixnum#odd?
371
Style/EvenOdd:
372
  Enabled: true
373

374
# Use snake_case for source file names.
375
Style/FileName:
376 377
  Enabled: true

378
# Checks for flip flops.
379
Style/FlipFlop:
380
  Enabled: true
381

382
# Checks use of for or each in multiline loops.
383
Style/For:
G
Grzegorz Bizon 已提交
384
  Enabled: true
385

386 387 388 389
# Use a consistent style for format string tokens.
Style/FormatStringToken:
  Enabled: false

Z
Z.J. van de Weg 已提交
390 391 392
# Checks if there is a magic comment to enforce string literals
Style/FrozenStringLiteralComment:
  Enabled: false
393

394
# Do not introduce global variables.
395
Style/GlobalVars:
396
  Enabled: true
397 398 399
  Exclude:
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
400

401 402
# Prefer Ruby 1.9 hash syntax `{ a: 1, b: 2 }`
# over 1.8 syntax `{ :a => 1, :b => 2 }`.
403
Style/HashSyntax:
404
  Enabled: true
405

406 407 408
# 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:
409
  Enabled: true
410

D
Douwe Maan 已提交
411 412 413 414
# Do not use if x; .... Use the ternary operator instead.
Style/IfWithSemicolon:
  Enabled: true

415
# Use Kernel#loop for infinite loops.
416
Style/InfiniteLoop:
417
  Enabled: true
418

419 420 421 422 423
# Use the inverse method instead of `!.method`
# if an inverse method is defined.
Style/InverseMethods:
  Enabled: false

424
# Use lambda.call(...) instead of lambda.(...).
425
Style/LambdaCall:
426
  Enabled: true
427

428
# Checks if the method definitions have or don't have parentheses.
429
Style/MethodDefParentheses:
430
  Enabled: true
431

432
# Use the configured style when naming methods.
433
Style/MethodName:
434
  Enabled: true
435

C
Connor Shea 已提交
436 437 438 439
# Checks for usage of `extend self` in modules.
Style/ModuleFunction:
  Enabled: false

440
# Avoid multi-line chains of blocks.
441
Style/MultilineBlockChain:
442
  Enabled: true
443

444
# Do not use then for multi-line if/unless.
445
Style/MultilineIfThen:
446
  Enabled: true
447

448 449 450 451
# Avoid multi-line `? :` (the ternary operator), use if/unless instead.
Style/MultilineTernaryOperator:
  Enabled: true

452 453 454 455 456
# Avoid comparing a variable with multiple items in a conditional,
# use Array#include? instead.
Style/MultipleComparison:
  Enabled: false

D
Douwe Maan 已提交
457 458
# This cop checks whether some constant value isn't a
# mutable literal (e.g. array or hash).
D
Douwe Maan 已提交
459 460
Style/MutableConstant:
  Enabled: true
461 462 463
  Exclude:
    - 'db/migrate/**/*'
    - 'db/post_migrate/**/*'
D
Douwe Maan 已提交
464

465
# Favor unless over if for negative conditions (or control flow or).
466
Style/NegatedIf:
467
  Enabled: true
468

469 470
# Avoid using nested modifiers.
Style/NestedModifier:
471
  Enabled: true
472 473

# Use one expression per branch in a ternary operator.
474
Style/NestedTernaryOperator:
475
  Enabled: true
476

477
# Prefer x.nil? to x == nil.
478
Style/NilComparison:
479
  Enabled: true
480

481
# Checks for redundant nil checks.
482
Style/NonNilCheck:
483
  Enabled: true
484

485
# Use ! instead of not.
486
Style/Not:
487
  Enabled: true
488

489
# Add underscores to large numeric literals to improve their readability.
490 491 492
Style/NumericLiterals:
  Enabled: false

493
# Favor the ternary operator(?:) over if/then/else/end constructs.
494
Style/OneLineConditional:
495
  Enabled: true
496

497
# When defining binary operators, name the argument other.
498
Style/OpMethod:
499
  Enabled: true
500

501
# Don't use parentheses around the condition of an if/unless/while.
502
Style/ParenthesesAroundCondition:
503
  Enabled: true
504

505 506 507 508 509 510 511
# 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:
512
  Enabled: false
513

514 515 516 517
# Checks for an obsolete RuntimeException argument in raise/fail.
Style/RedundantException:
  Enabled: true

518 519
# Checks for parentheses that seem not to serve any purpose.
Style/RedundantParentheses:
520
  Enabled: true
521 522

# Don't use semicolons to terminate expressions.
523
Style/Semicolon:
524
  Enabled: true
525

526
# Checks for proper usage of fail and raise.
527
Style/SignalException:
528 529
  EnforcedStyle: only_raise
  Enabled: true
530

531 532
# Check for the usage of parentheses around stabby lambda arguments.
Style/StabbyLambdaParentheses:
533 534
  EnforcedStyle: require_parentheses
  Enabled: true
535 536

# Checks if uses of quotes match the configured preference.
537 538 539
Style/StringLiterals:
  Enabled: false

540 541
# Checks if configured preferred methods are used over non-preferred.
Style/StringMethods:
542 543 544
  PreferredMethods:
    intern: to_sym
  Enabled: true
545

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

D
Douwe Maan 已提交
550
# This cop checks for trailing comma in array and hash literals.
551
Style/TrailingCommaInLiteral:
552 553
  Enabled: true
  EnforcedStyleForMultiline: no_comma
554

555 556 557 558 559
# This cop checks for trailing comma in argument lists.
Style/TrailingCommaInArguments:
  Enabled: true
  EnforcedStyleForMultiline: no_comma

560
# Checks for %W when interpolation is not needed.
561
Style/UnneededCapitalW:
562
  Enabled: true
563

564
# Checks for %q/%Q when single quotes or double quotes would do.
565 566 567
Style/UnneededPercentQ:
  Enabled: false

568
# Don't interpolate global, instance and class variables directly in strings.
569
Style/VariableInterpolation:
570
  Enabled: true
571

572
# Use the configured style when naming variables.
573
Style/VariableName:
574 575
  EnforcedStyle: snake_case
  Enabled: true
576

577 578 579 580
# Use the configured style when numbering variables.
Style/VariableNumber:
  Enabled: false

581
# Use when x then ... for one-line cases.
582
Style/WhenThen:
583
  Enabled: true
584

585
# Checks for redundant do after while or until.
586
Style/WhileUntilDo:
587
  Enabled: true
588

589
# Favor modifier while/until usage when you have a single-line body.
590
Style/WhileUntilModifier:
591
  Enabled: true
592

593
# Use %w or %W for arrays of words.
594
Style/WordArray:
D
Douwe Maan 已提交
595
  Enabled: true
596

597 598 599 600
# Do not use literals as the first operand of a comparison.
Style/YodaCondition:
  Enabled: false

M
mhasbini 已提交
601 602 603 604
# Use `proc` instead of `Proc.new`.
Style/Proc:
  Enabled: true

605
# Metrics #####################################################################
606

607 608
# A calculated magnitude based on number of assignments,
# branches, and conditions.
609
Metrics/AbcSize:
G
Grzegorz Bizon 已提交
610
  Enabled: true
M
Maxim Rydkin 已提交
611
  Max: 56.96
G
Grzegorz Bizon 已提交
612

D
Douwe Maan 已提交
613
# This cop checks if the length of a block exceeds some maximum value.
D
Douwe Maan 已提交
614 615 616
Metrics/BlockLength:
  Enabled: false

617
# Avoid excessive block nesting.
618
Metrics/BlockNesting:
G
Grzegorz Bizon 已提交
619 620
  Enabled: true
  Max: 4
621

622
# Avoid classes longer than 100 lines of code.
623 624 625
Metrics/ClassLength:
  Enabled: false

626 627 628 629
# A complexity metric that is strongly correlated to the number
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity:
  Enabled: true
630
  Max: 16
631 632

# Limit lines to 80 characters.
633 634 635
Metrics/LineLength:
  Enabled: false

636
# Avoid methods longer than 10 lines of code.
637 638 639
Metrics/MethodLength:
  Enabled: false

640
# Avoid modules longer than 100 lines of code.
641 642 643
Metrics/ModuleLength:
  Enabled: false

644 645 646 647 648 649 650 651
# 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 已提交
652
  Max: 18
653

654
# Lint ########################################################################
655

656 657 658 659 660
# Checks for ambiguous block association with method when param passed without
# parentheses.
Lint/AmbiguousBlockAssociation:
  Enabled: false

661 662
# Checks for ambiguous operators in the first argument of a method invocation
# without parentheses.
663
Lint/AmbiguousOperator:
664
  Enabled: true
665

D
Douwe Maan 已提交
666 667
# This cop checks for ambiguous regexp literals in the first argument of
# a method invocation without parentheses.
D
Douwe Maan 已提交
668 669 670
Lint/AmbiguousRegexpLiteral:
  Enabled: false

D
Douwe Maan 已提交
671 672
# This cop checks for assignments in the conditions of
# if/while/until.
D
Douwe Maan 已提交
673 674 675
Lint/AssignmentInCondition:
  Enabled: false

676
# Align block ends correctly.
677
Lint/BlockAlignment:
678
  Enabled: true
679

680 681 682
# Default values in optional keyword arguments and optional ordinal arguments
# should not refer back to the name of the argument.
Lint/CircularArgumentReference:
683
  Enabled: true
684 685

# Checks for condition placed in a confusing position relative to the keyword.
686
Lint/ConditionPosition:
687
  Enabled: true
688

689
# Check for debugger calls.
690
Lint/Debugger:
691
  Enabled: true
692

693
# Align ends corresponding to defs correctly.
694
Lint/DefEndAlignment:
695
  Enabled: true
696

697
# Check for deprecated class method calls.
698
Lint/DeprecatedClassMethods:
699
  Enabled: true
700

701 702
# Check for immutable argument given to each_with_object.
Lint/EachWithObjectArgument:
703
  Enabled: true
704 705

# Check for odd code arrangement in an else block.
706
Lint/ElseLayout:
707
  Enabled: true
708

709
# Checks for empty ensure block.
710
Lint/EmptyEnsure:
711
  Enabled: true
712

713 714 715 716
# Checks for the presence of `when` branches without a body.
Lint/EmptyWhen:
  Enabled: true

717
# Align ends correctly.
718
Lint/EndAlignment:
719
  Enabled: true
720

721
# END blocks should not be placed inside method definitions.
722
Lint/EndInMethod:
723
  Enabled: true
724

725
# Do not use return in an ensure block.
726
Lint/EnsureReturn:
727
  Enabled: true
728

729 730
# Catches floating-point literals too large or small for Ruby to represent.
Lint/FloatOutOfRange:
731
  Enabled: true
732 733 734

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

D
Douwe Maan 已提交
737
# This cop checks for *rescue* blocks with no body.
D
Douwe Maan 已提交
738 739 740
Lint/HandleExceptions:
  Enabled: false

741 742 743
# Checks for adjacent string literals on the same line, which could better be
# represented as a single string literal.
Lint/ImplicitStringConcatenation:
744
  Enabled: true
745

D
Douwe Maan 已提交
746 747 748 749 750
# Checks for attempts to use `private` or `protected` to set the visibility
# of a class method, which does not work.
Lint/IneffectiveAccessModifier:
  Enabled: false

751 752
# Checks for invalid character literals with a non-escaped whitespace
# character.
753
Lint/InvalidCharacterLiteral:
754
  Enabled: true
755

756
# Checks of literals used in conditions.
757
Lint/LiteralInCondition:
758
  Enabled: true
759

760
# Checks for literals used in interpolation.
761
Lint/LiteralInInterpolation:
762
  Enabled: true
763

D
Douwe Maan 已提交
764
# This cop checks for uses of *begin...end while/until something*.
D
Douwe Maan 已提交
765 766 767
Lint/Loop:
  Enabled: false

768 769
# Do not use nested method definitions.
Lint/NestedMethodDefinition:
770
  Enabled: true
771 772 773

# Do not omit the accumulator when calling `next` in a `reduce`/`inject` block.
Lint/NextWithoutAccumulator:
774
  Enabled: true
775 776

# Checks for method calls with a space before the opening parenthesis.
777
Lint/ParenthesesAsGroupedExpression:
778
  Enabled: true
779

780 781 782
# Checks for `rand(1)` calls. Such calls always return `0` and most likely
# a mistake.
Lint/RandOne:
783
  Enabled: true
784 785

# Use parentheses in the method call to avoid confusion about precedence.
786
Lint/RequireParentheses:
787
  Enabled: true
788

789
# Avoid rescuing the Exception class.
790
Lint/RescueException:
791
  Enabled: true
792

C
Connor Shea 已提交
793 794
# Checks for the order which exceptions are rescued to avoid rescueing a less specific exception before a more specific exception.
Lint/ShadowedException:
795 796
  Enabled: false

D
Douwe Maan 已提交
797 798
# This cop looks for use of the same name as outer local variables
# for block arguments or block local variables.
D
Douwe Maan 已提交
799 800 801
Lint/ShadowingOuterLocalVariable:
  Enabled: false

802 803 804 805
# Checks for Object#to_s usage in string interpolation.
Lint/StringConversionInInterpolation:
  Enabled: true

806
# Do not use prefix `_` for a variable that is used.
807
Lint/UnderscorePrefixedVariableName:
808
  Enabled: true
809

D
Douwe Maan 已提交
810
# This cop checks for using Fixnum or Bignum constant
D
Douwe Maan 已提交
811 812 813
Lint/UnifiedInteger:
  Enabled: true

814 815 816 817 818 819
# 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

D
Douwe Maan 已提交
820
# This cop checks for unneeded usages of splat expansion
D
Douwe Maan 已提交
821 822 823
Lint/UnneededSplatExpansion:
  Enabled: false

824
# Unreachable code.
825
Lint/UnreachableCode:
826
  Enabled: true
827

D
Douwe Maan 已提交
828
# This cop checks for unused block arguments.
D
Douwe Maan 已提交
829 830 831
Lint/UnusedBlockArgument:
  Enabled: false

D
Douwe Maan 已提交
832
# This cop checks for unused method arguments.
D
Douwe Maan 已提交
833 834 835
Lint/UnusedMethodArgument:
  Enabled: false

D
Douwe Maan 已提交
836 837 838 839
# Checks for useless access modifiers.
Lint/UselessAccessModifier:
  Enabled: true

840
# Checks for useless assignment to a local variable.
841
Lint/UselessAssignment:
842
  Enabled: true
843

844
# Checks for comparison of something with itself.
845
Lint/UselessComparison:
846
  Enabled: true
847

848
# Checks for useless `else` in `begin..end` without `rescue`.
849
Lint/UselessElseWithoutRescue:
850
  Enabled: true
851

852
# Checks for useless setter call to a local variable.
853
Lint/UselessSetterCall:
854
  Enabled: true
855

856
# Possible use of operator/literal/variable in void context.
857
Lint/Void:
858
  Enabled: true
859

860
# Performance #################################################################
861

862 863 864 865
# Use `caller(n..n)` instead of `caller`.
Performance/Caller:
  Enabled: false

866 867
# Use `casecmp` rather than `downcase ==`.
Performance/Casecmp:
868
  Enabled: true
869 870 871 872

# Use `str.{start,end}_with?(x, ..., y, ...)` instead of
# `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
Performance/DoubleStartEndWith:
873
  Enabled: true
874 875 876

# Use `strip` instead of `lstrip.rstrip`.
Performance/LstripRstrip:
C
Connor Shea 已提交
877
  Enabled: true
878 879 880

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

D
Douwe Maan 已提交
883 884
# This cop identifies the use of a `&block` parameter and `block.call`
# where `yield` would do just as well.
D
Douwe Maan 已提交
885 886 887
Performance/RedundantBlockCall:
  Enabled: true

D
Douwe Maan 已提交
888 889
# This cop identifies use of `Regexp#match` or `String#match in a context
# where the integral return value of `=~` would do just as well.
D
Douwe Maan 已提交
890 891 892
Performance/RedundantMatch:
  Enabled: true

D
Douwe Maan 已提交
893 894
# This cop identifies places where `Hash#merge!` can be replaced by
# `Hash#[]=`.
D
Douwe Maan 已提交
895 896 897 898
Performance/RedundantMerge:
  Enabled: true
  MaxKeyValuePairs: 1

899 900
# Use `sort` instead of `sort_by { |x| x }`.
Performance/RedundantSortBy:
901
  Enabled: true
902 903 904 905

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

908 909 910 911
# 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 已提交
912
  Enabled: true
913 914 915

# Checks for `.times.map` calls.
Performance/TimesMap:
916
  Enabled: true
917

D
Douwe Maan 已提交
918 919
# Security ####################################################################

D
Douwe Maan 已提交
920 921
# This cop checks for the use of JSON class methods which have potential
# security issues.
D
Douwe Maan 已提交
922 923 924
Security/JSONLoad:
  Enabled: true

925 926 927 928
# This cop checks for the use of *Kernel#eval*.
Security/Eval:
  Enabled: true

929
# Rails #######################################################################
930

931 932 933 934 935
# Enables Rails cops.
Rails:
  Enabled: true

# Enforces consistent use of action filter methods.
936
Rails/ActionFilter:
937
  Enabled: true
938
  EnforcedStyle: action
939

940 941 942 943 944 945 946 947
# Check that models subclass ApplicationRecord.
Rails/ApplicationRecord:
  Enabled: false

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

948 949
# Checks the correct usage of date aware methods, such as `Date.today`,
# `Date.current`, etc.
G
Gabriel Mazetto 已提交
950 951 952
Rails/Date:
  Enabled: false

953
# Prefer delegate method for delegations.
R
Rémy Coutable 已提交
954
# Disabled per https://gitlab.com/gitlab-org/gitlab-ce/issues/35869
955
Rails/Delegate:
R
Rémy Coutable 已提交
956
  Enabled: false
957

D
Douwe Maan 已提交
958
# This cop checks dynamic `find_by_*` methods.
D
Douwe Maan 已提交
959 960 961
Rails/DynamicFindBy:
  Enabled: false

D
Douwe Maan 已提交
962
# This cop enforces that 'exit' calls are not used within a rails app.
D
Douwe Maan 已提交
963 964 965 966 967 968
Rails/Exit:
  Enabled: true
  Exclude:
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'

969 970
# Prefer `find_by` over `where.first`.
Rails/FindBy:
971
  Enabled: true
972 973 974

# Prefer `all.find_each` over `all.find`.
Rails/FindEach:
975
  Enabled: true
976

977
# Prefer has_many :through to has_and_belongs_to_many.
978
Rails/HasAndBelongsToMany:
979
  Enabled: true
980

D
Douwe Maan 已提交
981 982 983
# 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.
D
Douwe Maan 已提交
984 985 986
Rails/HttpPositionalArguments:
  Enabled: false

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

D
Douwe Maan 已提交
996 997
# This cop checks for the use of output safety calls like html_safe and
# raw.
D
Douwe Maan 已提交
998 999 1000
Rails/OutputSafety:
  Enabled: false

1001 1002
# Checks for incorrect grammar when using methods like `3.day.ago`.
Rails/PluralizationGrammar:
1003
  Enabled: true
1004

1005 1006 1007 1008
# Enforce using `blank?` and `present?`.
Rails/Present:
  Enabled: false

1009
# Checks for `read_attribute(:attr)` and `write_attribute(:attr, val)`.
1010 1011 1012
Rails/ReadWriteAttribute:
  Enabled: false

1013 1014 1015 1016
# Do not assign relative date to constants.
Rails/RelativeDateConstant:
  Enabled: false

1017
# Checks the arguments of ActiveRecord scopes.
1018
Rails/ScopeArgs:
1019
  Enabled: true
1020

D
Douwe Maan 已提交
1021
# This cop checks for the use of Time methods without zone.
D
Douwe Maan 已提交
1022 1023 1024
Rails/TimeZone:
  Enabled: false

D
Douwe Maan 已提交
1025
# This cop checks for the use of old-style attribute validation macros.
D
Douwe Maan 已提交
1026 1027 1028
Rails/Validation:
  Enabled: true

1029
# RSpec #######################################################################
R
Robert Speicher 已提交
1030

1031
# Check that instances are not being stubbed globally.
R
Robert Speicher 已提交
1032 1033 1034
RSpec/AnyInstance:
  Enabled: false

1035 1036
# Check for expectations where `be(...)` can replace `eql(...)`.
RSpec/BeEql:
R
Rémy Coutable 已提交
1037
  Enabled: true
1038

1039 1040 1041 1042
# We don't enforce this as we use this technique in a few places.
RSpec/BeforeAfterAll:
  Enabled: false

1043 1044
# Check that the first argument to the top level describe is the tested class or
# module.
R
Robert Speicher 已提交
1045 1046 1047
RSpec/DescribeClass:
  Enabled: false

R
Rémy Coutable 已提交
1048
# Checks that the second argument to `describe` specifies a method.
R
Robert Speicher 已提交
1049 1050 1051
RSpec/DescribeMethod:
  Enabled: false

1052 1053 1054 1055
# Avoid describing symbols.
RSpec/DescribeSymbol:
  Enabled: true

R
Rémy Coutable 已提交
1056
# Checks that tests use `described_class`.
1057
RSpec/DescribedClass:
1058
  Enabled: true
R
Robert Speicher 已提交
1059

1060
# Checks if an example group does not include any tests.
1061 1062 1063 1064 1065
RSpec/EmptyExampleGroup:
  Enabled: true
  CustomIncludeMethods:
    - run_permission_checks

1066
# Checks for long example.
R
Robert Speicher 已提交
1067 1068 1069 1070
RSpec/ExampleLength:
  Enabled: false
  Max: 5

1071
# Do not use should when describing your tests.
R
Robert Speicher 已提交
1072 1073 1074 1075 1076 1077 1078 1079
RSpec/ExampleWording:
  Enabled: false
  CustomTransform:
    be: is
    have: has
    not: does not
  IgnoredWords: []

1080 1081 1082 1083
# Checks for `expect(...)` calls containing literal values.
RSpec/ExpectActual:
  Enabled: true

1084
# Checks for opportunities to use `expect { … }.to output`.
1085 1086 1087
RSpec/ExpectOutput:
  Enabled: true

1088
# Checks the file and folder naming of the spec file.
R
Robert Speicher 已提交
1089
RSpec/FilePath:
S
Sean McGivern 已提交
1090 1091 1092 1093 1094 1095
  Enabled: true
  IgnoreMethods: true
  Exclude:
    - 'qa/**/*'
    - 'spec/javascripts/fixtures/*'
    - 'spec/requests/api/v3/*'
R
Robert Speicher 已提交
1096

1097
# Checks if there are focused specs.
R
Robert Speicher 已提交
1098 1099 1100
RSpec/Focus:
  Enabled: true

1101 1102 1103 1104 1105
# Checks the arguments passed to `before`, `around`, and `after`.
RSpec/HookArgument:
  Enabled: true
  EnforcedStyle: implicit

1106 1107 1108 1109 1110 1111
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: is_expected, should
RSpec/ImplicitExpect:
  Enabled: true
  EnforcedStyle: is_expected

1112
# Checks for the usage of instance variables.
R
Robert Speicher 已提交
1113 1114 1115
RSpec/InstanceVariable:
  Enabled: false

D
Douwe Maan 已提交
1116
# Checks for `subject` definitions that come after `let` definitions.
D
Douwe Maan 已提交
1117 1118 1119
RSpec/LeadingSubject:
  Enabled: false

D
Douwe Maan 已提交
1120
# Checks unreferenced `let!` calls being used for test setup.
D
Douwe Maan 已提交
1121 1122 1123
RSpec/LetSetup:
  Enabled: false

D
Douwe Maan 已提交
1124
# Check that chains of messages are not being stubbed.
D
Douwe Maan 已提交
1125 1126 1127
RSpec/MessageChain:
  Enabled: false

D
Douwe Maan 已提交
1128
# Checks that message expectations are set using spies.
D
Douwe Maan 已提交
1129 1130 1131
RSpec/MessageSpies:
  Enabled: false

D
Douwe Maan 已提交
1132 1133
# Checks for multiple top-level describes.
RSpec/MultipleDescribes:
D
Douwe Maan 已提交
1134 1135
  Enabled: false

D
Douwe Maan 已提交
1136
# Checks if examples contain too many `expect` calls.
D
Douwe Maan 已提交
1137
RSpec/MultipleExpectations:
D
Douwe Maan 已提交
1138 1139
  Enabled: false

D
Douwe Maan 已提交
1140
# Checks for explicitly referenced test subjects.
D
Douwe Maan 已提交
1141
RSpec/NamedSubject:
D
Douwe Maan 已提交
1142 1143
  Enabled: false

D
Douwe Maan 已提交
1144
# Checks for nested example groups.
D
Douwe Maan 已提交
1145
RSpec/NestedGroups:
D
Douwe Maan 已提交
1146 1147
  Enabled: false

D
Douwe Maan 已提交
1148 1149 1150
# Enforces the usage of the same method on all negative message expectations.
RSpec/NotToNot:
  EnforcedStyle: not_to
D
Douwe Maan 已提交
1151
  Enabled: true
1152

D
Douwe Maan 已提交
1153
# Check for repeated description strings in example groups.
D
Douwe Maan 已提交
1154
RSpec/RepeatedDescription:
D
Douwe Maan 已提交
1155 1156
  Enabled: false

1157 1158
# Ensure RSpec hook blocks are always multi-line.
RSpec/SingleLineHook:
1159
  Enabled: true
1160 1161 1162 1163
  Exclude:
    - 'spec/factories/*'
    - 'spec/requests/api/v3/*'

D
Douwe Maan 已提交
1164
# Checks for stubbed test subjects.
D
Douwe Maan 已提交
1165
RSpec/SubjectStub:
D
Douwe Maan 已提交
1166 1167
  Enabled: false

D
Douwe Maan 已提交
1168 1169
# Prefer using verifying doubles over normal doubles.
RSpec/VerifiedDoubles:
D
Douwe Maan 已提交
1170
  Enabled: false
1171 1172 1173 1174 1175 1176 1177

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

GitlabSecurity/DeepMunge:
  Enabled: true
  Exclude:
    - 'lib/**/*.rake'
1178
    - 'spec/**/*'
1179 1180 1181 1182

GitlabSecurity/PublicSend:
  Enabled: true
  Exclude:
1183 1184 1185
    - 'config/**/*'
    - 'db/**/*'
    - 'features/**/*'
1186
    - 'lib/**/*.rake'
1187 1188
    - 'qa/**/*'
    - 'spec/**/*'
1189 1190 1191 1192 1193

GitlabSecurity/RedirectToParamsUpdate:
  Enabled: true
  Exclude:
    - 'lib/**/*.rake'
1194
    - 'spec/**/*'
1195 1196 1197 1198 1199

GitlabSecurity/SqlInjection:
  Enabled: true
  Exclude:
    - 'lib/**/*.rake'
1200
    - 'spec/**/*'
1201 1202 1203 1204 1205

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