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

Z.J. van de Weg's avatar
Z.J. van de Weg committed
6 7
inherit_from: .rubocop_todo.yml

8
AllCops:
Z.J. van de Weg's avatar
Z.J. van de Weg committed
9
  TargetRubyVersion: 2.3
10
  TargetRailsVersion: 4.2
Z.J. van de Weg's avatar
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's avatar
Douwe Maan committed
30
# Gems in consecutive lines should be alphabetically sorted
Douwe Maan's avatar
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's avatar
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 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:
Douwe Maan's avatar
Douwe Maan committed
258 259
  Enabled: false

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

Douwe Maan's avatar
Douwe Maan committed
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:
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

Douwe Maan's avatar
Douwe Maan committed
299 300
 # This cop checks for braces around the last parameter in a method call
# if the last parameter is a hash.
Douwe Maan's avatar
Douwe Maan committed
301 302 303
Style/BracesAroundHashParameters:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
304
# This cop checks for uses of the case equality operator(===).
Douwe Maan's avatar
Douwe Maan committed
305 306 307
Style/CaseEquality:
  Enabled: false

308
# Checks for uses of character literals.
309
Style/CharacterLiteral:
310
  Enabled: true
311

312
# Use CamelCase for classes and modules.'
313
Style/ClassAndModuleCamelCase:
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:
Douwe Maan's avatar
Douwe Maan committed
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:
330
  Enabled: true
331

Douwe Maan's avatar
Douwe Maan committed
332 333
# This cop checks for methods invoked via the :: operator instead
# of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).
Douwe Maan's avatar
Douwe Maan committed
334 335 336
Style/ColonMethodCall:
  Enabled: true

Douwe Maan's avatar
Douwe Maan committed
337 338
# This cop checks that comment annotation keywords are written according
# to guidelines.
Douwe Maan's avatar
Douwe Maan committed
339 340 341
Style/CommentAnnotation:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
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.
Douwe Maan's avatar
Douwe Maan committed
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

Douwe Maan's avatar
Douwe Maan committed
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.
Douwe Maan's avatar
Douwe Maan committed
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:
384
  Enabled: true
385

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

Z.J. van de Weg's avatar
Z.J. van de Weg committed
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

Douwe Maan's avatar
Douwe Maan committed
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

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

Douwe Maan's avatar
Douwe Maan committed
457 458
# This cop checks whether some constant value isn't a
# mutable literal (e.g. array or hash).
Douwe Maan's avatar
Douwe Maan committed
459 460
Style/MutableConstant:
  Enabled: true
461 462 463
  Exclude:
    - 'db/migrate/**/*'
    - 'db/post_migrate/**/*'
Douwe Maan's avatar
Douwe Maan committed
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

Douwe Maan's avatar
Douwe Maan committed
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:
Douwe Maan's avatar
Douwe Maan committed
595
  Enabled: true
596

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

mhasbini's avatar
mhasbini committed
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:
Grzegorz Bizon's avatar
Grzegorz Bizon committed
610
  Enabled: true
611
  Max: 56.96
Grzegorz Bizon's avatar
Grzegorz Bizon committed
612

Douwe Maan's avatar
Douwe Maan committed
613
# This cop checks if the length of a block exceeds some maximum value.
Douwe Maan's avatar
Douwe Maan committed
614 615 616
Metrics/BlockLength:
  Enabled: false

617
# Avoid excessive block nesting.
618
Metrics/BlockNesting:
Grzegorz Bizon's avatar
Grzegorz Bizon committed
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
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

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

Douwe Maan's avatar
Douwe Maan committed
671 672
# This cop checks for assignments in the conditions of
# if/while/until.
Douwe Maan's avatar
Douwe Maan committed
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

Douwe Maan's avatar
Douwe Maan committed
737
# This cop checks for *rescue* blocks with no body.
Douwe Maan's avatar
Douwe Maan committed
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

Douwe Maan's avatar
Douwe Maan committed
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

Douwe Maan's avatar
Douwe Maan committed
764
# This cop checks for uses of *begin...end while/until something*.
Douwe Maan's avatar
Douwe Maan committed
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

Connor Shea's avatar
Connor Shea committed
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

Douwe Maan's avatar
Douwe Maan committed
797 798
# This cop looks for use of the same name as outer local variables
# for block arguments or block local variables.
Douwe Maan's avatar
Douwe Maan committed
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

Douwe Maan's avatar
Douwe Maan committed
810
# This cop checks for using Fixnum or Bignum constant
Douwe Maan's avatar
Douwe Maan committed
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

Douwe Maan's avatar
Douwe Maan committed
820
# This cop checks for unneeded usages of splat expansion
Douwe Maan's avatar
Douwe Maan committed
821 822 823
Lint/UnneededSplatExpansion:
  Enabled: false

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

Douwe Maan's avatar
Douwe Maan committed
828
# This cop checks for unused block arguments.
Douwe Maan's avatar
Douwe Maan committed
829 830 831
Lint/UnusedBlockArgument:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
832
# This cop checks for unused method arguments.
833 834 835
Lint/UnusedMethodArgument:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
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:
Connor Shea's avatar
Connor Shea committed
877
  Enabled: true
878 879 880

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

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

Douwe Maan's avatar
Douwe Maan committed
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.
Douwe Maan's avatar
Douwe Maan committed
890 891 892
Performance/RedundantMatch:
  Enabled: true

Douwe Maan's avatar
Douwe Maan committed
893 894
# This cop identifies places where `Hash#merge!` can be replaced by
# `Hash#[]=`.
Douwe Maan's avatar
Douwe Maan committed
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
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:
912
  Enabled: true
913 914 915

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

Douwe Maan's avatar
Douwe Maan committed
918 919
# Security ####################################################################

Douwe Maan's avatar
Douwe Maan committed
920 921
# This cop checks for the use of JSON class methods which have potential
# security issues.
Douwe Maan's avatar
Douwe Maan committed
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.
Gabriel Mazetto's avatar
Gabriel Mazetto committed
950 951 952
Rails/Date:
  Enabled: false

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

Douwe Maan's avatar
Douwe Maan committed
958
# This cop checks dynamic `find_by_*` methods.
Douwe Maan's avatar
Douwe Maan committed
959 960 961
Rails/DynamicFindBy:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
962
# This cop enforces that 'exit' calls are not used within a rails app.
Douwe Maan's avatar
Douwe Maan committed
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

Douwe Maan's avatar
Douwe Maan committed
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.
Douwe Maan's avatar
Douwe Maan committed
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

Douwe Maan's avatar
Douwe Maan committed
996 997
# This cop checks for the use of output safety calls like html_safe and
# raw.
Douwe Maan's avatar
Douwe Maan committed
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