.rubocop.yml 26.4 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

167 168 169 170 171
# Multi-line method chaining should be done with leading dots.
Style/DotPosition:
  Enabled: true
  EnforcedStyle: leading

D
Douwe Maan 已提交
172 173 174
# 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 已提交
175 176 177
Style/DoubleNegation:
  Enabled: false

178
# Align elses and elsifs correctly.
179
Style/ElseAlignment:
180
  Enabled: true
181

182
# Use empty lines between defs.
183
Style/EmptyLineBetweenDefs:
D
Douwe Maan 已提交
184
  Enabled: true
185

186
# Don't use several empty lines in a row.
187
Style/EmptyLines:
188
  Enabled: true
189

190
# Keep blank lines around access modifiers.
191
Style/EmptyLinesAroundAccessModifier:
192
  Enabled: true
193

194
# Keeps track of empty lines around block bodies.
195
Style/EmptyLinesAroundBlockBody:
196
  Enabled: true
197

198
# Keeps track of empty lines around class bodies.
199
Style/EmptyLinesAroundClassBody:
200
  Enabled: true
201

202
# Keeps track of empty lines around method bodies.
203
Style/EmptyLinesAroundMethodBody:
204
  Enabled: true
205

D
Douwe Maan 已提交
206 207 208 209
# Keeps track of empty lines around module bodies.
Style/EmptyLinesAroundModuleBody:
  Enabled: true

210
# Avoid the use of END blocks.
211
Style/EndBlock:
212
  Enabled: true
213

214
# Use Unix-style line endings.
215
Style/EndOfLine:
216
  Enabled: true
217

218
# Favor the use of Fixnum#even? && Fixnum#odd?
219
Style/EvenOdd:
220
  Enabled: true
221

222
# Use snake_case for source file names.
223
Style/FileName:
224 225 226
  Enabled: true

# Checks for a line break before the first parameter in a multi-line method
227
# parameter definition.
228 229
Style/FirstMethodParameterLineBreak:
  Enabled: true
230

231
# Checks for flip flops.
232
Style/FlipFlop:
233
  Enabled: true
234

235
# Checks use of for or each in multiline loops.
236
Style/For:
G
Grzegorz Bizon 已提交
237
  Enabled: true
238

Z
Z.J. van de Weg 已提交
239 240 241
# Checks if there is a magic comment to enforce string literals
Style/FrozenStringLiteralComment:
  Enabled: false
242

243
# Do not introduce global variables.
244
Style/GlobalVars:
245
  Enabled: true
246 247 248
  Exclude:
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
249

250 251
# Prefer Ruby 1.9 hash syntax `{ a: 1, b: 2 }`
# over 1.8 syntax `{ :a => 1, :b => 2 }`.
252
Style/HashSyntax:
253
  Enabled: true
254

255 256 257
# 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:
258
  Enabled: true
259

D
Douwe Maan 已提交
260 261 262 263
# Do not use if x; .... Use the ternary operator instead.
Style/IfWithSemicolon:
  Enabled: true

264
# Checks the indentation of the first line of the right-hand-side of a
G
Gabriel Mazetto 已提交
265
# multi-line assignment.
266
Style/IndentAssignment:
267
  Enabled: true
268 269

# Keep indentation straight.
270
Style/IndentationConsistency:
271
  Enabled: true
272

273
# Use 2 spaces for indentation.
274
Style/IndentationWidth:
275
  Enabled: true
276

277
# Use Kernel#loop for infinite loops.
278
Style/InfiniteLoop:
279
  Enabled: true
280

281
# Use lambda.call(...) instead of lambda.(...).
282
Style/LambdaCall:
283
  Enabled: true
284

285
# Comments should start with a space.
286
Style/LeadingCommentSpace:
F
Felipe Artur 已提交
287
  Enabled: true
288

289
# Checks if the method definitions have or don't have parentheses.
290
Style/MethodDefParentheses:
291
  Enabled: true
292

293
# Use the configured style when naming methods.
294
Style/MethodName:
295
  Enabled: true
296

C
Connor Shea 已提交
297 298 299 300
# Checks for usage of `extend self` in modules.
Style/ModuleFunction:
  Enabled: false

R
Robert Speicher 已提交
301 302 303
# 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:
304
  Enabled: true
R
Robert Speicher 已提交
305 306
  EnforcedStyle: symmetrical

307
# Avoid multi-line chains of blocks.
308
Style/MultilineBlockChain:
309
  Enabled: true
310

311
# Ensures newlines after multiline block do statements.
312
Style/MultilineBlockLayout:
313
  Enabled: true
314

R
Robert Speicher 已提交
315 316 317
# 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:
318
  Enabled: true
R
Robert Speicher 已提交
319 320
  EnforcedStyle: symmetrical

321
# Do not use then for multi-line if/unless.
322
Style/MultilineIfThen:
323
  Enabled: true
324

R
Robert Speicher 已提交
325 326 327 328 329 330
# 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

331 332 333 334 335
# Checks indentation of method calls with the dot operator that span more than
# one line.
Style/MultilineMethodCallIndentation:
  Enabled: false

336 337 338 339 340
# 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

341
# Checks indentation of binary operations that span more than one line.
342
Style/MultilineOperationIndentation:
343 344
  Enabled: true
  EnforcedStyle: indented
345

346 347 348 349
# Avoid multi-line `? :` (the ternary operator), use if/unless instead.
Style/MultilineTernaryOperator:
  Enabled: true

D
Douwe Maan 已提交
350 351
# This cop checks whether some constant value isn't a
# mutable literal (e.g. array or hash).
D
Douwe Maan 已提交
352 353
Style/MutableConstant:
  Enabled: true
354 355 356
  Exclude:
    - 'db/migrate/**/*'
    - 'db/post_migrate/**/*'
D
Douwe Maan 已提交
357

358
# Favor unless over if for negative conditions (or control flow or).
359
Style/NegatedIf:
360
  Enabled: true
361

362 363
# Avoid using nested modifiers.
Style/NestedModifier:
364
  Enabled: true
365 366

# Use one expression per branch in a ternary operator.
367
Style/NestedTernaryOperator:
368
  Enabled: true
369

370
# Prefer x.nil? to x == nil.
371
Style/NilComparison:
372
  Enabled: true
373

374
# Checks for redundant nil checks.
375
Style/NonNilCheck:
376
  Enabled: true
377

378
# Use ! instead of not.
379
Style/Not:
380
  Enabled: true
381

382
# Add underscores to large numeric literals to improve their readability.
383 384 385
Style/NumericLiterals:
  Enabled: false

386
# Favor the ternary operator(?:) over if/then/else/end constructs.
387
Style/OneLineConditional:
388
  Enabled: true
389

390
# When defining binary operators, name the argument other.
391
Style/OpMethod:
392
  Enabled: true
393

394
# Don't use parentheses around the condition of an if/unless/while.
395
Style/ParenthesesAroundCondition:
396
  Enabled: true
397

398 399 400 401 402 403 404
# 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:
405
  Enabled: false
406

407 408 409 410
# Checks for an obsolete RuntimeException argument in raise/fail.
Style/RedundantException:
  Enabled: true

411 412
# Checks for parentheses that seem not to serve any purpose.
Style/RedundantParentheses:
413
  Enabled: true
414 415

# Don't use semicolons to terminate expressions.
416
Style/Semicolon:
417
  Enabled: true
418

419
# Checks for proper usage of fail and raise.
420
Style/SignalException:
421 422
  EnforcedStyle: only_raise
  Enabled: true
423

424
# Use spaces after colons.
425
Style/SpaceAfterColon:
426
  Enabled: true
427

428
# Use spaces after commas.
429
Style/SpaceAfterComma:
430
  Enabled: true
431

432 433
# Do not put a space between a method name and the opening parenthesis in a
# method definition.
434
Style/SpaceAfterMethodName:
435
  Enabled: true
436

437
# Tracks redundant space after the ! operator.
438
Style/SpaceAfterNot:
439
  Enabled: true
440

441
# Use spaces after semicolons.
442
Style/SpaceAfterSemicolon:
443
  Enabled: true
444

445 446 447 448
# Use space around equals in parameter default
Style/SpaceAroundEqualsInParameterDefault:
  Enabled: true

449 450
# Use a space around keywords if appropriate.
Style/SpaceAroundKeyword:
451
  Enabled: true
452

453 454
# Use a single space around operators.
Style/SpaceAroundOperators:
G
Gabriel Mazetto 已提交
455
  Enabled: true
456

457 458
# No spaces before commas.
Style/SpaceBeforeComma:
459
  Enabled: true
460

461 462
# Checks for missing space between code and a comment on the same line.
Style/SpaceBeforeComment:
463
  Enabled: true
464

465 466
# No spaces before semicolons.
Style/SpaceBeforeSemicolon:
467
  Enabled: true
468

D
Douwe Maan 已提交
469
# Checks for spaces inside square brackets.
D
Douwe Maan 已提交
470 471 472
Style/SpaceInsideBrackets:
  Enabled: true

473
# Use spaces inside hash literal braces - or don't.
474
Style/SpaceInsideHashLiteralBraces:
475
  Enabled: true
476

477
# No spaces inside range literals.
478
Style/SpaceInsideRangeLiteral:
479
  Enabled: true
480

481 482
# Checks for padding/surrounding spaces inside string interpolation.
Style/SpaceInsideStringInterpolation:
483 484
  EnforcedStyle: no_space
  Enabled: true
485 486 487

# Check for the usage of parentheses around stabby lambda arguments.
Style/StabbyLambdaParentheses:
488 489
  EnforcedStyle: require_parentheses
  Enabled: true
490 491

# Checks if uses of quotes match the configured preference.
492 493 494
Style/StringLiterals:
  Enabled: false

495 496
# Checks if configured preferred methods are used over non-preferred.
Style/StringMethods:
497 498 499
  PreferredMethods:
    intern: to_sym
  Enabled: true
500 501

# No hard tabs.
502
Style/Tab:
D
Dmitriy Zaporozhets 已提交
503
  Enabled: true
504

505
# Checks trailing blank lines and final newline.
506
Style/TrailingBlankLines:
507
  Enabled: true
508

D
Douwe Maan 已提交
509
# This cop checks for trailing comma in array and hash literals.
510
Style/TrailingCommaInLiteral:
511 512
  Enabled: true
  EnforcedStyleForMultiline: no_comma
513

514 515 516 517 518
# This cop checks for trailing comma in argument lists.
Style/TrailingCommaInArguments:
  Enabled: true
  EnforcedStyleForMultiline: no_comma

519
# Checks for %W when interpolation is not needed.
520
Style/UnneededCapitalW:
521
  Enabled: true
522

523
# Checks for %q/%Q when single quotes or double quotes would do.
524 525 526
Style/UnneededPercentQ:
  Enabled: false

527
# Don't interpolate global, instance and class variables directly in strings.
528
Style/VariableInterpolation:
529
  Enabled: true
530

531
# Use the configured style when naming variables.
532
Style/VariableName:
533 534
  EnforcedStyle: snake_case
  Enabled: true
535

536 537 538 539
# Use the configured style when numbering variables.
Style/VariableNumber:
  Enabled: false

540
# Use when x then ... for one-line cases.
541
Style/WhenThen:
542
  Enabled: true
543

544
# Checks for redundant do after while or until.
545
Style/WhileUntilDo:
546
  Enabled: true
547

548
# Favor modifier while/until usage when you have a single-line body.
549
Style/WhileUntilModifier:
550
  Enabled: true
551

552
# Use %w or %W for arrays of words.
553
Style/WordArray:
D
Douwe Maan 已提交
554
  Enabled: true
555

M
mhasbini 已提交
556 557 558 559
# Use `proc` instead of `Proc.new`.
Style/Proc:
  Enabled: true

560
# Metrics #####################################################################
561

562 563
# A calculated magnitude based on number of assignments,
# branches, and conditions.
564
Metrics/AbcSize:
G
Grzegorz Bizon 已提交
565
  Enabled: true
M
Maxim Rydkin 已提交
566
  Max: 57.08
G
Grzegorz Bizon 已提交
567

D
Douwe Maan 已提交
568
# This cop checks if the length of a block exceeds some maximum value.
D
Douwe Maan 已提交
569 570 571
Metrics/BlockLength:
  Enabled: false

572
# Avoid excessive block nesting.
573
Metrics/BlockNesting:
G
Grzegorz Bizon 已提交
574 575
  Enabled: true
  Max: 4
576

577
# Avoid classes longer than 100 lines of code.
578 579 580
Metrics/ClassLength:
  Enabled: false

581 582 583 584
# A complexity metric that is strongly correlated to the number
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity:
  Enabled: true
585
  Max: 16
586 587

# Limit lines to 80 characters.
588 589 590
Metrics/LineLength:
  Enabled: false

591
# Avoid methods longer than 10 lines of code.
592 593 594
Metrics/MethodLength:
  Enabled: false

595
# Avoid modules longer than 100 lines of code.
596 597 598
Metrics/ModuleLength:
  Enabled: false

599 600 601 602 603 604 605 606
# 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 已提交
607
  Max: 18
608

609
# Lint ########################################################################
610

611 612
# Checks for ambiguous operators in the first argument of a method invocation
# without parentheses.
613
Lint/AmbiguousOperator:
614
  Enabled: true
615

D
Douwe Maan 已提交
616 617
# This cop checks for ambiguous regexp literals in the first argument of
# a method invocation without parentheses.
D
Douwe Maan 已提交
618 619 620
Lint/AmbiguousRegexpLiteral:
  Enabled: false

D
Douwe Maan 已提交
621 622
# This cop checks for assignments in the conditions of
# if/while/until.
D
Douwe Maan 已提交
623 624 625
Lint/AssignmentInCondition:
  Enabled: false

626
# Align block ends correctly.
627
Lint/BlockAlignment:
628
  Enabled: true
629

630 631 632
# Default values in optional keyword arguments and optional ordinal arguments
# should not refer back to the name of the argument.
Lint/CircularArgumentReference:
633
  Enabled: true
634 635

# Checks for condition placed in a confusing position relative to the keyword.
636
Lint/ConditionPosition:
637
  Enabled: true
638

639
# Check for debugger calls.
640
Lint/Debugger:
641
  Enabled: true
642

643
# Align ends corresponding to defs correctly.
644
Lint/DefEndAlignment:
645
  Enabled: true
646

647
# Check for deprecated class method calls.
648
Lint/DeprecatedClassMethods:
649
  Enabled: true
650

651 652
# Check for immutable argument given to each_with_object.
Lint/EachWithObjectArgument:
653
  Enabled: true
654 655

# Check for odd code arrangement in an else block.
656
Lint/ElseLayout:
657
  Enabled: true
658

659
# Checks for empty ensure block.
660
Lint/EmptyEnsure:
661
  Enabled: true
662

663 664 665 666
# Checks for the presence of `when` branches without a body.
Lint/EmptyWhen:
  Enabled: true

667
# Align ends correctly.
668
Lint/EndAlignment:
669
  Enabled: true
670

671
# END blocks should not be placed inside method definitions.
672
Lint/EndInMethod:
673
  Enabled: true
674

675
# Do not use return in an ensure block.
676
Lint/EnsureReturn:
677
  Enabled: true
678

679 680
# Catches floating-point literals too large or small for Ruby to represent.
Lint/FloatOutOfRange:
681
  Enabled: true
682 683 684

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

D
Douwe Maan 已提交
687
# This cop checks for *rescue* blocks with no body.
D
Douwe Maan 已提交
688 689 690
Lint/HandleExceptions:
  Enabled: false

691 692 693
# Checks for adjacent string literals on the same line, which could better be
# represented as a single string literal.
Lint/ImplicitStringConcatenation:
694
  Enabled: true
695

D
Douwe Maan 已提交
696 697 698 699 700
# Checks for attempts to use `private` or `protected` to set the visibility
# of a class method, which does not work.
Lint/IneffectiveAccessModifier:
  Enabled: false

701 702
# Checks for invalid character literals with a non-escaped whitespace
# character.
703
Lint/InvalidCharacterLiteral:
704
  Enabled: true
705

706
# Checks of literals used in conditions.
707
Lint/LiteralInCondition:
708
  Enabled: true
709

710
# Checks for literals used in interpolation.
711
Lint/LiteralInInterpolation:
712
  Enabled: true
713

D
Douwe Maan 已提交
714
# This cop checks for uses of *begin...end while/until something*.
D
Douwe Maan 已提交
715 716 717
Lint/Loop:
  Enabled: false

718 719
# Do not use nested method definitions.
Lint/NestedMethodDefinition:
720
  Enabled: true
721 722 723

# Do not omit the accumulator when calling `next` in a `reduce`/`inject` block.
Lint/NextWithoutAccumulator:
724
  Enabled: true
725 726

# Checks for method calls with a space before the opening parenthesis.
727
Lint/ParenthesesAsGroupedExpression:
728
  Enabled: true
729

730 731 732
# Checks for `rand(1)` calls. Such calls always return `0` and most likely
# a mistake.
Lint/RandOne:
733
  Enabled: true
734 735

# Use parentheses in the method call to avoid confusion about precedence.
736
Lint/RequireParentheses:
737
  Enabled: true
738

739
# Avoid rescuing the Exception class.
740
Lint/RescueException:
741
  Enabled: true
742

C
Connor Shea 已提交
743 744
# Checks for the order which exceptions are rescued to avoid rescueing a less specific exception before a more specific exception.
Lint/ShadowedException:
745 746
  Enabled: false

D
Douwe Maan 已提交
747 748
# This cop looks for use of the same name as outer local variables
# for block arguments or block local variables.
D
Douwe Maan 已提交
749 750 751
Lint/ShadowingOuterLocalVariable:
  Enabled: false

752 753 754 755
# Checks for Object#to_s usage in string interpolation.
Lint/StringConversionInInterpolation:
  Enabled: true

756
# Do not use prefix `_` for a variable that is used.
757
Lint/UnderscorePrefixedVariableName:
758
  Enabled: true
759

D
Douwe Maan 已提交
760
# This cop checks for using Fixnum or Bignum constant
D
Douwe Maan 已提交
761 762 763
Lint/UnifiedInteger:
  Enabled: true

764 765 766 767 768 769
# 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 已提交
770
# This cop checks for unneeded usages of splat expansion
D
Douwe Maan 已提交
771 772 773
Lint/UnneededSplatExpansion:
  Enabled: false

774
# Unreachable code.
775
Lint/UnreachableCode:
776
  Enabled: true
777

D
Douwe Maan 已提交
778
# This cop checks for unused block arguments.
D
Douwe Maan 已提交
779 780 781
Lint/UnusedBlockArgument:
  Enabled: false

D
Douwe Maan 已提交
782
# This cop checks for unused method arguments.
D
Douwe Maan 已提交
783 784 785
Lint/UnusedMethodArgument:
  Enabled: false

D
Douwe Maan 已提交
786 787 788 789
# Checks for useless access modifiers.
Lint/UselessAccessModifier:
  Enabled: true

790
# Checks for useless assignment to a local variable.
791
Lint/UselessAssignment:
792
  Enabled: true
793

794
# Checks for comparison of something with itself.
795
Lint/UselessComparison:
796
  Enabled: true
797

798
# Checks for useless `else` in `begin..end` without `rescue`.
799
Lint/UselessElseWithoutRescue:
800
  Enabled: true
801

802
# Checks for useless setter call to a local variable.
803
Lint/UselessSetterCall:
804
  Enabled: true
805

806
# Possible use of operator/literal/variable in void context.
807
Lint/Void:
808
  Enabled: true
809

810
# Performance #################################################################
811 812 813

# Use `casecmp` rather than `downcase ==`.
Performance/Casecmp:
814
  Enabled: true
815 816 817 818

# Use `str.{start,end}_with?(x, ..., y, ...)` instead of
# `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
Performance/DoubleStartEndWith:
819
  Enabled: true
820 821 822

# Use `strip` instead of `lstrip.rstrip`.
Performance/LstripRstrip:
C
Connor Shea 已提交
823
  Enabled: true
824 825 826

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

D
Douwe Maan 已提交
829 830
# This cop identifies the use of a `&block` parameter and `block.call`
# where `yield` would do just as well.
D
Douwe Maan 已提交
831 832 833
Performance/RedundantBlockCall:
  Enabled: true

D
Douwe Maan 已提交
834 835
# 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 已提交
836 837 838
Performance/RedundantMatch:
  Enabled: true

D
Douwe Maan 已提交
839 840
# This cop identifies places where `Hash#merge!` can be replaced by
# `Hash#[]=`.
D
Douwe Maan 已提交
841 842 843 844
Performance/RedundantMerge:
  Enabled: true
  MaxKeyValuePairs: 1

845 846
# Use `sort` instead of `sort_by { |x| x }`.
Performance/RedundantSortBy:
847
  Enabled: true
848 849 850 851

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

854 855 856 857
# 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 已提交
858
  Enabled: true
859 860 861

# Checks for `.times.map` calls.
Performance/TimesMap:
862
  Enabled: true
863

D
Douwe Maan 已提交
864 865
# Security ####################################################################

D
Douwe Maan 已提交
866 867
# This cop checks for the use of JSON class methods which have potential
# security issues.
D
Douwe Maan 已提交
868 869 870
Security/JSONLoad:
  Enabled: true

871 872 873 874
# This cop checks for the use of *Kernel#eval*.
Security/Eval:
  Enabled: true

875
# Rails #######################################################################
876

877 878 879 880 881
# Enables Rails cops.
Rails:
  Enabled: true

# Enforces consistent use of action filter methods.
882
Rails/ActionFilter:
883
  Enabled: true
884
  EnforcedStyle: action
885

886 887
# Checks the correct usage of date aware methods, such as `Date.today`,
# `Date.current`, etc.
G
Gabriel Mazetto 已提交
888 889 890
Rails/Date:
  Enabled: false

891 892
# Prefer delegate method for delegations.
Rails/Delegate:
D
Douwe Maan 已提交
893
  Enabled: true
894

D
Douwe Maan 已提交
895
# This cop checks dynamic `find_by_*` methods.
D
Douwe Maan 已提交
896 897 898
Rails/DynamicFindBy:
  Enabled: false

D
Douwe Maan 已提交
899
# This cop enforces that 'exit' calls are not used within a rails app.
D
Douwe Maan 已提交
900 901 902 903 904 905
Rails/Exit:
  Enabled: true
  Exclude:
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'

906 907
# Prefer `find_by` over `where.first`.
Rails/FindBy:
908
  Enabled: true
909 910 911

# Prefer `all.find_each` over `all.find`.
Rails/FindEach:
912
  Enabled: true
913

914
# Prefer has_many :through to has_and_belongs_to_many.
915
Rails/HasAndBelongsToMany:
916
  Enabled: true
917

D
Douwe Maan 已提交
918 919 920
# 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 已提交
921 922 923
Rails/HttpPositionalArguments:
  Enabled: false

924
# Checks for calls to puts, print, etc.
925
Rails/Output:
926
  Enabled: true
927 928 929 930 931
  Exclude:
    - lib/gitlab/seeder.rb
    - lib/gitlab/upgrader.rb
    - 'lib/backup/**/*'
    - 'lib/tasks/**/*'
932

D
Douwe Maan 已提交
933 934
# This cop checks for the use of output safety calls like html_safe and
# raw.
D
Douwe Maan 已提交
935 936 937
Rails/OutputSafety:
  Enabled: false

938 939
# Checks for incorrect grammar when using methods like `3.day.ago`.
Rails/PluralizationGrammar:
940
  Enabled: true
941 942

# Checks for `read_attribute(:attr)` and `write_attribute(:attr, val)`.
943 944 945
Rails/ReadWriteAttribute:
  Enabled: false

946
# Checks the arguments of ActiveRecord scopes.
947
Rails/ScopeArgs:
948
  Enabled: true
949

D
Douwe Maan 已提交
950
# This cop checks for the use of Time methods without zone.
D
Douwe Maan 已提交
951 952 953
Rails/TimeZone:
  Enabled: false

D
Douwe Maan 已提交
954
# This cop checks for the use of old-style attribute validation macros.
D
Douwe Maan 已提交
955 956 957
Rails/Validation:
  Enabled: true

958
# RSpec #######################################################################
R
Robert Speicher 已提交
959

960
# Check that instances are not being stubbed globally.
R
Robert Speicher 已提交
961 962 963
RSpec/AnyInstance:
  Enabled: false

964 965
# Check for expectations where `be(...)` can replace `eql(...)`.
RSpec/BeEql:
R
Rémy Coutable 已提交
966
  Enabled: true
967

968 969 970 971
# We don't enforce this as we use this technique in a few places.
RSpec/BeforeAfterAll:
  Enabled: false

972 973
# Check that the first argument to the top level describe is the tested class or
# module.
R
Robert Speicher 已提交
974 975 976
RSpec/DescribeClass:
  Enabled: false

977
# Use `described_class` for tested class / module.
R
Robert Speicher 已提交
978 979 980
RSpec/DescribeMethod:
  Enabled: false

981 982 983 984
# Avoid describing symbols.
RSpec/DescribeSymbol:
  Enabled: true

985 986 987
# Checks that the second argument to top level describe is the tested method
# name.
RSpec/DescribedClass:
988
  Enabled: true
R
Robert Speicher 已提交
989

990
# Checks if an example group does not include any tests.
991 992 993 994 995
RSpec/EmptyExampleGroup:
  Enabled: true
  CustomIncludeMethods:
    - run_permission_checks

996
# Checks for long example.
R
Robert Speicher 已提交
997 998 999 1000
RSpec/ExampleLength:
  Enabled: false
  Max: 5

1001
# Do not use should when describing your tests.
R
Robert Speicher 已提交
1002 1003 1004 1005 1006 1007 1008 1009
RSpec/ExampleWording:
  Enabled: false
  CustomTransform:
    be: is
    have: has
    not: does not
  IgnoredWords: []

1010 1011 1012 1013
# Checks for `expect(...)` calls containing literal values.
RSpec/ExpectActual:
  Enabled: true

1014
# Checks for opportunities to use `expect { … }.to output`.
1015 1016 1017
RSpec/ExpectOutput:
  Enabled: true

1018
# Checks the file and folder naming of the spec file.
R
Robert Speicher 已提交
1019
RSpec/FilePath:
S
Sean McGivern 已提交
1020 1021 1022 1023 1024 1025
  Enabled: true
  IgnoreMethods: true
  Exclude:
    - 'qa/**/*'
    - 'spec/javascripts/fixtures/*'
    - 'spec/requests/api/v3/*'
R
Robert Speicher 已提交
1026

1027
# Checks if there are focused specs.
R
Robert Speicher 已提交
1028 1029 1030
RSpec/Focus:
  Enabled: true

1031 1032 1033 1034 1035 1036
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: is_expected, should
RSpec/ImplicitExpect:
  Enabled: true
  EnforcedStyle: is_expected

1037
# Checks for the usage of instance variables.
R
Robert Speicher 已提交
1038 1039 1040
RSpec/InstanceVariable:
  Enabled: false

D
Douwe Maan 已提交
1041
# Checks for `subject` definitions that come after `let` definitions.
D
Douwe Maan 已提交
1042 1043 1044
RSpec/LeadingSubject:
  Enabled: false

D
Douwe Maan 已提交
1045
# Checks unreferenced `let!` calls being used for test setup.
D
Douwe Maan 已提交
1046 1047 1048
RSpec/LetSetup:
  Enabled: false

D
Douwe Maan 已提交
1049
# Check that chains of messages are not being stubbed.
D
Douwe Maan 已提交
1050 1051 1052
RSpec/MessageChain:
  Enabled: false

D
Douwe Maan 已提交
1053
# Checks that message expectations are set using spies.
D
Douwe Maan 已提交
1054 1055 1056
RSpec/MessageSpies:
  Enabled: false

D
Douwe Maan 已提交
1057 1058
# Checks for multiple top-level describes.
RSpec/MultipleDescribes:
D
Douwe Maan 已提交
1059 1060
  Enabled: false

D
Douwe Maan 已提交
1061
# Checks if examples contain too many `expect` calls.
D
Douwe Maan 已提交
1062
RSpec/MultipleExpectations:
D
Douwe Maan 已提交
1063 1064
  Enabled: false

D
Douwe Maan 已提交
1065
# Checks for explicitly referenced test subjects.
D
Douwe Maan 已提交
1066
RSpec/NamedSubject:
D
Douwe Maan 已提交
1067 1068
  Enabled: false

D
Douwe Maan 已提交
1069
# Checks for nested example groups.
D
Douwe Maan 已提交
1070
RSpec/NestedGroups:
D
Douwe Maan 已提交
1071 1072
  Enabled: false

D
Douwe Maan 已提交
1073 1074 1075
# Enforces the usage of the same method on all negative message expectations.
RSpec/NotToNot:
  EnforcedStyle: not_to
D
Douwe Maan 已提交
1076
  Enabled: true
1077

D
Douwe Maan 已提交
1078
# Check for repeated description strings in example groups.
D
Douwe Maan 已提交
1079
RSpec/RepeatedDescription:
D
Douwe Maan 已提交
1080 1081
  Enabled: false

1082 1083
# Ensure RSpec hook blocks are always multi-line.
RSpec/SingleLineHook:
1084
  Enabled: true
1085 1086 1087 1088
  Exclude:
    - 'spec/factories/*'
    - 'spec/requests/api/v3/*'

D
Douwe Maan 已提交
1089
# Checks for stubbed test subjects.
D
Douwe Maan 已提交
1090
RSpec/SubjectStub:
D
Douwe Maan 已提交
1091 1092
  Enabled: false

D
Douwe Maan 已提交
1093 1094
# Prefer using verifying doubles over normal doubles.
RSpec/VerifiedDoubles:
D
Douwe Maan 已提交
1095
  Enabled: false