.rubocop.yml 26.0 KB
Newer Older
1 2 3
require:
  - rubocop-rspec
  - ./rubocop/rubocop
R
Robert Speicher 已提交
4

Z
Z.J. van de Weg 已提交
5 6
inherit_from: .rubocop_todo.yml

7
AllCops:
Z
Z.J. van de Weg 已提交
8
  TargetRubyVersion: 2.3
Z
Z.J. van de Weg 已提交
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/**/*'
M
Mike Greiling 已提交
20
    - 'node_modules/**/*'
S
Sean McGivern 已提交
21 22
    - 'db/*'
    - 'db/fixtures/**/*'
23 24
    - 'tmp/**/*'
    - 'bin/**/*'
25
    - 'generator_templates/**/*'
26
    - 'builds/**/*'
27

D
Douwe Maan 已提交
28
# Gems in consecutive lines should be alphabetically sorted
D
Douwe Maan 已提交
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

C
Connor Shea 已提交
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

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

D
Douwe Maan 已提交
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:
D
Dmitriy Zaporozhets 已提交
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

D
Douwe Maan 已提交
94 95 96 97
# Put end statement of multiline block on its own line.
Style/BlockEndNewline:
  Enabled: true

D
Douwe Maan 已提交
98 99
 # This cop checks for braces around the last parameter in a method call
# if the last parameter is a hash.
D
Douwe Maan 已提交
100 101 102
Style/BracesAroundHashParameters:
  Enabled: false

D
Douwe Maan 已提交
103
# This cop checks for uses of the case equality operator(===).
D
Douwe Maan 已提交
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:
D
Dmitriy Zaporozhets 已提交
113
  Enabled: true
114

115
# Use CamelCase for classes and modules.'
116
Style/ClassAndModuleCamelCase:
D
Dmitriy Zaporozhets 已提交
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:
D
Douwe Maan 已提交
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:
D
Dmitriy Zaporozhets 已提交
133
  Enabled: true
134

D
Douwe Maan 已提交
135 136
# This cop checks for methods invoked via the :: operator instead
# of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).
D
Douwe Maan 已提交
137 138 139
Style/ColonMethodCall:
  Enabled: true

D
Douwe Maan 已提交
140 141
# This cop checks that comment annotation keywords are written according
# to guidelines.
D
Douwe Maan 已提交
142 143 144
Style/CommentAnnotation:
  Enabled: false

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

D
Douwe Maan 已提交
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.
D
Douwe Maan 已提交
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

D
Douwe Maan 已提交
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.
D
Douwe Maan 已提交
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:
D
Douwe Maan 已提交
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

D
Douwe Maan 已提交
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:
G
Grzegorz Bizon 已提交
232
  Enabled: true
233

Z
Z.J. van de Weg 已提交
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

D
Douwe Maan 已提交
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
G
Gabriel Mazetto 已提交
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:
F
Felipe Artur 已提交
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

C
Connor Shea 已提交
292 293 294 295
# Checks for usage of `extend self` in modules.
Style/ModuleFunction:
  Enabled: false

R
Robert Speicher 已提交
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
R
Robert Speicher 已提交
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

R
Robert Speicher 已提交
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
R
Robert Speicher 已提交
314 315
  EnforcedStyle: symmetrical

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

R
Robert Speicher 已提交
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

D
Douwe Maan 已提交
345 346
# This cop checks whether some constant value isn't a
# mutable literal (e.g. array or hash).
D
Douwe Maan 已提交
347 348
Style/MutableConstant:
  Enabled: true
349 350 351
  Exclude:
    - 'db/migrate/**/*'
    - 'db/post_migrate/**/*'
D
Douwe Maan 已提交
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 397 398 399
# 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:
400
  Enabled: false
401

402 403 404 405
# Checks for an obsolete RuntimeException argument in raise/fail.
Style/RedundantException:
  Enabled: true

406 407
# Checks for parentheses that seem not to serve any purpose.
Style/RedundantParentheses:
408
  Enabled: true
409 410

# Don't use semicolons to terminate expressions.
411
Style/Semicolon:
412
  Enabled: true
413

414
# Checks for proper usage of fail and raise.
415
Style/SignalException:
416 417
  EnforcedStyle: only_raise
  Enabled: true
418

419
# Use spaces after colons.
420
Style/SpaceAfterColon:
421
  Enabled: true
422

423
# Use spaces after commas.
424
Style/SpaceAfterComma:
425
  Enabled: true
426

427 428
# Do not put a space between a method name and the opening parenthesis in a
# method definition.
429
Style/SpaceAfterMethodName:
430
  Enabled: true
431

432
# Tracks redundant space after the ! operator.
433
Style/SpaceAfterNot:
434
  Enabled: true
435

436
# Use spaces after semicolons.
437
Style/SpaceAfterSemicolon:
438
  Enabled: true
439

440 441 442 443
# Use space around equals in parameter default
Style/SpaceAroundEqualsInParameterDefault:
  Enabled: true

444 445
# Use a space around keywords if appropriate.
Style/SpaceAroundKeyword:
446
  Enabled: true
447

448 449
# Use a single space around operators.
Style/SpaceAroundOperators:
G
Gabriel Mazetto 已提交
450
  Enabled: true
451

452 453
# No spaces before commas.
Style/SpaceBeforeComma:
454
  Enabled: true
455

456 457
# Checks for missing space between code and a comment on the same line.
Style/SpaceBeforeComment:
458
  Enabled: true
459

460 461
# No spaces before semicolons.
Style/SpaceBeforeSemicolon:
462
  Enabled: true
463

D
Douwe Maan 已提交
464
# Checks for spaces inside square brackets.
D
Douwe Maan 已提交
465 466 467
Style/SpaceInsideBrackets:
  Enabled: true

468
# Use spaces inside hash literal braces - or don't.
469
Style/SpaceInsideHashLiteralBraces:
470
  Enabled: true
471

472
# No spaces inside range literals.
473
Style/SpaceInsideRangeLiteral:
474
  Enabled: true
475

476 477
# Checks for padding/surrounding spaces inside string interpolation.
Style/SpaceInsideStringInterpolation:
478 479
  EnforcedStyle: no_space
  Enabled: true
480 481 482

# Check for the usage of parentheses around stabby lambda arguments.
Style/StabbyLambdaParentheses:
483 484
  EnforcedStyle: require_parentheses
  Enabled: true
485 486

# Checks if uses of quotes match the configured preference.
487 488 489
Style/StringLiterals:
  Enabled: false

490 491
# Checks if configured preferred methods are used over non-preferred.
Style/StringMethods:
492 493 494
  PreferredMethods:
    intern: to_sym
  Enabled: true
495 496

# No hard tabs.
497
Style/Tab:
D
Dmitriy Zaporozhets 已提交
498
  Enabled: true
499

500
# Checks trailing blank lines and final newline.
501
Style/TrailingBlankLines:
502
  Enabled: true
503

D
Douwe Maan 已提交
504
# This cop checks for trailing comma in array and hash literals.
505
Style/TrailingCommaInLiteral:
506 507
  Enabled: true
  EnforcedStyleForMultiline: no_comma
508

509 510 511 512 513
# This cop checks for trailing comma in argument lists.
Style/TrailingCommaInArguments:
  Enabled: true
  EnforcedStyleForMultiline: no_comma

514
# Checks for %W when interpolation is not needed.
515
Style/UnneededCapitalW:
516
  Enabled: true
517

518
# Checks for %q/%Q when single quotes or double quotes would do.
519 520 521
Style/UnneededPercentQ:
  Enabled: false

522
# Don't interpolate global, instance and class variables directly in strings.
523
Style/VariableInterpolation:
524
  Enabled: true
525

526
# Use the configured style when naming variables.
527
Style/VariableName:
528 529
  EnforcedStyle: snake_case
  Enabled: true
530

531 532 533 534
# Use the configured style when numbering variables.
Style/VariableNumber:
  Enabled: false

535
# Use when x then ... for one-line cases.
536
Style/WhenThen:
537
  Enabled: true
538

539
# Checks for redundant do after while or until.
540
Style/WhileUntilDo:
541
  Enabled: true
542

543
# Favor modifier while/until usage when you have a single-line body.
544
Style/WhileUntilModifier:
545
  Enabled: true
546

547
# Use %w or %W for arrays of words.
548
Style/WordArray:
D
Douwe Maan 已提交
549
  Enabled: true
550

M
mhasbini 已提交
551 552 553 554
# Use `proc` instead of `Proc.new`.
Style/Proc:
  Enabled: true

555
# Metrics #####################################################################
556

557 558
# A calculated magnitude based on number of assignments,
# branches, and conditions.
559
Metrics/AbcSize:
G
Grzegorz Bizon 已提交
560
  Enabled: true
M
Maxim Rydkin 已提交
561
  Max: 57.08
G
Grzegorz Bizon 已提交
562

D
Douwe Maan 已提交
563
# This cop checks if the length of a block exceeds some maximum value.
D
Douwe Maan 已提交
564 565 566
Metrics/BlockLength:
  Enabled: false

567
# Avoid excessive block nesting.
568
Metrics/BlockNesting:
G
Grzegorz Bizon 已提交
569 570
  Enabled: true
  Max: 4
571

572
# Avoid classes longer than 100 lines of code.
573 574 575
Metrics/ClassLength:
  Enabled: false

576 577 578 579
# A complexity metric that is strongly correlated to the number
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity:
  Enabled: true
580
  Max: 16
581 582

# Limit lines to 80 characters.
583 584 585
Metrics/LineLength:
  Enabled: false

586
# Avoid methods longer than 10 lines of code.
587 588 589
Metrics/MethodLength:
  Enabled: false

590
# Avoid modules longer than 100 lines of code.
591 592 593
Metrics/ModuleLength:
  Enabled: false

594 595 596 597 598 599 600 601
# Avoid parameter lists longer than three or four parameters.
Metrics/ParameterLists:
  Enabled: true
  Max: 8

# A complexity metric geared towards measuring complexity for a human reader.
Metrics/PerceivedComplexity:
  Enabled: true
V
Valery Sizov 已提交
602
  Max: 18
603

604
# Lint ########################################################################
605

606 607
# Checks for ambiguous operators in the first argument of a method invocation
# without parentheses.
608
Lint/AmbiguousOperator:
609
  Enabled: true
610

D
Douwe Maan 已提交
611 612
# This cop checks for ambiguous regexp literals in the first argument of
# a method invocation without parentheses.
D
Douwe Maan 已提交
613 614 615
Lint/AmbiguousRegexpLiteral:
  Enabled: false

D
Douwe Maan 已提交
616 617
# This cop checks for assignments in the conditions of
# if/while/until.
D
Douwe Maan 已提交
618 619 620
Lint/AssignmentInCondition:
  Enabled: false

621
# Align block ends correctly.
622
Lint/BlockAlignment:
623
  Enabled: true
624

625 626 627
# Default values in optional keyword arguments and optional ordinal arguments
# should not refer back to the name of the argument.
Lint/CircularArgumentReference:
628
  Enabled: true
629 630

# Checks for condition placed in a confusing position relative to the keyword.
631
Lint/ConditionPosition:
632
  Enabled: true
633

634
# Check for debugger calls.
635
Lint/Debugger:
636
  Enabled: true
637

638
# Align ends corresponding to defs correctly.
639
Lint/DefEndAlignment:
640
  Enabled: true
641

642
# Check for deprecated class method calls.
643
Lint/DeprecatedClassMethods:
644
  Enabled: true
645

646 647
# Check for immutable argument given to each_with_object.
Lint/EachWithObjectArgument:
648
  Enabled: true
649 650

# Check for odd code arrangement in an else block.
651
Lint/ElseLayout:
652
  Enabled: true
653

654
# Checks for empty ensure block.
655
Lint/EmptyEnsure:
656
  Enabled: true
657

658 659 660 661
# Checks for the presence of `when` branches without a body.
Lint/EmptyWhen:
  Enabled: true

662
# Align ends correctly.
663
Lint/EndAlignment:
664
  Enabled: true
665

666
# END blocks should not be placed inside method definitions.
667
Lint/EndInMethod:
668
  Enabled: true
669

670
# Do not use return in an ensure block.
671
Lint/EnsureReturn:
672
  Enabled: true
673

674 675
# Catches floating-point literals too large or small for Ruby to represent.
Lint/FloatOutOfRange:
676
  Enabled: true
677 678 679

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

D
Douwe Maan 已提交
682
# This cop checks for *rescue* blocks with no body.
D
Douwe Maan 已提交
683 684 685
Lint/HandleExceptions:
  Enabled: false

686 687 688
# Checks for adjacent string literals on the same line, which could better be
# represented as a single string literal.
Lint/ImplicitStringConcatenation:
689
  Enabled: true
690

D
Douwe Maan 已提交
691 692 693 694 695
# Checks for attempts to use `private` or `protected` to set the visibility
# of a class method, which does not work.
Lint/IneffectiveAccessModifier:
  Enabled: false

696 697
# Checks for invalid character literals with a non-escaped whitespace
# character.
698
Lint/InvalidCharacterLiteral:
699
  Enabled: true
700

701
# Checks of literals used in conditions.
702
Lint/LiteralInCondition:
703
  Enabled: true
704

705
# Checks for literals used in interpolation.
706
Lint/LiteralInInterpolation:
707
  Enabled: true
708

D
Douwe Maan 已提交
709
# This cop checks for uses of *begin...end while/until something*.
D
Douwe Maan 已提交
710 711 712
Lint/Loop:
  Enabled: false

713 714
# Do not use nested method definitions.
Lint/NestedMethodDefinition:
715
  Enabled: true
716 717 718

# Do not omit the accumulator when calling `next` in a `reduce`/`inject` block.
Lint/NextWithoutAccumulator:
719
  Enabled: true
720 721

# Checks for method calls with a space before the opening parenthesis.
722
Lint/ParenthesesAsGroupedExpression:
723
  Enabled: true
724

725 726 727
# Checks for `rand(1)` calls. Such calls always return `0` and most likely
# a mistake.
Lint/RandOne:
728
  Enabled: true
729 730

# Use parentheses in the method call to avoid confusion about precedence.
731
Lint/RequireParentheses:
732
  Enabled: true
733

734
# Avoid rescuing the Exception class.
735
Lint/RescueException:
736
  Enabled: true
737

C
Connor Shea 已提交
738 739
# Checks for the order which exceptions are rescued to avoid rescueing a less specific exception before a more specific exception.
Lint/ShadowedException:
740 741
  Enabled: false

D
Douwe Maan 已提交
742 743
# This cop looks for use of the same name as outer local variables
# for block arguments or block local variables.
D
Douwe Maan 已提交
744 745 746
Lint/ShadowingOuterLocalVariable:
  Enabled: false

747 748 749 750
# Checks for Object#to_s usage in string interpolation.
Lint/StringConversionInInterpolation:
  Enabled: true

751
# Do not use prefix `_` for a variable that is used.
752
Lint/UnderscorePrefixedVariableName:
753
  Enabled: true
754

D
Douwe Maan 已提交
755
# This cop checks for using Fixnum or Bignum constant
D
Douwe Maan 已提交
756 757 758
Lint/UnifiedInteger:
  Enabled: true

759 760 761 762 763 764
# Checks for rubocop:disable comments that can be removed.
# Note: this cop is not disabled when disabling all cops.
# It must be explicitly disabled.
Lint/UnneededDisable:
  Enabled: false

D
Douwe Maan 已提交
765
# This cop checks for unneeded usages of splat expansion
D
Douwe Maan 已提交
766 767 768
Lint/UnneededSplatExpansion:
  Enabled: false

769
# Unreachable code.
770
Lint/UnreachableCode:
771
  Enabled: true
772

D
Douwe Maan 已提交
773
# This cop checks for unused block arguments.
D
Douwe Maan 已提交
774 775 776
Lint/UnusedBlockArgument:
  Enabled: false

D
Douwe Maan 已提交
777
# This cop checks for unused method arguments.
D
Douwe Maan 已提交
778 779 780
Lint/UnusedMethodArgument:
  Enabled: false

D
Douwe Maan 已提交
781 782 783 784
# Checks for useless access modifiers.
Lint/UselessAccessModifier:
  Enabled: true

785
# Checks for useless assignment to a local variable.
786
Lint/UselessAssignment:
787
  Enabled: true
788

789
# Checks for comparison of something with itself.
790
Lint/UselessComparison:
791
  Enabled: true
792

793
# Checks for useless `else` in `begin..end` without `rescue`.
794
Lint/UselessElseWithoutRescue:
795
  Enabled: true
796

797
# Checks for useless setter call to a local variable.
798
Lint/UselessSetterCall:
799
  Enabled: true
800

801
# Possible use of operator/literal/variable in void context.
802
Lint/Void:
803
  Enabled: true
804

805
# Performance #################################################################
806 807 808

# Use `casecmp` rather than `downcase ==`.
Performance/Casecmp:
809
  Enabled: true
810 811 812 813

# Use `str.{start,end}_with?(x, ..., y, ...)` instead of
# `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
Performance/DoubleStartEndWith:
814
  Enabled: true
815 816 817

# Use `strip` instead of `lstrip.rstrip`.
Performance/LstripRstrip:
C
Connor Shea 已提交
818
  Enabled: true
819 820 821

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

D
Douwe Maan 已提交
824 825
# This cop identifies the use of a `&block` parameter and `block.call`
# where `yield` would do just as well.
D
Douwe Maan 已提交
826 827 828
Performance/RedundantBlockCall:
  Enabled: true

D
Douwe Maan 已提交
829 830
# This cop identifies use of `Regexp#match` or `String#match in a context
# where the integral return value of `=~` would do just as well.
D
Douwe Maan 已提交
831 832 833
Performance/RedundantMatch:
  Enabled: true

D
Douwe Maan 已提交
834 835
# This cop identifies places where `Hash#merge!` can be replaced by
# `Hash#[]=`.
D
Douwe Maan 已提交
836 837 838 839
Performance/RedundantMerge:
  Enabled: true
  MaxKeyValuePairs: 1

840 841
# Use `sort` instead of `sort_by { |x| x }`.
Performance/RedundantSortBy:
842
  Enabled: true
843 844 845 846

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

849 850 851 852
# Use `tr` instead of `gsub` when you are replacing the same number of
# characters. Use `delete` instead of `gsub` when you are deleting
# characters.
Performance/StringReplacement:
C
Connor Shea 已提交
853
  Enabled: true
854 855 856

# Checks for `.times.map` calls.
Performance/TimesMap:
857
  Enabled: true
858

D
Douwe Maan 已提交
859 860
# Security ####################################################################

D
Douwe Maan 已提交
861 862
# This cop checks for the use of JSON class methods which have potential
# security issues.
D
Douwe Maan 已提交
863 864 865
Security/JSONLoad:
  Enabled: true

866 867 868 869
# This cop checks for the use of *Kernel#eval*.
Security/Eval:
  Enabled: true

870
# Rails #######################################################################
871

872 873 874 875 876
# Enables Rails cops.
Rails:
  Enabled: true

# Enforces consistent use of action filter methods.
877
Rails/ActionFilter:
878
  Enabled: true
879
  EnforcedStyle: action
880

881 882
# Checks the correct usage of date aware methods, such as `Date.today`,
# `Date.current`, etc.
G
Gabriel Mazetto 已提交
883 884 885
Rails/Date:
  Enabled: false

886 887
# Prefer delegate method for delegations.
Rails/Delegate:
D
Douwe Maan 已提交
888
  Enabled: true
889

D
Douwe Maan 已提交
890
# This cop checks dynamic `find_by_*` methods.
D
Douwe Maan 已提交
891 892 893
Rails/DynamicFindBy:
  Enabled: false

D
Douwe Maan 已提交
894
# This cop enforces that 'exit' calls are not used within a rails app.
D
Douwe Maan 已提交
895 896 897 898 899 900
Rails/Exit:
  Enabled: true
  Exclude:
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'

901 902
# Prefer `find_by` over `where.first`.
Rails/FindBy:
903
  Enabled: true
904 905 906

# Prefer `all.find_each` over `all.find`.
Rails/FindEach:
907
  Enabled: true
908

909
# Prefer has_many :through to has_and_belongs_to_many.
910
Rails/HasAndBelongsToMany:
911
  Enabled: true
912

D
Douwe Maan 已提交
913 914 915
# This cop is used to identify usages of http methods like `get`, `post`,
# `put`, `patch` without the usage of keyword arguments in your tests and
# change them to use keyword args.
D
Douwe Maan 已提交
916 917 918
Rails/HttpPositionalArguments:
  Enabled: false

919
# Checks for calls to puts, print, etc.
920
Rails/Output:
921
  Enabled: true
922 923 924 925 926
  Exclude:
    - lib/gitlab/seeder.rb
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
927

D
Douwe Maan 已提交
928 929
# This cop checks for the use of output safety calls like html_safe and
# raw.
D
Douwe Maan 已提交
930 931 932
Rails/OutputSafety:
  Enabled: false

933 934
# Checks for incorrect grammar when using methods like `3.day.ago`.
Rails/PluralizationGrammar:
935
  Enabled: true
936 937

# Checks for `read_attribute(:attr)` and `write_attribute(:attr, val)`.
938 939 940
Rails/ReadWriteAttribute:
  Enabled: false

941
# Checks the arguments of ActiveRecord scopes.
942
Rails/ScopeArgs:
943
  Enabled: true
944

D
Douwe Maan 已提交
945
# This cop checks for the use of Time methods without zone.
D
Douwe Maan 已提交
946 947 948
Rails/TimeZone:
  Enabled: false

D
Douwe Maan 已提交
949
# This cop checks for the use of old-style attribute validation macros.
D
Douwe Maan 已提交
950 951 952
Rails/Validation:
  Enabled: true

953
# RSpec #######################################################################
R
Robert Speicher 已提交
954

955
# Check that instances are not being stubbed globally.
R
Robert Speicher 已提交
956 957 958
RSpec/AnyInstance:
  Enabled: false

959 960
# Check for expectations where `be(...)` can replace `eql(...)`.
RSpec/BeEql:
R
Rémy Coutable 已提交
961
  Enabled: true
962

963 964
# Check that the first argument to the top level describe is the tested class or
# module.
R
Robert Speicher 已提交
965 966 967
RSpec/DescribeClass:
  Enabled: false

968
# Use `described_class` for tested class / module.
R
Robert Speicher 已提交
969 970 971
RSpec/DescribeMethod:
  Enabled: false

972 973 974 975
# Avoid describing symbols.
RSpec/DescribeSymbol:
  Enabled: true

976 977 978
# Checks that the second argument to top level describe is the tested method
# name.
RSpec/DescribedClass:
979
  Enabled: true
R
Robert Speicher 已提交
980

981
# Checks if an example group does not include any tests.
982 983 984 985 986
RSpec/EmptyExampleGroup:
  Enabled: true
  CustomIncludeMethods:
    - run_permission_checks

987
# Checks for long example.
R
Robert Speicher 已提交
988 989 990 991
RSpec/ExampleLength:
  Enabled: false
  Max: 5

992
# Do not use should when describing your tests.
R
Robert Speicher 已提交
993 994 995 996 997 998 999 1000
RSpec/ExampleWording:
  Enabled: false
  CustomTransform:
    be: is
    have: has
    not: does not
  IgnoredWords: []

1001 1002 1003 1004
# Checks for `expect(...)` calls containing literal values.
RSpec/ExpectActual:
  Enabled: true

1005
# Checks for opportunities to use `expect { … }.to output`.
1006 1007 1008
RSpec/ExpectOutput:
  Enabled: true

1009
# Checks the file and folder naming of the spec file.
R
Robert Speicher 已提交
1010
RSpec/FilePath:
S
Sean McGivern 已提交
1011 1012 1013 1014 1015 1016
  Enabled: true
  IgnoreMethods: true
  Exclude:
    - 'qa/**/*'
    - 'spec/javascripts/fixtures/*'
    - 'spec/requests/api/v3/*'
R
Robert Speicher 已提交
1017

1018
# Checks if there are focused specs.
R
Robert Speicher 已提交
1019 1020 1021
RSpec/Focus:
  Enabled: true

1022
# Checks for the usage of instance variables.
R
Robert Speicher 已提交
1023 1024 1025
RSpec/InstanceVariable:
  Enabled: false

D
Douwe Maan 已提交
1026
# Checks for `subject` definitions that come after `let` definitions.
D
Douwe Maan 已提交
1027 1028 1029
RSpec/LeadingSubject:
  Enabled: false

D
Douwe Maan 已提交
1030
# Checks unreferenced `let!` calls being used for test setup.
D
Douwe Maan 已提交
1031 1032 1033
RSpec/LetSetup:
  Enabled: false

D
Douwe Maan 已提交
1034
# Check that chains of messages are not being stubbed.
D
Douwe Maan 已提交
1035 1036 1037
RSpec/MessageChain:
  Enabled: false

D
Douwe Maan 已提交
1038
# Checks that message expectations are set using spies.
D
Douwe Maan 已提交
1039 1040 1041
RSpec/MessageSpies:
  Enabled: false

D
Douwe Maan 已提交
1042 1043
# Checks for multiple top-level describes.
RSpec/MultipleDescribes:
D
Douwe Maan 已提交
1044 1045
  Enabled: false

D
Douwe Maan 已提交
1046
# Checks if examples contain too many `expect` calls.
D
Douwe Maan 已提交
1047
RSpec/MultipleExpectations:
D
Douwe Maan 已提交
1048 1049
  Enabled: false

D
Douwe Maan 已提交
1050
# Checks for explicitly referenced test subjects.
D
Douwe Maan 已提交
1051
RSpec/NamedSubject:
D
Douwe Maan 已提交
1052 1053
  Enabled: false

D
Douwe Maan 已提交
1054
# Checks for nested example groups.
D
Douwe Maan 已提交
1055
RSpec/NestedGroups:
D
Douwe Maan 已提交
1056 1057
  Enabled: false

D
Douwe Maan 已提交
1058 1059 1060
# Enforces the usage of the same method on all negative message expectations.
RSpec/NotToNot:
  EnforcedStyle: not_to
D
Douwe Maan 已提交
1061
  Enabled: true
1062

D
Douwe Maan 已提交
1063
# Check for repeated description strings in example groups.
D
Douwe Maan 已提交
1064
RSpec/RepeatedDescription:
D
Douwe Maan 已提交
1065 1066
  Enabled: false

1067 1068
# Ensure RSpec hook blocks are always multi-line.
RSpec/SingleLineHook:
1069
  Enabled: true
1070 1071 1072 1073
  Exclude:
    - 'spec/factories/*'
    - 'spec/requests/api/v3/*'

D
Douwe Maan 已提交
1074
# Checks for stubbed test subjects.
D
Douwe Maan 已提交
1075
RSpec/SubjectStub:
D
Douwe Maan 已提交
1076 1077
  Enabled: false

D
Douwe Maan 已提交
1078 1079
# Prefer using verifying doubles over normal doubles.
RSpec/VerifiedDoubles:
D
Douwe Maan 已提交
1080
  Enabled: false