.rubocop.yml 29.5 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
# No spaces before commas.
Layout/SpaceBeforeComma:
  Enabled: true

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Douwe Maan's avatar
Douwe Maan committed
346 347 348
# Check for `if` and `case` statements where each branch is used for
# assignment to the same variable when using the return of the
# condition can be used instead.
Douwe Maan's avatar
Douwe Maan committed
349 350 351
Style/ConditionalAssignment:
  Enabled: true

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

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

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

Douwe Maan's avatar
Douwe Maan committed
364 365 366
# This cop checks for uses of double negation (!!) to convert something
# to a boolean value. As this is both cryptic and usually redundant, it
# should be avoided.
Douwe Maan's avatar
Douwe Maan committed
367 368 369
Style/DoubleNegation:
  Enabled: false

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

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

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

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

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

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

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

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

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

410 411 412
# Checks that conditional statements do not have an identical line at the
# end of each branch, which can validly be moved out of the conditional.
Style/IdenticalConditionalBranches:
413
  Enabled: true
414

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

509 510 511 512 513 514 515
# This cop (by default) checks for uses of methods Hash#has_key? and
# Hash#has_value? where it enforces Hash#key? and Hash#value?
# It is configurable to enforce the inverse, using `verbose` method
# names also.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: short, verbose
Style/PreferredHashMethods:
516
  Enabled: false
517

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

mhasbini's avatar
mhasbini committed
605 606 607 608
# Use `proc` instead of `Proc.new`.
Style/Proc:
  Enabled: true

609 610 611 612 613 614 615 616 617 618 619 620
# Use `spam?` instead of `is_spam?`
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
Style/PredicateName:
  Enabled: true
  NamePrefixBlacklist: is_
  Exclude:
    - 'spec/**/*'
    - 'features/**/*'

621
# Metrics #####################################################################
622

623 624
# A calculated magnitude based on number of assignments,
# branches, and conditions.
625
Metrics/AbcSize:
Grzegorz Bizon's avatar
Grzegorz Bizon committed
626
  Enabled: true
627
  Max: 56.96
Grzegorz Bizon's avatar
Grzegorz Bizon committed
628

Douwe Maan's avatar
Douwe Maan committed
629
# This cop checks if the length of a block exceeds some maximum value.
Douwe Maan's avatar
Douwe Maan committed
630 631 632
Metrics/BlockLength:
  Enabled: false

633
# Avoid excessive block nesting.
634
Metrics/BlockNesting:
Grzegorz Bizon's avatar
Grzegorz Bizon committed
635 636
  Enabled: true
  Max: 4
637

638
# Avoid classes longer than 100 lines of code.
639 640 641
Metrics/ClassLength:
  Enabled: false

642 643 644 645
# A complexity metric that is strongly correlated to the number
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity:
  Enabled: true
646
  Max: 16
647 648

# Limit lines to 80 characters.
649 650 651
Metrics/LineLength:
  Enabled: false

652
# Avoid methods longer than 10 lines of code.
653 654 655
Metrics/MethodLength:
  Enabled: false

656
# Avoid modules longer than 100 lines of code.
657 658 659
Metrics/ModuleLength:
  Enabled: false

660 661 662 663 664 665 666 667
# 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
668
  Max: 18
669

670
# Lint ########################################################################
671

672 673 674 675 676
# Checks for ambiguous block association with method when param passed without
# parentheses.
Lint/AmbiguousBlockAssociation:
  Enabled: false

677 678
# Checks for ambiguous operators in the first argument of a method invocation
# without parentheses.
679
Lint/AmbiguousOperator:
680
  Enabled: true
681

Douwe Maan's avatar
Douwe Maan committed
682 683
# This cop checks for ambiguous regexp literals in the first argument of
# a method invocation without parentheses.
Douwe Maan's avatar
Douwe Maan committed
684 685 686
Lint/AmbiguousRegexpLiteral:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
687 688
# This cop checks for assignments in the conditions of
# if/while/until.
Douwe Maan's avatar
Douwe Maan committed
689 690 691
Lint/AssignmentInCondition:
  Enabled: false

692
# Align block ends correctly.
693
Lint/BlockAlignment:
694
  Enabled: true
695

696 697 698
# Default values in optional keyword arguments and optional ordinal arguments
# should not refer back to the name of the argument.
Lint/CircularArgumentReference:
699
  Enabled: true
700 701

# Checks for condition placed in a confusing position relative to the keyword.
702
Lint/ConditionPosition:
703
  Enabled: true
704

705
# Check for debugger calls.
706
Lint/Debugger:
707
  Enabled: true
708

709
# Align ends corresponding to defs correctly.
710
Lint/DefEndAlignment:
711
  Enabled: true
712

713
# Check for deprecated class method calls.
714
Lint/DeprecatedClassMethods:
715
  Enabled: true
716

717 718
# Check for immutable argument given to each_with_object.
Lint/EachWithObjectArgument:
719
  Enabled: true
720 721

# Check for odd code arrangement in an else block.
722
Lint/ElseLayout:
723
  Enabled: true
724

725
# Checks for empty ensure block.
726
Lint/EmptyEnsure:
727
  Enabled: true
728

729 730 731 732
# Checks for the presence of `when` branches without a body.
Lint/EmptyWhen:
  Enabled: true

733
# Align ends correctly.
734
Lint/EndAlignment:
735
  Enabled: true
736

737
# END blocks should not be placed inside method definitions.
738
Lint/EndInMethod:
739
  Enabled: true
740

741
# Do not use return in an ensure block.
742
Lint/EnsureReturn:
743
  Enabled: true
744

745 746
# Catches floating-point literals too large or small for Ruby to represent.
Lint/FloatOutOfRange:
747
  Enabled: true
748 749 750

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

Douwe Maan's avatar
Douwe Maan committed
753
# This cop checks for *rescue* blocks with no body.
Douwe Maan's avatar
Douwe Maan committed
754 755 756
Lint/HandleExceptions:
  Enabled: false

757 758 759
# Checks for adjacent string literals on the same line, which could better be
# represented as a single string literal.
Lint/ImplicitStringConcatenation:
760
  Enabled: true
761

Douwe Maan's avatar
Douwe Maan committed
762 763 764 765 766
# Checks for attempts to use `private` or `protected` to set the visibility
# of a class method, which does not work.
Lint/IneffectiveAccessModifier:
  Enabled: false

767 768
# Checks for invalid character literals with a non-escaped whitespace
# character.
769
Lint/InvalidCharacterLiteral:
770
  Enabled: true
771

772
# Checks of literals used in conditions.
773
Lint/LiteralInCondition:
774
  Enabled: true
775

776
# Checks for literals used in interpolation.
777
Lint/LiteralInInterpolation:
778
  Enabled: true
779

Douwe Maan's avatar
Douwe Maan committed
780
# This cop checks for uses of *begin...end while/until something*.
Douwe Maan's avatar
Douwe Maan committed
781 782 783
Lint/Loop:
  Enabled: false

784 785
# Do not use nested method definitions.
Lint/NestedMethodDefinition:
786
  Enabled: true
787 788 789

# Do not omit the accumulator when calling `next` in a `reduce`/`inject` block.
Lint/NextWithoutAccumulator:
790
  Enabled: true
791 792

# Checks for method calls with a space before the opening parenthesis.
793
Lint/ParenthesesAsGroupedExpression:
794
  Enabled: true
795

796 797 798
# Checks for `rand(1)` calls. Such calls always return `0` and most likely
# a mistake.
Lint/RandOne:
799
  Enabled: true
800 801

# Use parentheses in the method call to avoid confusion about precedence.
802
Lint/RequireParentheses:
803
  Enabled: true
804

805
# Avoid rescuing the Exception class.
806
Lint/RescueException:
807
  Enabled: true
808

Connor Shea's avatar
Connor Shea committed
809 810
# Checks for the order which exceptions are rescued to avoid rescueing a less specific exception before a more specific exception.
Lint/ShadowedException:
811 812
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
813 814
# 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
815 816 817
Lint/ShadowingOuterLocalVariable:
  Enabled: false

818 819 820 821
# Checks for Object#to_s usage in string interpolation.
Lint/StringConversionInInterpolation:
  Enabled: true

822
# Do not use prefix `_` for a variable that is used.
823
Lint/UnderscorePrefixedVariableName:
824
  Enabled: true
825

Douwe Maan's avatar
Douwe Maan committed
826
# This cop checks for using Fixnum or Bignum constant
Douwe Maan's avatar
Douwe Maan committed
827 828 829
Lint/UnifiedInteger:
  Enabled: true

830 831 832 833 834 835
# 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
836
# This cop checks for unneeded usages of splat expansion
Douwe Maan's avatar
Douwe Maan committed
837 838 839
Lint/UnneededSplatExpansion:
  Enabled: false

840
# Unreachable code.
841
Lint/UnreachableCode:
842
  Enabled: true
843

Douwe Maan's avatar
Douwe Maan committed
844
# This cop checks for unused block arguments.
Douwe Maan's avatar
Douwe Maan committed
845 846 847
Lint/UnusedBlockArgument:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
848
# This cop checks for unused method arguments.
849 850 851
Lint/UnusedMethodArgument:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
852 853 854 855
# Checks for useless access modifiers.
Lint/UselessAccessModifier:
  Enabled: true

856
# Checks for useless assignment to a local variable.
857
Lint/UselessAssignment:
858
  Enabled: true
859

860
# Checks for comparison of something with itself.
861
Lint/UselessComparison:
862
  Enabled: true
863

864
# Checks for useless `else` in `begin..end` without `rescue`.
865
Lint/UselessElseWithoutRescue:
866
  Enabled: true
867

868
# Checks for useless setter call to a local variable.
869
Lint/UselessSetterCall:
870
  Enabled: true
871

872
# Possible use of operator/literal/variable in void context.
873
Lint/Void:
874
  Enabled: true
875

876
# Performance #################################################################
877

878 879 880 881
# Use `caller(n..n)` instead of `caller`.
Performance/Caller:
  Enabled: false

882 883
# Use `casecmp` rather than `downcase ==`.
Performance/Casecmp:
884
  Enabled: true
885 886 887 888

# Use `str.{start,end}_with?(x, ..., y, ...)` instead of
# `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
Performance/DoubleStartEndWith:
889
  Enabled: true
890 891 892

# Use `strip` instead of `lstrip.rstrip`.
Performance/LstripRstrip:
Connor Shea's avatar
Connor Shea committed
893
  Enabled: true
894 895 896

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

Douwe Maan's avatar
Douwe Maan committed
899 900
# 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
901 902 903
Performance/RedundantBlockCall:
  Enabled: true

Douwe Maan's avatar
Douwe Maan committed
904 905
# 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
906 907 908
Performance/RedundantMatch:
  Enabled: true

Douwe Maan's avatar
Douwe Maan committed
909 910
# This cop identifies places where `Hash#merge!` can be replaced by
# `Hash#[]=`.
Douwe Maan's avatar
Douwe Maan committed
911 912 913 914
Performance/RedundantMerge:
  Enabled: true
  MaxKeyValuePairs: 1

915 916
# Use `sort` instead of `sort_by { |x| x }`.
Performance/RedundantSortBy:
917
  Enabled: true
918 919 920 921

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

924 925 926 927
# 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:
928
  Enabled: true
929 930 931

# Checks for `.times.map` calls.
Performance/TimesMap:
932
  Enabled: true
933

Douwe Maan's avatar
Douwe Maan committed
934 935
# Security ####################################################################

Douwe Maan's avatar
Douwe Maan committed
936 937
# This cop checks for the use of JSON class methods which have potential
# security issues.
Douwe Maan's avatar
Douwe Maan committed
938 939 940
Security/JSONLoad:
  Enabled: true

941 942 943 944
# This cop checks for the use of *Kernel#eval*.
Security/Eval:
  Enabled: true

945
# Rails #######################################################################
946

947 948 949 950 951
# Enables Rails cops.
Rails:
  Enabled: true

# Enforces consistent use of action filter methods.
952
Rails/ActionFilter:
953
  Enabled: true
954
  EnforcedStyle: action
955

956 957 958 959 960 961 962 963
# Check that models subclass ApplicationRecord.
Rails/ApplicationRecord:
  Enabled: false

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

964 965
# Checks the correct usage of date aware methods, such as `Date.today`,
# `Date.current`, etc.
Gabriel Mazetto's avatar
Gabriel Mazetto committed
966 967 968
Rails/Date:
  Enabled: false

969
# Prefer delegate method for delegations.
970
# Disabled per https://gitlab.com/gitlab-org/gitlab-ce/issues/35869
971
Rails/Delegate:
972
  Enabled: false
973

Douwe Maan's avatar
Douwe Maan committed
974
# This cop checks dynamic `find_by_*` methods.
Douwe Maan's avatar
Douwe Maan committed
975 976 977
Rails/DynamicFindBy:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
978
# This cop enforces that 'exit' calls are not used within a rails app.
Douwe Maan's avatar
Douwe Maan committed
979 980 981 982 983 984
Rails/Exit:
  Enabled: true
  Exclude:
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'

985 986
# Prefer `find_by` over `where.first`.
Rails/FindBy:
987
  Enabled: true
988 989 990

# Prefer `all.find_each` over `all.find`.
Rails/FindEach:
991
  Enabled: true
992

993
# Prefer has_many :through to has_and_belongs_to_many.
994
Rails/HasAndBelongsToMany:
995
  Enabled: true
996

Douwe Maan's avatar
Douwe Maan committed
997 998 999
# 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
1000 1001 1002
Rails/HttpPositionalArguments:
  Enabled: false

1003
# Checks for calls to puts, print, etc.
1004
Rails/Output:
1005
  Enabled: true
1006 1007 1008 1009 1010
  Exclude:
    - lib/gitlab/seeder.rb
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
1011

Douwe Maan's avatar
Douwe Maan committed
1012 1013
# This cop checks for the use of output safety calls like html_safe and
# raw.
Douwe Maan's avatar
Douwe Maan committed
1014