.rubocop.yml 24.9 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 497 498
Style/TrailingCommaInLiteral:
  Enabled: false

499
# Checks for %W when interpolation is not needed.
500
Style/UnneededCapitalW:
501
  Enabled: true
502

503
# Checks for %q/%Q when single quotes or double quotes would do.
504 505 506
Style/UnneededPercentQ:
  Enabled: false

507
# Don't interpolate global, instance and class variables directly in strings.
508
Style/VariableInterpolation:
509
  Enabled: true
510

511
# Use the configured style when naming variables.
512
Style/VariableName:
513 514
  EnforcedStyle: snake_case
  Enabled: true
515

516 517 518 519
# Use the configured style when numbering variables.
Style/VariableNumber:
  Enabled: false

520
# Use when x then ... for one-line cases.
521
Style/WhenThen:
522
  Enabled: true
523

524
# Checks for redundant do after while or until.
525
Style/WhileUntilDo:
526
  Enabled: true
527

528
# Favor modifier while/until usage when you have a single-line body.
529
Style/WhileUntilModifier:
530
  Enabled: true
531

532
# Use %w or %W for arrays of words.
533
Style/WordArray:
Douwe Maan's avatar
Douwe Maan committed
534
  Enabled: true
535

536
# Metrics #####################################################################
537

538 539
# A calculated magnitude based on number of assignments,
# branches, and conditions.
540
Metrics/AbcSize:
Grzegorz Bizon's avatar
Grzegorz Bizon committed
541
  Enabled: true
542
  Max: 60
Grzegorz Bizon's avatar
Grzegorz Bizon committed
543

Douwe Maan's avatar
Douwe Maan committed
544
# This cop checks if the length of a block exceeds some maximum value.
Douwe Maan's avatar
Douwe Maan committed
545 546 547
Metrics/BlockLength:
  Enabled: false

548
# Avoid excessive block nesting.
549
Metrics/BlockNesting:
Grzegorz Bizon's avatar
Grzegorz Bizon committed
550 551
  Enabled: true
  Max: 4
552

553
# Avoid classes longer than 100 lines of code.
554 555 556
Metrics/ClassLength:
  Enabled: false

557 558 559 560 561 562 563
# A complexity metric that is strongly correlated to the number
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity:
  Enabled: true
  Max: 17

# Limit lines to 80 characters.
564 565 566
Metrics/LineLength:
  Enabled: false

567
# Avoid methods longer than 10 lines of code.
568 569 570
Metrics/MethodLength:
  Enabled: false

571
# Avoid modules longer than 100 lines of code.
572 573 574
Metrics/ModuleLength:
  Enabled: false

575 576 577 578 579 580 581 582
# 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
583
  Max: 18
584

585
# Lint ########################################################################
586

587 588
# Checks for ambiguous operators in the first argument of a method invocation
# without parentheses.
589
Lint/AmbiguousOperator:
590
  Enabled: true
591

Douwe Maan's avatar
Douwe Maan committed
592 593
# This cop checks for ambiguous regexp literals in the first argument of
# a method invocation without parentheses.
Douwe Maan's avatar
Douwe Maan committed
594 595 596
Lint/AmbiguousRegexpLiteral:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
597 598
# This cop checks for assignments in the conditions of
# if/while/until.
Douwe Maan's avatar
Douwe Maan committed
599 600 601
Lint/AssignmentInCondition:
  Enabled: false

602
# Align block ends correctly.
603
Lint/BlockAlignment:
604
  Enabled: true
605

606 607 608
# Default values in optional keyword arguments and optional ordinal arguments
# should not refer back to the name of the argument.
Lint/CircularArgumentReference:
609
  Enabled: true
610 611

# Checks for condition placed in a confusing position relative to the keyword.
612
Lint/ConditionPosition:
613
  Enabled: true
614

615
# Check for debugger calls.
616
Lint/Debugger:
617
  Enabled: true
618

619
# Align ends corresponding to defs correctly.
620
Lint/DefEndAlignment:
621
  Enabled: true
622

623
# Check for deprecated class method calls.
624
Lint/DeprecatedClassMethods:
625
  Enabled: true
626

627 628
# Check for immutable argument given to each_with_object.
Lint/EachWithObjectArgument:
629
  Enabled: true
630 631

# Check for odd code arrangement in an else block.
632
Lint/ElseLayout:
633
  Enabled: true
634

635
# Checks for empty ensure block.
636
Lint/EmptyEnsure:
637
  Enabled: true
638

639 640 641 642
# Checks for the presence of `when` branches without a body.
Lint/EmptyWhen:
  Enabled: true

643
# Align ends correctly.
644
Lint/EndAlignment:
645
  Enabled: true
646

647
# END blocks should not be placed inside method definitions.
648
Lint/EndInMethod:
649
  Enabled: true
650

651
# Do not use return in an ensure block.
652
Lint/EnsureReturn:
653
  Enabled: true
654

655 656
# Catches floating-point literals too large or small for Ruby to represent.
Lint/FloatOutOfRange:
657
  Enabled: true
658 659 660

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

Douwe Maan's avatar
Douwe Maan committed
663
# This cop checks for *rescue* blocks with no body.
Douwe Maan's avatar
Douwe Maan committed
664 665 666
Lint/HandleExceptions:
  Enabled: false

667 668 669
# Checks for adjacent string literals on the same line, which could better be
# represented as a single string literal.
Lint/ImplicitStringConcatenation:
670
  Enabled: true
671

Douwe Maan's avatar
Douwe Maan committed
672 673 674 675 676
# Checks for attempts to use `private` or `protected` to set the visibility
# of a class method, which does not work.
Lint/IneffectiveAccessModifier:
  Enabled: false

677 678
# Checks for invalid character literals with a non-escaped whitespace
# character.
679
Lint/InvalidCharacterLiteral:
680
  Enabled: true
681

682
# Checks of literals used in conditions.
683
Lint/LiteralInCondition:
684
  Enabled: true
685

686
# Checks for literals used in interpolation.
687
Lint/LiteralInInterpolation:
688
  Enabled: true
689

Douwe Maan's avatar
Douwe Maan committed
690
# This cop checks for uses of *begin...end while/until something*.
Douwe Maan's avatar
Douwe Maan committed
691 692 693
Lint/Loop:
  Enabled: false

694 695
# Do not use nested method definitions.
Lint/NestedMethodDefinition:
696
  Enabled: true
697 698 699

# Do not omit the accumulator when calling `next` in a `reduce`/`inject` block.
Lint/NextWithoutAccumulator:
700
  Enabled: true
701 702

# Checks for method calls with a space before the opening parenthesis.
703
Lint/ParenthesesAsGroupedExpression:
704
  Enabled: true
705

706 707 708
# Checks for `rand(1)` calls. Such calls always return `0` and most likely
# a mistake.
Lint/RandOne:
709
  Enabled: true
710 711

# Use parentheses in the method call to avoid confusion about precedence.
712
Lint/RequireParentheses:
713
  Enabled: true
714

715
# Avoid rescuing the Exception class.
716
Lint/RescueException:
717
  Enabled: true
718

Connor Shea's avatar
Connor Shea committed
719 720
# Checks for the order which exceptions are rescued to avoid rescueing a less specific exception before a more specific exception.
Lint/ShadowedException:
721 722
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
723 724
# 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
725 726 727
Lint/ShadowingOuterLocalVariable:
  Enabled: false

728 729 730 731
# Checks for Object#to_s usage in string interpolation.
Lint/StringConversionInInterpolation:
  Enabled: true

732
# Do not use prefix `_` for a variable that is used.
733
Lint/UnderscorePrefixedVariableName:
734
  Enabled: true
735

Douwe Maan's avatar
Douwe Maan committed
736
# This cop checks for using Fixnum or Bignum constant
Douwe Maan's avatar
Douwe Maan committed
737 738 739
Lint/UnifiedInteger:
  Enabled: true

740 741 742 743 744 745
# 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
746
# This cop checks for unneeded usages of splat expansion
Douwe Maan's avatar
Douwe Maan committed
747 748 749
Lint/UnneededSplatExpansion:
  Enabled: false

750
# Unreachable code.
751
Lint/UnreachableCode:
752
  Enabled: true
753

Douwe Maan's avatar
Douwe Maan committed
754
# This cop checks for unused block arguments.
Douwe Maan's avatar
Douwe Maan committed
755 756 757
Lint/UnusedBlockArgument:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
758
# This cop checks for unused method arguments.
759 760 761
Lint/UnusedMethodArgument:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
762 763 764 765
# Checks for useless access modifiers.
Lint/UselessAccessModifier:
  Enabled: true

766
# Checks for useless assignment to a local variable.
767
Lint/UselessAssignment:
768
  Enabled: true
769

770
# Checks for comparison of something with itself.
771
Lint/UselessComparison:
772
  Enabled: true
773

774
# Checks for useless `else` in `begin..end` without `rescue`.
775
Lint/UselessElseWithoutRescue:
776
  Enabled: true
777

778
# Checks for useless setter call to a local variable.
779
Lint/UselessSetterCall:
780
  Enabled: true
781

782
# Possible use of operator/literal/variable in void context.
783
Lint/Void:
784
  Enabled: true
785

786
# Performance #################################################################
787 788 789

# Use `casecmp` rather than `downcase ==`.
Performance/Casecmp:
790
  Enabled: true
791 792 793 794

# Use `str.{start,end}_with?(x, ..., y, ...)` instead of
# `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
Performance/DoubleStartEndWith:
795
  Enabled: true
796 797 798

# Use `strip` instead of `lstrip.rstrip`.
Performance/LstripRstrip:
Connor Shea's avatar
Connor Shea committed
799
  Enabled: true
800 801 802

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

Douwe Maan's avatar
Douwe Maan committed
805 806
# 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
807 808 809
Performance/RedundantBlockCall:
  Enabled: true

Douwe Maan's avatar
Douwe Maan committed
810 811
# 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
812 813 814
Performance/RedundantMatch:
  Enabled: true

Douwe Maan's avatar
Douwe Maan committed
815 816
# This cop identifies places where `Hash#merge!` can be replaced by
# `Hash#[]=`.
Douwe Maan's avatar
Douwe Maan committed
817 818 819 820
Performance/RedundantMerge:
  Enabled: true
  MaxKeyValuePairs: 1

821 822
# Use `sort` instead of `sort_by { |x| x }`.
Performance/RedundantSortBy:
823
  Enabled: true
824 825 826 827

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

830 831 832 833
# 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:
834
  Enabled: true
835 836 837

# Checks for `.times.map` calls.
Performance/TimesMap:
838
  Enabled: true
839

Douwe Maan's avatar
Douwe Maan committed
840 841
# Security ####################################################################

Douwe Maan's avatar
Douwe Maan committed
842 843
# This cop checks for the use of JSON class methods which have potential
# security issues.
Douwe Maan's avatar
Douwe Maan committed
844 845 846
Security/JSONLoad:
  Enabled: true

847 848 849 850
# This cop checks for the use of *Kernel#eval*.
Security/Eval:
  Enabled: true

851
# Rails #######################################################################
852

853 854 855 856 857
# Enables Rails cops.
Rails:
  Enabled: true

# Enforces consistent use of action filter methods.
858
Rails/ActionFilter:
859
  Enabled: true
860
  EnforcedStyle: action
861

862 863
# Checks the correct usage of date aware methods, such as `Date.today`,
# `Date.current`, etc.
864 865 866
Rails/Date:
  Enabled: false

867 868
# Prefer delegate method for delegations.
Rails/Delegate:
Douwe Maan's avatar
Douwe Maan committed
869
  Enabled: true
870

Douwe Maan's avatar
Douwe Maan committed
871
# This cop checks dynamic `find_by_*` methods.
Douwe Maan's avatar
Douwe Maan committed
872 873 874
Rails/DynamicFindBy:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
875
# This cop enforces that 'exit' calls are not used within a rails app.
Douwe Maan's avatar
Douwe Maan committed
876 877 878 879 880 881
Rails/Exit:
  Enabled: true
  Exclude:
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'

882 883
# Prefer `find_by` over `where.first`.
Rails/FindBy:
884
  Enabled: true
885 886 887

# Prefer `all.find_each` over `all.find`.
Rails/FindEach:
888
  Enabled: true
889

890
# Prefer has_many :through to has_and_belongs_to_many.
891
Rails/HasAndBelongsToMany:
892
  Enabled: true
893

Douwe Maan's avatar
Douwe Maan committed
894 895 896
# 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
897 898 899
Rails/HttpPositionalArguments:
  Enabled: false

900
# Checks for calls to puts, print, etc.
901
Rails/Output:
902
  Enabled: true
903 904 905 906 907
  Exclude:
    - lib/gitlab/seeder.rb
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
908

Douwe Maan's avatar
Douwe Maan committed
909 910
# This cop checks for the use of output safety calls like html_safe and
# raw.
Douwe Maan's avatar
Douwe Maan committed
911 912 913
Rails/OutputSafety:
  Enabled: false

914 915
# Checks for incorrect grammar when using methods like `3.day.ago`.
Rails/PluralizationGrammar:
916
  Enabled: true
917 918

# Checks for `read_attribute(:attr)` and `write_attribute(:attr, val)`.
919 920 921
Rails/ReadWriteAttribute:
  Enabled: false

922
# Checks the arguments of ActiveRecord scopes.
923
Rails/ScopeArgs:
924
  Enabled: true
925

Douwe Maan's avatar
Douwe Maan committed
926
# This cop checks for the use of Time methods without zone.
Douwe Maan's avatar
Douwe Maan committed
927 928 929
Rails/TimeZone:
  Enabled: false

Douwe Maan's avatar
Douwe Maan committed
930
# This cop checks for the use of old-style attribute validation macros.
Douwe Maan's avatar
Douwe Maan committed
931 932 933
Rails/Validation:
  Enabled: true

934
# RSpec #######################################################################
Robert Speicher's avatar
Robert Speicher committed
935

936
# Check that instances are not being stubbed globally.
Robert Speicher's avatar
Robert Speicher committed
937 938 939
RSpec/AnyInstance:
  Enabled: false

940 941
# Check for expectations where `be(...)` can replace `eql(...)`.
RSpec/BeEql:
942
  Enabled: true
943

944 945
# Check that the first argument to the top level describe is the tested class or
# module.
Robert Speicher's avatar
Robert Speicher committed
946 947 948
RSpec/DescribeClass:
  Enabled: false

949
# Use `described_class` for tested class / module.
Robert Speicher's avatar
Robert Speicher committed
950 951 952
RSpec/DescribeMethod:
  Enabled: false

953 954 955
# Checks that the second argument to top level describe is the tested method
# name.
RSpec/DescribedClass:
Robert Speicher's avatar
Robert Speicher committed
956 957
  Enabled: false

958
# Checks for long example.
Robert Speicher's avatar
Robert Speicher committed
959 960 961 962
RSpec/ExampleLength:
  Enabled: false
  Max: 5

963
# Do not use should when describing your tests.
Robert Speicher's avatar
Robert Speicher committed
964 965 966 967 968 969 970 971
RSpec/ExampleWording:
  Enabled: false
  CustomTransform:
    be: is
    have: has
    not: does not
  IgnoredWords: []

972 973 974 975
# Checks for `expect(...)` calls containing literal values.
RSpec/ExpectActual:
  Enabled