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

5 6
inherit_from: .rubocop_todo.yml

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

Douwe Maan's avatar
Douwe Maan committed
28
# Gems in consecutive lines should be alphabetically sorted
Douwe Maan's avatar
Douwe Maan committed
29 30 31
Bundler/OrderedGems:
  Enabled: false

32
# Style #######################################################################
33 34

# Check indentation of private/protected visibility modifiers.
35
Style/AccessModifierIndentation:
36
  Enabled: true
37

38 39 40 41
# Check the naming of accessor methods for get_/set_.
Style/AccessorMethodName:
  Enabled: false

42
# Use alias_method instead of alias.
43
Style/Alias:
44
  EnforcedStyle: prefer_alias_method
45
  Enabled: true
46

47
# Align the elements of an array literal if they span more than one line.
48
Style/AlignArray:
49
  Enabled: true
50

51
# Align the elements of a hash literal if they span more than one line.
52
Style/AlignHash:
53
  Enabled: true
54

Douwe Maan's avatar
Douwe Maan committed
55 56
# Here we check if the parameters on a multi-line method call or
# definition are aligned.
Douwe Maan's avatar
Douwe Maan committed
57 58 59
Style/AlignParameters:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
60 61 62 63 64
# Whether `and` and `or` are banned only in conditionals (conditionals)
# or completely (always).
Style/AndOr:
  Enabled: true

65
# Use `Array#join` instead of `Array#*`.
66
Style/ArrayJoin:
67
  Enabled: true
68

69
# Use only ascii symbols in comments.
70
Style/AsciiComments:
71
  Enabled: true
72

73
# Use only ascii symbols in identifiers.
74
Style/AsciiIdentifiers:
75
  Enabled: true
76

77
# Checks for uses of Module#attr.
78
Style/Attr:
79
  Enabled: true
80

81
# Avoid the use of BEGIN blocks.
82
Style/BeginBlock:
83
  Enabled: true
84

85
# Do not use block comments.
86
Style/BlockComments:
87
  Enabled: true
88

89 90
# Avoid using {...} for multi-line blocks (multiline chaining is # always
# ugly). Prefer {...} over do...end for single-line blocks.
91
Style/BlockDelimiters:
92
  Enabled: true
93

Douwe Maan's avatar
Douwe Maan committed
94 95 96 97
# Put end statement of multiline block on its own line.
Style/BlockEndNewline:
  Enabled: true

Douwe Maan's avatar
Douwe Maan committed
98 99
 # 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
100 101 102
Style/BracesAroundHashParameters:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
103
# This cop checks for uses of the case equality operator(===).
Douwe Maan's avatar
Douwe Maan committed
104 105 106
Style/CaseEquality:
  Enabled: false

107
# Indentation of when in a case/when/[else/]end.
108
Style/CaseIndentation:
109
  Enabled: true
110

111
# Checks for uses of character literals.
112
Style/CharacterLiteral:
113
  Enabled: true
114

115
# Use CamelCase for classes and modules.'
116
Style/ClassAndModuleCamelCase:
117
  Enabled: true
118

119
# Checks style of children classes and modules.
120 121 122
Style/ClassAndModuleChildren:
  Enabled: false

123
# Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.
124
Style/ClassCheck:
Douwe Maan's avatar
Douwe Maan committed
125
  Enabled: true
126

127
# Use self when defining module/class methods.
128
Style/ClassMethods:
129
  Enabled: true
130

131
# Avoid the use of class variables.
132
Style/ClassVars:
133
  Enabled: true
134

Douwe Maan's avatar
Douwe Maan committed
135 136
# 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
137 138 139
Style/ColonMethodCall:
  Enabled: true

Douwe Maan's avatar
Douwe Maan committed
140 141
# This cop checks that comment annotation keywords are written according
# to guidelines.
Douwe Maan's avatar
Douwe Maan committed
142 143 144
Style/CommentAnnotation:
  Enabled: false

145
# Indentation of comments.
146
Style/CommentIndentation:
147
  Enabled: true
148

Douwe Maan's avatar
Douwe Maan committed
149 150 151
# 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
152 153 154
Style/ConditionalAssignment:
  Enabled: true

155
# Constants should use SCREAMING_SNAKE_CASE.
156
Style/ConstantName:
157
  Enabled: true
158

159
# Use def with parentheses when there are arguments.
160
Style/DefWithParentheses:
161
  Enabled: true
162

163
# Document classes and non-namespace modules.
164 165 166
Style/Documentation:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
167 168 169
# 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
170 171 172
Style/DoubleNegation:
  Enabled: false

173
# Align elses and elsifs correctly.
174
Style/ElseAlignment:
175
  Enabled: true
176

177
# Use empty lines between defs.
178
Style/EmptyLineBetweenDefs:
179
  Enabled: true
180

181
# Don't use several empty lines in a row.
182
Style/EmptyLines:
183
  Enabled: true
184

185
# Keep blank lines around access modifiers.
186
Style/EmptyLinesAroundAccessModifier:
187
  Enabled: true
188

189
# Keeps track of empty lines around block bodies.
190
Style/EmptyLinesAroundBlockBody:
191
  Enabled: true
192

193
# Keeps track of empty lines around class bodies.
194
Style/EmptyLinesAroundClassBody:
195
  Enabled: true
196

197
# Keeps track of empty lines around method bodies.
198
Style/EmptyLinesAroundMethodBody:
199
  Enabled: true
200

Douwe Maan's avatar
Douwe Maan committed
201 202 203 204
# Keeps track of empty lines around module bodies.
Style/EmptyLinesAroundModuleBody:
  Enabled: true

205
# Avoid the use of END blocks.
206
Style/EndBlock:
207
  Enabled: true
208

209
# Use Unix-style line endings.
210
Style/EndOfLine:
211
  Enabled: true
212

213
# Favor the use of Fixnum#even? && Fixnum#odd?
214
Style/EvenOdd:
215
  Enabled: true
216

217
# Use snake_case for source file names.
218
Style/FileName:
219 220 221
  Enabled: true

# Checks for a line break before the first parameter in a multi-line method
222
# parameter definition.
223 224
Style/FirstMethodParameterLineBreak:
  Enabled: true
225

226
# Checks for flip flops.
227
Style/FlipFlop:
228
  Enabled: true
229

230
# Checks use of for or each in multiline loops.
231
Style/For:
232
  Enabled: true
233

Z.J. van de Weg's avatar
Z.J. van de Weg committed
234 235 236
# Checks if there is a magic comment to enforce string literals
Style/FrozenStringLiteralComment:
  Enabled: false
237

238
# Do not introduce global variables.
239
Style/GlobalVars:
240
  Enabled: true
241 242 243
  Exclude:
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
244

245 246
# Prefer Ruby 1.9 hash syntax `{ a: 1, b: 2 }`
# over 1.8 syntax `{ :a => 1, :b => 2 }`.
247
Style/HashSyntax:
248
  Enabled: true
249

250 251 252
# 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:
253
  Enabled: true
254

Douwe Maan's avatar
Douwe Maan committed
255 256 257 258
# Do not use if x; .... Use the ternary operator instead.
Style/IfWithSemicolon:
  Enabled: true

259
# Checks the indentation of the first line of the right-hand-side of a
260
# multi-line assignment.
261
Style/IndentAssignment:
262
  Enabled: true
263 264

# Keep indentation straight.
265
Style/IndentationConsistency:
266
  Enabled: true
267

268
# Use 2 spaces for indentation.
269
Style/IndentationWidth:
270
  Enabled: true
271

272
# Use Kernel#loop for infinite loops.
273
Style/InfiniteLoop:
274
  Enabled: true
275

276
# Use lambda.call(...) instead of lambda.(...).
277
Style/LambdaCall:
278
  Enabled: true
279

280
# Comments should start with a space.
281
Style/LeadingCommentSpace:
282
  Enabled: true
283

284
# Checks if the method definitions have or don't have parentheses.
285
Style/MethodDefParentheses:
286
  Enabled: true
287

288
# Use the configured style when naming methods.
289
Style/MethodName:
290
  Enabled: true
291

292 293 294 295
# Checks for usage of `extend self` in modules.
Style/ModuleFunction:
  Enabled: false

296 297 298
# Checks that the closing brace in an array literal is either on the same line
# as the last array element, or a new line.
Style/MultilineArrayBraceLayout:
299
  Enabled: true
300 301
  EnforcedStyle: symmetrical

302
# Avoid multi-line chains of blocks.
303
Style/MultilineBlockChain:
304
  Enabled: true
305

306
# Ensures newlines after multiline block do statements.
307
Style/MultilineBlockLayout:
308
  Enabled: true
309

310 311 312
# Checks that the closing brace in a hash literal is either on the same line as
# the last hash element, or a new line.
Style/MultilineHashBraceLayout:
313
  Enabled: true
314 315
  EnforcedStyle: symmetrical

316
# Do not use then for multi-line if/unless.
317
Style/MultilineIfThen:
318
  Enabled: true
319

320 321 322 323 324 325
# Checks that the closing brace in a method call is either on the same line as
# the last method argument, or a new line.
Style/MultilineMethodCallBraceLayout:
  Enabled: false
  EnforcedStyle: symmetrical

326 327 328 329 330
# Checks indentation of method calls with the dot operator that span more than
# one line.
Style/MultilineMethodCallIndentation:
  Enabled: false

331 332 333 334 335
# Checks that the closing brace in a method definition is symmetrical with
# respect to the opening brace and the method parameters.
Style/MultilineMethodDefinitionBraceLayout:
  Enabled: false

336
# Checks indentation of binary operations that span more than one line.
337
Style/MultilineOperationIndentation:
338 339
  Enabled: true
  EnforcedStyle: indented
340

341 342 343 344
# Avoid multi-line `? :` (the ternary operator), use if/unless instead.
Style/MultilineTernaryOperator:
  Enabled: true

Douwe Maan's avatar
Douwe Maan committed
345 346
# This cop checks whether some constant value isn't a
# mutable literal (e.g. array or hash).
347 348
Style/MutableConstant:
  Enabled: true
349 350 351
  Exclude:
    - 'db/migrate/**/*'
    - 'db/post_migrate/**/*'
352

353
# Favor unless over if for negative conditions (or control flow or).
354
Style/NegatedIf:
355
  Enabled: true
356

357 358
# Avoid using nested modifiers.
Style/NestedModifier:
359
  Enabled: true
360 361

# Use one expression per branch in a ternary operator.
362
Style/NestedTernaryOperator:
363
  Enabled: true
364

365
# Prefer x.nil? to x == nil.
366
Style/NilComparison:
367
  Enabled: true
368

369
# Checks for redundant nil checks.
370
Style/NonNilCheck:
371
  Enabled: true
372

373
# Use ! instead of not.
374
Style/Not:
375
  Enabled: true
376

377
# Add underscores to large numeric literals to improve their readability.
378 379 380
Style/NumericLiterals:
  Enabled: false

381
# Favor the ternary operator(?:) over if/then/else/end constructs.
382
Style/OneLineConditional:
383
  Enabled: true
384

385
# When defining binary operators, name the argument other.
386
Style/OpMethod:
387
  Enabled: true
388

389
# Don't use parentheses around the condition of an if/unless/while.
390
Style/ParenthesesAroundCondition:
391
  Enabled: true
392

393 394 395 396
# Checks for an obsolete RuntimeException argument in raise/fail.
Style/RedundantException:
  Enabled: true

397 398
# Checks for parentheses that seem not to serve any purpose.
Style/RedundantParentheses:
399
  Enabled: true
400 401

# Don't use semicolons to terminate expressions.
402
Style/Semicolon:
403
  Enabled: true
404

405
# Checks for proper usage of fail and raise.
406
Style/SignalException:
407 408
  EnforcedStyle: only_raise
  Enabled: true
409

410
# Use spaces after colons.
411
Style/SpaceAfterColon:
412
  Enabled: true
413

414
# Use spaces after commas.
415
Style/SpaceAfterComma:
416
  Enabled: true
417

418 419
# Do not put a space between a method name and the opening parenthesis in a
# method definition.
420
Style/SpaceAfterMethodName:
421
  Enabled: true
422

423
# Tracks redundant space after the ! operator.
424
Style/SpaceAfterNot:
425
  Enabled: true
426

427
# Use spaces after semicolons.
428
Style/SpaceAfterSemicolon:
429
  Enabled: true
430

431 432 433 434
# Use space around equals in parameter default
Style/SpaceAroundEqualsInParameterDefault:
  Enabled: true

435 436
# Use a space around keywords if appropriate.
Style/SpaceAroundKeyword:
437
  Enabled: true
438

439 440
# Use a single space around operators.
Style/SpaceAroundOperators:
441
  Enabled: true
442

443 444
# No spaces before commas.
Style/SpaceBeforeComma:
445
  Enabled: true
446

447 448
# Checks for missing space between code and a comment on the same line.
Style/SpaceBeforeComment:
449
  Enabled: true
450

451 452
# No spaces before semicolons.
Style/SpaceBeforeSemicolon:
453
  Enabled: true
454

Douwe Maan's avatar
Douwe Maan committed
455
# Checks for spaces inside square brackets.
456 457 458
Style/SpaceInsideBrackets:
  Enabled: true

459
# Use spaces inside hash literal braces - or don't.
460
Style/SpaceInsideHashLiteralBraces:
461
  Enabled: true
462

463
# No spaces inside range literals.
464
Style/SpaceInsideRangeLiteral:
465
  Enabled: true
466

467 468
# Checks for padding/surrounding spaces inside string interpolation.
Style/SpaceInsideStringInterpolation:
469 470
  EnforcedStyle: no_space
  Enabled: true
471 472 473

# Check for the usage of parentheses around stabby lambda arguments.
Style/StabbyLambdaParentheses:
474 475
  EnforcedStyle: require_parentheses
  Enabled: true
476 477

# Checks if uses of quotes match the configured preference.
478 479 480
Style/StringLiterals:
  Enabled: false

481 482
# Checks if configured preferred methods are used over non-preferred.
Style/StringMethods:
483 484 485
  PreferredMethods:
    intern: to_sym
  Enabled: true
486 487

# No hard tabs.
488
Style/Tab:
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
489
  Enabled: true
490

491
# Checks trailing blank lines and final newline.
492
Style/TrailingBlankLines:
493
  Enabled: true
494

Douwe Maan's avatar
Douwe Maan committed
495
# This cop checks for trailing comma in array and hash literals.
496
Style/TrailingCommaInLiteral:
497 498
  Enabled: true
  EnforcedStyleForMultiline: no_comma
499

500 501 502 503 504
# This cop checks for trailing comma in argument lists.
Style/TrailingCommaInArguments:
  Enabled: true
  EnforcedStyleForMultiline: no_comma

505
# Checks for %W when interpolation is not needed.
506
Style/UnneededCapitalW:
507
  Enabled: true
508

509
# Checks for %q/%Q when single quotes or double quotes would do.
510 511 512
Style/UnneededPercentQ:
  Enabled: false

513
# Don't interpolate global, instance and class variables directly in strings.
514
Style/VariableInterpolation:
515
  Enabled: true
516

517
# Use the configured style when naming variables.
518
Style/VariableName:
519 520
  EnforcedStyle: snake_case
  Enabled: true
521

522 523 524 525
# Use the configured style when numbering variables.
Style/VariableNumber:
  Enabled: false

526
# Use when x then ... for one-line cases.
527
Style/WhenThen:
528
  Enabled: true
529

530
# Checks for redundant do after while or until.
531
Style/WhileUntilDo:
532
  Enabled: true
533

534
# Favor modifier while/until usage when you have a single-line body.
535
Style/WhileUntilModifier:
536
  Enabled: true
537

538
# Use %w or %W for arrays of words.
539
Style/WordArray:
Douwe Maan's avatar
Douwe Maan committed
540
  Enabled: true
541

542 543 544 545
# Use `proc` instead of `Proc.new`.
Style/Proc:
  Enabled: true

546
# Metrics #####################################################################
547

548 549
# A calculated magnitude based on number of assignments,
# branches, and conditions.
550
Metrics/AbcSize:
Grzegorz Bizon's avatar
Grzegorz Bizon committed
551
  Enabled: true
552
  Max: 57.08
Grzegorz Bizon's avatar
Grzegorz Bizon committed
553

Douwe Maan's avatar
Douwe Maan committed
554
# This cop checks if the length of a block exceeds some maximum value.
Douwe Maan's avatar
Douwe Maan committed
555 556 557
Metrics/BlockLength:
  Enabled: false

558
# Avoid excessive block nesting.
559
Metrics/BlockNesting:
Grzegorz Bizon's avatar
Grzegorz Bizon committed
560 561
  Enabled: true
  Max: 4
562

563
# Avoid classes longer than 100 lines of code.
564 565 566
Metrics/ClassLength:
  Enabled: false

567 568 569 570
# A complexity metric that is strongly correlated to the number
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity:
  Enabled: true
571
  Max: 16
572 573

# Limit lines to 80 characters.
574 575 576
Metrics/LineLength:
  Enabled: false

577
# Avoid methods longer than 10 lines of code.
578 579 580
Metrics/MethodLength:
  Enabled: false

581
# Avoid modules longer than 100 lines of code.
582 583 584
Metrics/ModuleLength:
  Enabled: false

585 586 587 588 589 590 591 592
# 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
593
  Max: 18
594

595
# Lint ########################################################################
596

597 598
# Checks for ambiguous operators in the first argument of a method invocation
# without parentheses.
599
Lint/AmbiguousOperator:
600
  Enabled: true
601

Douwe Maan's avatar
Douwe Maan committed
602 603
# This cop checks for ambiguous regexp literals in the first argument of
# a method invocation without parentheses.
Douwe Maan's avatar
Douwe Maan committed
604 605 606
Lint/AmbiguousRegexpLiteral:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
607 608
# This cop checks for assignments in the conditions of
# if/while/until.
Douwe Maan's avatar
Douwe Maan committed
609 610 611
Lint/AssignmentInCondition:
  Enabled: false

612
# Align block ends correctly.
613
Lint/BlockAlignment:
614
  Enabled: true
615

616 617 618
# Default values in optional keyword arguments and optional ordinal arguments
# should not refer back to the name of the argument.
Lint/CircularArgumentReference:
619
  Enabled: true
620 621

# Checks for condition placed in a confusing position relative to the keyword.
622
Lint/ConditionPosition:
623
  Enabled: true
624

625
# Check for debugger calls.
626
Lint/Debugger:
627
  Enabled: true
628

629
# Align ends corresponding to defs correctly.
630
Lint/DefEndAlignment:
631
  Enabled: true
632

633
# Check for deprecated class method calls.
634
Lint/DeprecatedClassMethods:
635
  Enabled: true
636

637 638
# Check for immutable argument given to each_with_object.
Lint/EachWithObjectArgument:
639
  Enabled: true
640 641

# Check for odd code arrangement in an else block.
642
Lint/ElseLayout:
643
  Enabled: true
644

645
# Checks for empty ensure block.
646
Lint/EmptyEnsure:
647
  Enabled: true
648

649 650 651 652
# Checks for the presence of `when` branches without a body.
Lint/EmptyWhen:
  Enabled: true

653
# Align ends correctly.
654
Lint/EndAlignment:
655
  Enabled: true
656

657
# END blocks should not be placed inside method definitions.
658
Lint/EndInMethod:
659
  Enabled: true
660

661
# Do not use return in an ensure block.
662
Lint/EnsureReturn:
663
  Enabled: true
664

665 666
# Catches floating-point literals too large or small for Ruby to represent.
Lint/FloatOutOfRange:
667
  Enabled: true
668 669 670

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

Douwe Maan's avatar
Douwe Maan committed
673
# This cop checks for *rescue* blocks with no body.
Douwe Maan's avatar
Douwe Maan committed
674 675 676
Lint/HandleExceptions:
  Enabled: false

677 678 679
# Checks for adjacent string literals on the same line, which could better be
# represented as a single string literal.
Lint/ImplicitStringConcatenation:
680
  Enabled: true
681

Douwe Maan's avatar
Douwe Maan committed
682 683 684 685 686
# Checks for attempts to use `private` or `protected` to set the visibility
# of a class method, which does not work.
Lint/IneffectiveAccessModifier:
  Enabled: false

687 688
# Checks for invalid character literals with a non-escaped whitespace
# character.
689
Lint/InvalidCharacterLiteral:
690
  Enabled: true
691

692
# Checks of literals used in conditions.
693
Lint/LiteralInCondition:
694
  Enabled: true
695

696
# Checks for literals used in interpolation.
697
Lint/LiteralInInterpolation:
698
  Enabled: true
699

Douwe Maan's avatar
Douwe Maan committed
700
# This cop checks for uses of *begin...end while/until something*.
Douwe Maan's avatar
Douwe Maan committed
701 702 703
Lint/Loop:
  Enabled: false

704 705
# Do not use nested method definitions.
Lint/NestedMethodDefinition:
706
  Enabled: true
707 708 709

# Do not omit the accumulator when calling `next` in a `reduce`/`inject` block.
Lint/NextWithoutAccumulator:
710
  Enabled: true
711 712

# Checks for method calls with a space before the opening parenthesis.
713
Lint/ParenthesesAsGroupedExpression:
714
  Enabled: true
715

716 717 718
# Checks for `rand(1)` calls. Such calls always return `0` and most likely
# a mistake.
Lint/RandOne:
719
  Enabled: true
720 721

# Use parentheses in the method call to avoid confusion about precedence.
722
Lint/RequireParentheses:
723
  Enabled: true
724

725
# Avoid rescuing the Exception class.
726
Lint/RescueException:
727
  Enabled: true
728

Connor Shea's avatar
Connor Shea committed
729 730
# Checks for the order which exceptions are rescued to avoid rescueing a less specific exception before a more specific exception.
Lint/ShadowedException:
731 732
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
733 734
# 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
735 736 737
Lint/ShadowingOuterLocalVariable:
  Enabled: false

738 739 740 741
# Checks for Object#to_s usage in string interpolation.
Lint/StringConversionInInterpolation:
  Enabled: true

742
# Do not use prefix `_` for a variable that is used.
743
Lint/UnderscorePrefixedVariableName:
744
  Enabled: true
745

Douwe Maan's avatar
Douwe Maan committed
746
# This cop checks for using Fixnum or Bignum constant
Douwe Maan's avatar
Douwe Maan committed
747 748 749
Lint/UnifiedInteger:
  Enabled: true

750 751 752 753 754 755
# 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
756
# This cop checks for unneeded usages of splat expansion
Douwe Maan's avatar
Douwe Maan committed
757 758 759
Lint/UnneededSplatExpansion:
  Enabled: false

760
# Unreachable code.
761
Lint/UnreachableCode:
762
  Enabled: true
763

Douwe Maan's avatar
Douwe Maan committed
764
# This cop checks for unused block arguments.
Douwe Maan's avatar
Douwe Maan committed
765 766 767
Lint/UnusedBlockArgument:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
768
# This cop checks for unused method arguments.
769 770 771
Lint/UnusedMethodArgument:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
772 773 774 775
# Checks for useless access modifiers.
Lint/UselessAccessModifier:
  Enabled: true

776
# Checks for useless assignment to a local variable.
777
Lint/UselessAssignment:
778
  Enabled: true
779

780
# Checks for comparison of something with itself.
781
Lint/UselessComparison:
782
  Enabled: true
783

784
# Checks for useless `else` in `begin..end` without `rescue`.
785
Lint/UselessElseWithoutRescue:
786
  Enabled: true
787

788
# Checks for useless setter call to a local variable.
789
Lint/UselessSetterCall:
790
  Enabled: true
791

792
# Possible use of operator/literal/variable in void context.
793
Lint/Void:
794
  Enabled: true
795

796
# Performance #################################################################
797 798 799

# Use `casecmp` rather than `downcase ==`.
Performance/Casecmp:
800
  Enabled: true
801 802 803 804

# Use `str.{start,end}_with?(x, ..., y, ...)` instead of
# `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
Performance/DoubleStartEndWith:
805
  Enabled: true
806 807 808

# Use `strip` instead of `lstrip.rstrip`.
Performance/LstripRstrip:
Connor Shea's avatar
Connor Shea committed
809
  Enabled: true
810 811 812

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

Douwe Maan's avatar
Douwe Maan committed
815 816
# 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
817 818 819
Performance/RedundantBlockCall:
  Enabled: true

Douwe Maan's avatar
Douwe Maan committed
820 821
# 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
822 823 824
Performance/RedundantMatch:
  Enabled: true

Douwe Maan's avatar
Douwe Maan committed
825 826
# This cop identifies places where `Hash#merge!` can be replaced by
# `Hash#[]=`.
Douwe Maan's avatar
Douwe Maan committed
827 828 829 830
Performance/RedundantMerge:
  Enabled: true
  MaxKeyValuePairs: 1

831 832
# Use `sort` instead of `sort_by { |x| x }`.
Performance/RedundantSortBy:
833
  Enabled: true
834 835 836 837

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

840 841 842 843
# 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:
844
  Enabled: true
845 846 847

# Checks for `.times.map` calls.
Performance/TimesMap:
848
  Enabled: true
849

Douwe Maan's avatar
Douwe Maan committed
850 851
# Security ####################################################################

Douwe Maan's avatar
Douwe Maan committed
852 853
# This cop checks for the use of JSON class methods which have potential
# security issues.
Douwe Maan's avatar
Douwe Maan committed
854 855 856
Security/JSONLoad:
  Enabled: true

857 858 859 860
# This cop checks for the use of *Kernel#eval*.
Security/Eval:
  Enabled: true

861
# Rails #######################################################################
862

863 864 865 866 867
# Enables Rails cops.
Rails:
  Enabled: true

# Enforces consistent use of action filter methods.
868
Rails/ActionFilter:
869
  Enabled: true
870
  EnforcedStyle: action
871

872 873
# Checks the correct usage of date aware methods, such as `Date.today`,
# `Date.current`, etc.
874 875 876
Rails/Date:
  Enabled: false

877 878
# Prefer delegate method for delegations.
Rails/Delegate:
Douwe Maan's avatar
Douwe Maan committed
879
  Enabled: true
880

Douwe Maan's avatar
Douwe Maan committed
881
# This cop checks dynamic `find_by_*` methods.
Douwe Maan's avatar
Douwe Maan committed
882 883 884
Rails/DynamicFindBy:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
885
# This cop enforces that 'exit' calls are not used within a rails app.
Douwe Maan's avatar
Douwe Maan committed
886 887 888 889 890 891
Rails/Exit:
  Enabled: true
  Exclude:
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'

892 893
# Prefer `find_by` over `where.first`.
Rails/FindBy:
894
  Enabled: true
895 896 897

# Prefer `all.find_each` over `all.find`.
Rails/FindEach:
898
  Enabled: true
899

900
# Prefer has_many :through to has_and_belongs_to_many.
901
Rails/HasAndBelongsToMany:
902
  Enabled: true
903

Douwe Maan's avatar
Douwe Maan committed
904 905 906
# 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
907 908 909
Rails/HttpPositionalArguments:
  Enabled: false

910
# Checks for calls to puts, print, etc.
911
Rails/Output:
912
  Enabled: true
913 914 915 916 917
  Exclude:
    - lib/gitlab/seeder.rb
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
918

Douwe Maan's avatar
Douwe Maan committed
919 920
# This cop checks for the use of output safety calls like html_safe and
# raw.
Douwe Maan's avatar
Douwe Maan committed
921 922 923
Rails/OutputSafety:
  Enabled: false

924 925
# Checks for incorrect grammar when using methods like `3.day.ago`.
Rails/PluralizationGrammar:
926
  Enabled: true
927 928

# Checks for `read_attribute(:attr)` and `write_attribute(:attr, val)`.
929 930 931
Rails/ReadWriteAttribute:
  Enabled: false

932
# Checks the arguments of ActiveRecord scopes.
933
Rails/ScopeArgs:
934
  Enabled: true
935

Douwe Maan's avatar
Douwe Maan committed
936
# This cop checks for the use of Time methods without zone.
Douwe Maan's avatar
Douwe Maan committed
937 938 939
Rails/TimeZone:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
940
# This cop checks for the use of old-style attribute validation macros.
Douwe Maan's avatar
Douwe Maan committed
941 942 943
Rails/Validation:
  Enabled: true

944
# RSpec #######################################################################
Robert Speicher's avatar
Robert Speicher committed
945

946
# Check that instances are not being stubbed globally.
Robert Speicher's avatar
Robert Speicher committed
947 948 949
RSpec/AnyInstance:
  Enabled: false

950 951
# Check for expectations where `be(...)` can replace `eql(...)`.
RSpec/BeEql:
952
  Enabled: true
953

954 955
# Check that the first argument to the top level describe is the tested class or
# module.
Robert Speicher's avatar
Robert Speicher committed
956 957 958
RSpec/DescribeClass:
  Enabled: false

959
# Use `described_class` for tested class / module.
Robert Speicher's avatar
Robert Speicher committed
960 961 962
RSpec/DescribeMethod:
  Enabled: false

963 964 965 966
# Avoid describing symbols.
RSpec/DescribeSymbol:
  Enabled: true

967 968 969
# Checks that the second argument to top level describe is the tested method
# name.
RSpec/DescribedClass:
Robert Speicher's avatar