.rubocop.yml 28.6 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 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 250
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:
D
Douwe Maan 已提交
251 252
  Enabled: false

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

D
Douwe Maan 已提交
258 259 260 261 262
# Whether `and` and `or` are banned only in conditionals (conditionals)
# or completely (always).
Style/AndOr:
  Enabled: true

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

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

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

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

279
# Avoid the use of BEGIN blocks.
280
Style/BeginBlock:
D
Dmitriy Zaporozhets 已提交
281
  Enabled: true
282

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

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

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

D
Douwe Maan 已提交
297
# This cop checks for uses of the case equality operator(===).
D
Douwe Maan 已提交
298 299 300
Style/CaseEquality:
  Enabled: false

301
# Checks for uses of character literals.
302
Style/CharacterLiteral:
D
Dmitriy Zaporozhets 已提交
303
  Enabled: true
304

305
# Use CamelCase for classes and modules.'
306
Style/ClassAndModuleCamelCase:
D
Dmitriy Zaporozhets 已提交
307
  Enabled: true
308

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

313
# Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.
314
Style/ClassCheck:
D
Douwe Maan 已提交
315
  Enabled: true
316

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

321
# Avoid the use of class variables.
322
Style/ClassVars:
D
Dmitriy Zaporozhets 已提交
323
  Enabled: true
324

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

D
Douwe Maan 已提交
330 331
# This cop checks that comment annotation keywords are written according
# to guidelines.
D
Douwe Maan 已提交
332 333 334
Style/CommentAnnotation:
  Enabled: false

D
Douwe Maan 已提交
335 336 337
# 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 已提交
338 339 340
Style/ConditionalAssignment:
  Enabled: true

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

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

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

D
Douwe Maan 已提交
353 354 355
# 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 已提交
356 357 358
Style/DoubleNegation:
  Enabled: false

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

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

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

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

375
# Checks use of for or each in multiline loops.
376
Style/For:
G
Grzegorz Bizon 已提交
377
  Enabled: true
378

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

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

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

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

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

D
Douwe Maan 已提交
404 405 406 407
# Do not use if x; .... Use the ternary operator instead.
Style/IfWithSemicolon:
  Enabled: true

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

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

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

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

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

C
Connor Shea 已提交
429 430 431 432
# Checks for usage of `extend self` in modules.
Style/ModuleFunction:
  Enabled: false

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

498 499 500 501 502 503 504
# 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:
505
  Enabled: false
506

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

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

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

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

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

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

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

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

D
Douwe Maan 已提交
543
# This cop checks for trailing comma in array and hash literals.
544
Style/TrailingCommaInLiteral:
545 546
  Enabled: true
  EnforcedStyleForMultiline: no_comma
547

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

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

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

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

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

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

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

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

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

586
# Use %w or %W for arrays of words.
587
Style/WordArray:
D
Douwe Maan 已提交
588
  Enabled: true
589

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

M
mhasbini 已提交
594 595 596 597
# Use `proc` instead of `Proc.new`.
Style/Proc:
  Enabled: true

598
# Metrics #####################################################################
599

600 601
# A calculated magnitude based on number of assignments,
# branches, and conditions.
602
Metrics/AbcSize:
G
Grzegorz Bizon 已提交
603
  Enabled: true
M
Maxim Rydkin 已提交
604
  Max: 56.96
G
Grzegorz Bizon 已提交
605

D
Douwe Maan 已提交
606
# This cop checks if the length of a block exceeds some maximum value.
D
Douwe Maan 已提交
607 608 609
Metrics/BlockLength:
  Enabled: false

610
# Avoid excessive block nesting.
611
Metrics/BlockNesting:
G
Grzegorz Bizon 已提交
612 613
  Enabled: true
  Max: 4
614

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

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

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

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

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

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

647
# Lint ########################################################################
648

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

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

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

D
Douwe Maan 已提交
664 665
# This cop checks for assignments in the conditions of
# if/while/until.
D
Douwe Maan 已提交
666 667 668
Lint/AssignmentInCondition:
  Enabled: false

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

D
Douwe Maan 已提交
730
# This cop checks for *rescue* blocks with no body.
D
Douwe Maan 已提交
731 732 733
Lint/HandleExceptions:
  Enabled: false

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

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

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

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

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

D
Douwe Maan 已提交
757
# This cop checks for uses of *begin...end while/until something*.
D
Douwe Maan 已提交
758 759 760
Lint/Loop:
  Enabled: false

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

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

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

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

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

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

C
Connor Shea 已提交
786 787
# Checks for the order which exceptions are rescued to avoid rescueing a less specific exception before a more specific exception.
Lint/ShadowedException:
788 789
  Enabled: false

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

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

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

D
Douwe Maan 已提交
803
# This cop checks for using Fixnum or Bignum constant
D
Douwe Maan 已提交
804 805 806
Lint/UnifiedInteger:
  Enabled: true

807 808 809 810 811 812
# 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 已提交
813
# This cop checks for unneeded usages of splat expansion
D
Douwe Maan 已提交
814 815 816
Lint/UnneededSplatExpansion:
  Enabled: false

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

D
Douwe Maan 已提交
821
# This cop checks for unused block arguments.
D
Douwe Maan 已提交
822 823 824
Lint/UnusedBlockArgument:
  Enabled: false

D
Douwe Maan 已提交
825
# This cop checks for unused method arguments.
D
Douwe Maan 已提交
826 827 828
Lint/UnusedMethodArgument:
  Enabled: false

D
Douwe Maan 已提交
829 830 831 832
# Checks for useless access modifiers.
Lint/UselessAccessModifier:
  Enabled: true

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

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

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

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

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

853
# Performance #################################################################
854

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

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

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

# Use `strip` instead of `lstrip.rstrip`.
Performance/LstripRstrip:
C
Connor Shea 已提交
870
  Enabled: true
871 872 873

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

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

D
Douwe Maan 已提交
881 882
# 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 已提交
883 884 885
Performance/RedundantMatch:
  Enabled: true

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

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

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

901 902 903 904
# 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 已提交
905
  Enabled: true
906 907 908

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

D
Douwe Maan 已提交
911 912
# Security ####################################################################

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

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

922
# Rails #######################################################################
923

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

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

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

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

941 942
# Checks the correct usage of date aware methods, such as `Date.today`,
# `Date.current`, etc.
G
Gabriel Mazetto 已提交
943 944 945
Rails/Date:
  Enabled: false

946
# Prefer delegate method for delegations.
R
Rémy Coutable 已提交
947
# Disabled per https://gitlab.com/gitlab-org/gitlab-ce/issues/35869
948
Rails/Delegate:
R
Rémy Coutable 已提交
949
  Enabled: false
950

D
Douwe Maan 已提交
951
# This cop checks dynamic `find_by_*` methods.
D
Douwe Maan 已提交
952 953 954
Rails/DynamicFindBy:
  Enabled: false

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

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

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

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

D
Douwe Maan 已提交
974 975 976
# 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 已提交
977 978 979
Rails/HttpPositionalArguments:
  Enabled: false

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

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

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

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

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

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

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

D
Douwe Maan 已提交
1014
# This cop checks for the use of Time methods without zone.
D
Douwe Maan 已提交
1015 1016 1017
Rails/TimeZone:
  Enabled: false

D
Douwe Maan 已提交
1018
# This cop checks for the use of old-style attribute validation macros.
D
Douwe Maan 已提交
1019 1020 1021
Rails/Validation:
  Enabled: true

1022
# RSpec #######################################################################
R
Robert Speicher 已提交
1023

1024
# Check that instances are not being stubbed globally.
R
Robert Speicher 已提交
1025 1026 1027
RSpec/AnyInstance:
  Enabled: false

1028 1029
# Check for expectations where `be(...)` can replace `eql(...)`.
RSpec/BeEql:
R
Rémy Coutable 已提交
1030
  Enabled: true
1031

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

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

1041
# Use `described_class` for tested class / module.
R
Robert Speicher 已提交
1042 1043 1044
RSpec/DescribeMethod:
  Enabled: false

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

1049 1050 1051
# Checks that the second argument to top level describe is the tested method
# name.
RSpec/DescribedClass:
1052
  Enabled: true
R
Robert Speicher 已提交
1053

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

1060
# Checks for long example.
R
Robert Speicher 已提交
1061 1062 1063 1064
RSpec/ExampleLength:
  Enabled: false
  Max: 5

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

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

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

1082
# Checks the file and folder naming of the spec file.
R
Robert Speicher 已提交
1083
RSpec/FilePath:
S
Sean McGivern 已提交
1084 1085 1086 1087 1088 1089
  Enabled: true
  IgnoreMethods: true
  Exclude:
    - 'qa/**/*'
    - 'spec/javascripts/fixtures/*'
    - 'spec/requests/api/v3/*'
R
Robert Speicher 已提交
1090

1091
# Checks if there are focused specs.
R
Robert Speicher 已提交
1092 1093 1094
RSpec/Focus:
  Enabled: true

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

1101
# Checks for the usage of instance variables.
R
Robert Speicher 已提交
1102 1103 1104
RSpec/InstanceVariable:
  Enabled: false

D
Douwe Maan 已提交
1105
# Checks for `subject` definitions that come after `let` definitions.
D
Douwe Maan 已提交
1106 1107 1108
RSpec/LeadingSubject:
  Enabled: false

D
Douwe Maan 已提交
1109
# Checks unreferenced `let!` calls being used for test setup.
D
Douwe Maan 已提交
1110 1111 1112
RSpec/LetSetup:
  Enabled: false

D
Douwe Maan 已提交
1113
# Check that chains of messages are not being stubbed.
D
Douwe Maan 已提交
1114 1115 1116
RSpec/MessageChain:
  Enabled: false

D
Douwe Maan 已提交
1117
# Checks that message expectations are set using spies.
D
Douwe Maan 已提交
1118 1119 1120
RSpec/MessageSpies:
  Enabled: false

D
Douwe Maan 已提交
1121 1122
# Checks for multiple top-level describes.
RSpec/MultipleDescribes:
D
Douwe Maan 已提交
1123 1124
  Enabled: false

D
Douwe Maan 已提交
1125
# Checks if examples contain too many `expect` calls.
D
Douwe Maan 已提交
1126
RSpec/MultipleExpectations:
D
Douwe Maan 已提交
1127 1128
  Enabled: false

D
Douwe Maan 已提交
1129
# Checks for explicitly referenced test subjects.
D
Douwe Maan 已提交
1130
RSpec/NamedSubject:
D
Douwe Maan 已提交
1131 1132
  Enabled: false

D
Douwe Maan 已提交
1133
# Checks for nested example groups.
D
Douwe Maan 已提交
1134
RSpec/NestedGroups:
D
Douwe Maan 已提交
1135 1136
  Enabled: false

D
Douwe Maan 已提交
1137 1138 1139
# Enforces the usage of the same method on all negative message expectations.
RSpec/NotToNot:
  EnforcedStyle: not_to
D
Douwe Maan 已提交
1140
  Enabled: true
1141

D
Douwe Maan 已提交
1142
# Check for repeated description strings in example groups.
D
Douwe Maan 已提交
1143
RSpec/RepeatedDescription:
D
Douwe Maan 已提交
1144 1145
  Enabled: false

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

D
Douwe Maan 已提交
1153
# Checks for stubbed test subjects.
D
Douwe Maan 已提交
1154
RSpec/SubjectStub:
D
Douwe Maan 已提交
1155 1156
  Enabled: false

D
Douwe Maan 已提交
1157 1158
# Prefer using verifying doubles over normal doubles.
RSpec/VerifiedDoubles:
D
Douwe Maan 已提交
1159
  Enabled: false
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191

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

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

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

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

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

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