· 6 years ago · Jun 12, 2019, 10:00 PM
1# Common configuration.
2
3AllCops:
4 RubyInterpreters:
5 - ruby
6 - macruby
7 - rake
8 - jruby
9 - rbx
10 # Include common Ruby source files.
11 Include:
12 - '**/*.rb'
13 - '**/*.arb'
14 - '**/*.axlsx'
15 - '**/*.builder'
16 - '**/*.fcgi'
17 - '**/*.gemfile'
18 - '**/*.gemspec'
19 - '**/*.god'
20 - '**/*.jb'
21 - '**/*.jbuilder'
22 - '**/*.mspec'
23 - '**/*.opal'
24 - '**/*.pluginspec'
25 - '**/*.podspec'
26 - '**/*.rabl'
27 - '**/*.rake'
28 - '**/*.rbuild'
29 - '**/*.rbw'
30 - '**/*.rbx'
31 - '**/*.ru'
32 - '**/*.ruby'
33 - '**/*.spec'
34 - '**/*.thor'
35 - '**/*.watchr'
36 - '**/.irbrc'
37 - '**/.pryrc'
38 - '**/buildfile'
39 - '**/Appraisals'
40 - '**/Berksfile'
41 - '**/Brewfile'
42 - '**/Buildfile'
43 - '**/Capfile'
44 - '**/Cheffile'
45 - '**/Dangerfile'
46 - '**/Deliverfile'
47 - '**/Fastfile'
48 - '**/*Fastfile'
49 - '**/Gemfile'
50 - '**/Guardfile'
51 - '**/Jarfile'
52 - '**/Mavenfile'
53 - '**/Podfile'
54 - '**/Puppetfile'
55 - '**/Rakefile'
56 - '**/Snapfile'
57 - '**/Thorfile'
58 - '**/Vagabondfile'
59 - '**/Vagrantfile'
60 Exclude:
61 - 'node_modules/**/*'
62 - 'vendor/**/*'
63 - '.git/**/*'
64 # Default formatter will be used if no `-f/--format` option is given.
65 DefaultFormatter: progress
66 # Cop names are displayed in offense messages by default. Change behavior
67 # by overriding DisplayCopNames, or by giving the `--no-display-cop-names`
68 # option.
69 DisplayCopNames: true
70 # Style guide URLs are not displayed in offense messages by default. Change
71 # behavior by overriding `DisplayStyleGuide`, or by giving the
72 # `-S/--display-style-guide` option.
73 DisplayStyleGuide: false
74 # When specifying style guide URLs, any paths and/or fragments will be
75 # evaluated relative to the base URL.
76 StyleGuideBaseURL: https://github.com/rubocop-hq/ruby-style-guide
77 # Extra details are not displayed in offense messages by default. Change
78 # behavior by overriding ExtraDetails, or by giving the
79 # `-E/--extra-details` option.
80 ExtraDetails: false
81 # Additional cops that do not reference a style guide rule may be enabled by
82 # default. Change behavior by overriding `StyleGuideCopsOnly`, or by giving
83 # the `--only-guide-cops` option.
84 StyleGuideCopsOnly: false
85 # All cops except the ones configured `Enabled: false` in this file are enabled by default.
86 # Change this behavior by overriding either `DisabledByDefault` or `EnabledByDefault`.
87 # When `DisabledByDefault` is `true`, all cops in the default configuration
88 # are disabled, and only cops in user configuration are enabled. This makes
89 # cops opt-in instead of opt-out. Note that when `DisabledByDefault` is `true`,
90 # cops in user configuration will be enabled even if they don't set the
91 # Enabled parameter.
92 # When `EnabledByDefault` is `true`, all cops, even those configured `Enabled: false`
93 # in this file are enabled by default. Cops can still be disabled in user configuration.
94 # Note that it is invalid to set both EnabledByDefault and DisabledByDefault
95 # to true in the same configuration.
96 EnabledByDefault: false
97 DisabledByDefault: false
98 # Enables the result cache if `true`. Can be overridden by the `--cache` command
99 # line option.
100 UseCache: true
101 # Threshold for how many files can be stored in the result cache before some
102 # of the files are automatically removed.
103 MaxFilesInCache: 20000
104 # The cache will be stored in "rubocop_cache" under this directory. If
105 # CacheRootDirectory is ~ (nil), which it is by default, the root will be
106 # taken from the environment variable `$XDG_CACHE_HOME` if it is set, or if
107 # `$XDG_CACHE_HOME` is not set, it will be `$HOME/.cache/`.
108 CacheRootDirectory: ~
109 # It is possible for a malicious user to know the location of RuboCop's cache
110 # directory by looking at CacheRootDirectory, and create a symlink in its
111 # place that could cause RuboCop to overwrite unintended files, or read
112 # malicious input. If you are certain that your cache location is secure from
113 # this kind of attack, and wish to use a symlinked cache location, set this
114 # value to "true".
115 AllowSymlinksInCacheRootDirectory: false
116 # What MRI version of the Ruby interpreter is the inspected code intended to
117 # run on? (If there is more than one, set this to the lowest version.)
118 # If a value is specified for TargetRubyVersion then it is used. Acceptable
119 # values are specificed as a float (i.e. 2.5); the teeny version of Ruby
120 # should not be included. If the project specifies a Ruby version in the
121 # .ruby-version file, Gemfile or gems.rb file, RuboCop will try to determine
122 # the desired version of Ruby by inspecting the .ruby-version file first,
123 # followed by the Gemfile.lock or gems.locked file. (Although the Ruby version
124 # is specified in the Gemfile or gems.rb file, RuboCop reads the final value
125 # from the lock file.) If the Ruby version is still unresolved, RuboCop will
126 # use the oldest officially supported Ruby version (currently Ruby 2.3).
127 TargetRubyVersion: ~
128 # What version of Rails is the inspected code using? If a value is specified
129 # for TargetRailsVersion then it is used. Acceptable values are specificed
130 # as a float (i.e. 5.1); the patch version of Rails should not be included.
131 # If TargetRailsVersion is not set, RuboCop will parse the Gemfile.lock or
132 # gems.locked file to find the version of Rails that has been bound to the
133 # application. If neither of those files exist, RuboCop will use Rails 5.0
134 # as the default.
135 TargetRailsVersion: ~
136
137#################### Bundler ###############################
138
139Bundler/DuplicatedGem:
140 Description: 'Checks for duplicate gem entries in Gemfile.'
141 Enabled: true
142 VersionAdded: '0.46'
143 Include:
144 - '**/*.gemfile'
145 - '**/Gemfile'
146 - '**/gems.rb'
147
148Bundler/GemComment:
149 Description: 'Add a comment describing each gem.'
150 Enabled: false
151 VersionAdded: '0.59'
152 Include:
153 - '**/*.gemfile'
154 - '**/Gemfile'
155 - '**/gems.rb'
156 Whitelist: []
157
158Bundler/InsecureProtocolSource:
159 Description: >-
160 The source `:gemcutter`, `:rubygems` and `:rubyforge` are deprecated
161 because HTTP requests are insecure. Please change your source to
162 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
163 Enabled: true
164 VersionAdded: '0.50'
165 Include:
166 - '**/*.gemfile'
167 - '**/Gemfile'
168 - '**/gems.rb'
169
170Bundler/OrderedGems:
171 Description: >-
172 Gems within groups in the Gemfile should be alphabetically sorted.
173 Enabled: true
174 VersionAdded: '0.46'
175 VersionChanged: '0.47'
176 TreatCommentsAsGroupSeparators: true
177 Include:
178 - '**/*.gemfile'
179 - '**/Gemfile'
180 - '**/gems.rb'
181
182#################### Gemspec ###############################
183
184Gemspec/DuplicatedAssignment:
185 Description: 'An attribute assignment method calls should be listed only once in a gemspec.'
186 Enabled: true
187 VersionAdded: '0.52'
188 Include:
189 - '**/*.gemspec'
190
191Gemspec/OrderedDependencies:
192 Description: >-
193 Dependencies in the gemspec should be alphabetically sorted.
194 Enabled: true
195 VersionAdded: '0.51'
196 TreatCommentsAsGroupSeparators: true
197 Include:
198 - '**/*.gemspec'
199
200Gemspec/RequiredRubyVersion:
201 Description: 'Checks that `required_ruby_version` of gemspec and `TargetRubyVersion` of .rubocop.yml are equal.'
202 Enabled: true
203 VersionAdded: '0.52'
204 Include:
205 - '**/*.gemspec'
206
207#################### Layout ###########################
208
209Layout/AccessModifierIndentation:
210 Description: Check indentation of private/protected visibility modifiers.
211 StyleGuide: '#indent-public-private-protected'
212 Enabled: true
213 VersionAdded: '0.49'
214 EnforcedStyle: indent
215 SupportedStyles:
216 - outdent
217 - indent
218 # By default, the indentation width from Layout/IndentationWidth is used
219 # But it can be overridden by setting this parameter
220 IndentationWidth: ~
221
222Layout/AlignArguments:
223 Description: >-
224 Align the arguments of a method call if they span more
225 than one line.
226 StyleGuide: '#no-double-indent'
227 Enabled: true
228 VersionAdded: '0.68'
229 # Alignment of arguments in multi-line method calls.
230 #
231 # The `with_first_argument` style aligns the following lines along the same
232 # column as the first parameter.
233 #
234 # method_call(a,
235 # b)
236 #
237 # The `with_fixed_indentation` style aligns the following lines with one
238 # level of indentation relative to the start of the line with the method call.
239 #
240 # method_call(a,
241 # b)
242 EnforcedStyle: with_first_argument
243 SupportedStyles:
244 - with_first_argument
245 - with_fixed_indentation
246 # By default, the indentation width from Layout/IndentationWidth is used
247 # But it can be overridden by setting this parameter
248 IndentationWidth: ~
249
250Layout/AlignArray:
251 Description: >-
252 Align the elements of an array literal if they span more than
253 one line.
254 StyleGuide: '#align-multiline-arrays'
255 Enabled: true
256 VersionAdded: '0.49'
257
258Layout/AlignHash:
259 Description: >-
260 Align the elements of a hash literal if they span more than
261 one line.
262 Enabled: true
263 AllowMultipleStyles: true
264 VersionAdded: '0.49'
265 # Alignment of entries using hash rocket as separator. Valid values are:
266 #
267 # key - left alignment of keys
268 # 'a' => 2
269 # 'bb' => 3
270 # separator - alignment of hash rockets, keys are right aligned
271 # 'a' => 2
272 # 'bb' => 3
273 # table - left alignment of keys, hash rockets, and values
274 # 'a' => 2
275 # 'bb' => 3
276 EnforcedHashRocketStyle: key
277 SupportedHashRocketStyles:
278 - key
279 - separator
280 - table
281 # Alignment of entries using colon as separator. Valid values are:
282 #
283 # key - left alignment of keys
284 # a: 0
285 # bb: 1
286 # separator - alignment of colons, keys are right aligned
287 # a: 0
288 # bb: 1
289 # table - left alignment of keys and values
290 # a: 0
291 # bb: 1
292 EnforcedColonStyle: key
293 SupportedColonStyles:
294 - key
295 - separator
296 - table
297 # Select whether hashes that are the last argument in a method call should be
298 # inspected? Valid values are:
299 #
300 # always_inspect - Inspect both implicit and explicit hashes.
301 # Registers an offense for:
302 # function(a: 1,
303 # b: 2)
304 # Registers an offense for:
305 # function({a: 1,
306 # b: 2})
307 # always_ignore - Ignore both implicit and explicit hashes.
308 # Accepts:
309 # function(a: 1,
310 # b: 2)
311 # Accepts:
312 # function({a: 1,
313 # b: 2})
314 # ignore_implicit - Ignore only implicit hashes.
315 # Accepts:
316 # function(a: 1,
317 # b: 2)
318 # Registers an offense for:
319 # function({a: 1,
320 # b: 2})
321 # ignore_explicit - Ignore only explicit hashes.
322 # Accepts:
323 # function({a: 1,
324 # b: 2})
325 # Registers an offense for:
326 # function(a: 1,
327 # b: 2)
328 EnforcedLastArgumentHashStyle: always_inspect
329 SupportedLastArgumentHashStyles:
330 - always_inspect
331 - always_ignore
332 - ignore_implicit
333 - ignore_explicit
334
335Layout/AlignParameters:
336 Description: >-
337 Align the parameters of a method definition if they span more
338 than one line.
339 StyleGuide: '#no-double-indent'
340 Enabled: true
341 VersionAdded: '0.49'
342 VersionChanged: '0.68'
343 # Alignment of parameters in multi-line method calls.
344 #
345 # The `with_first_parameter` style aligns the following lines along the same
346 # column as the first parameter.
347 #
348 # def method_foo(a,
349 # b)
350 #
351 # The `with_fixed_indentation` style aligns the following lines with one
352 # level of indentation relative to the start of the line with the method call.
353 #
354 # def method_foo(a,
355 # b)
356 EnforcedStyle: with_first_parameter
357 SupportedStyles:
358 - with_first_parameter
359 - with_fixed_indentation
360 # By default, the indentation width from Layout/IndentationWidth is used
361 # But it can be overridden by setting this parameter
362 IndentationWidth: ~
363
364Layout/BlockAlignment:
365 Description: 'Align block ends correctly.'
366 Enabled: true
367 VersionAdded: '0.53'
368 # The value `start_of_block` means that the `end` should be aligned with line
369 # where the `do` keyword appears.
370 # The value `start_of_line` means it should be aligned with the whole
371 # expression's starting line.
372 # The value `either` means both are allowed.
373 EnforcedStyleAlignWith: either
374 SupportedStylesAlignWith:
375 - either
376 - start_of_block
377 - start_of_line
378
379Layout/BlockEndNewline:
380 Description: 'Put end statement of multiline block on its own line.'
381 Enabled: true
382 VersionAdded: '0.49'
383
384Layout/CaseIndentation:
385 Description: 'Indentation of when in a case/when/[else/]end.'
386 StyleGuide: '#indent-when-to-case'
387 Enabled: true
388 VersionAdded: '0.49'
389 EnforcedStyle: case
390 SupportedStyles:
391 - case
392 - end
393 IndentOneStep: false
394 # By default, the indentation width from `Layout/IndentationWidth` is used.
395 # But it can be overridden by setting this parameter.
396 # This only matters if `IndentOneStep` is `true`
397 IndentationWidth: ~
398
399Layout/ClassStructure:
400 Description: 'Enforces a configured order of definitions within a class body.'
401 StyleGuide: '#consistent-classes'
402 Enabled: false
403 VersionAdded: '0.52'
404 Categories:
405 module_inclusion:
406 - include
407 - prepend
408 - extend
409 ExpectedOrder:
410 - module_inclusion
411 - constants
412 - public_class_methods
413 - initializer
414 - public_methods
415 - protected_methods
416 - private_methods
417
418Layout/ClosingHeredocIndentation:
419 Description: 'Checks the indentation of here document closings.'
420 Enabled: true
421 VersionAdded: '0.57'
422
423Layout/ClosingParenthesisIndentation:
424 Description: 'Checks the indentation of hanging closing parentheses.'
425 Enabled: true
426 VersionAdded: '0.49'
427
428Layout/CommentIndentation:
429 Description: 'Indentation of comments.'
430 Enabled: true
431 VersionAdded: '0.49'
432
433Layout/ConditionPosition:
434 Description: >-
435 Checks for condition placed in a confusing position relative to
436 the keyword.
437 StyleGuide: '#same-line-condition'
438 Enabled: true
439 VersionAdded: '0.53'
440
441Layout/DefEndAlignment:
442 Description: 'Align ends corresponding to defs correctly.'
443 Enabled: true
444 VersionAdded: '0.53'
445 # The value `def` means that `end` should be aligned with the def keyword.
446 # The value `start_of_line` means that `end` should be aligned with method
447 # calls like `private`, `public`, etc, if present in front of the `def`
448 # keyword on the same line.
449 EnforcedStyleAlignWith: start_of_line
450 SupportedStylesAlignWith:
451 - start_of_line
452 - def
453 AutoCorrect: false
454 Severity: warning
455
456Layout/DotPosition:
457 Description: 'Checks the position of the dot in multi-line method calls.'
458 StyleGuide: '#consistent-multi-line-chains'
459 Enabled: true
460 VersionAdded: '0.49'
461 EnforcedStyle: leading
462 SupportedStyles:
463 - leading
464 - trailing
465
466Layout/ElseAlignment:
467 Description: 'Align elses and elsifs correctly.'
468 Enabled: true
469 VersionAdded: '0.49'
470
471Layout/EmptyComment:
472 Description: 'Checks empty comment.'
473 Enabled: true
474 VersionAdded: '0.53'
475 AllowBorderComment: true
476 AllowMarginComment: true
477
478Layout/EmptyLineAfterGuardClause:
479 Description: 'Add empty line after guard clause.'
480 Enabled: true
481 VersionAdded: '0.56'
482 VersionChanged: '0.59'
483
484Layout/EmptyLineAfterMagicComment:
485 Description: 'Add an empty line after magic comments to separate them from code.'
486 StyleGuide: '#separate-magic-comments-from-code'
487 Enabled: true
488 VersionAdded: '0.49'
489
490Layout/EmptyLineBetweenDefs:
491 Description: 'Use empty lines between defs.'
492 StyleGuide: '#empty-lines-between-methods'
493 Enabled: true
494 VersionAdded: '0.49'
495 # If `true`, this parameter means that single line method definitions don't
496 # need an empty line between them.
497 AllowAdjacentOneLineDefs: false
498 # Can be array to specify minimum and maximum number of empty lines, e.g. [1, 2]
499 NumberOfEmptyLines: 1
500
501Layout/EmptyLines:
502 Description: "Don't use several empty lines in a row."
503 StyleGuide: '#two-or-more-empty-lines'
504 Enabled: true
505 VersionAdded: '0.49'
506
507Layout/EmptyLinesAroundAccessModifier:
508 Description: "Keep blank lines around access modifiers."
509 StyleGuide: '#empty-lines-around-access-modifier'
510 Enabled: true
511 VersionAdded: '0.49'
512 EnforcedStyle: around
513 SupportedStyles:
514 - around
515 - only_before
516 Reference:
517 # A reference to `EnforcedStyle: only_before`.
518 - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
519
520Layout/EmptyLinesAroundArguments:
521 Description: "Keeps track of empty lines around method arguments."
522 Enabled: true
523 VersionAdded: '0.52'
524
525Layout/EmptyLinesAroundBeginBody:
526 Description: "Keeps track of empty lines around begin-end bodies."
527 StyleGuide: '#empty-lines-around-bodies'
528 Enabled: true
529 VersionAdded: '0.49'
530
531Layout/EmptyLinesAroundBlockBody:
532 Description: "Keeps track of empty lines around block bodies."
533 StyleGuide: '#empty-lines-around-bodies'
534 Enabled: true
535 VersionAdded: '0.49'
536 EnforcedStyle: no_empty_lines
537 SupportedStyles:
538 - empty_lines
539 - no_empty_lines
540
541Layout/EmptyLinesAroundClassBody:
542 Description: "Keeps track of empty lines around class bodies."
543 StyleGuide: '#empty-lines-around-bodies'
544 Enabled: true
545 VersionAdded: '0.49'
546 VersionChanged: '0.53'
547 EnforcedStyle: no_empty_lines
548 SupportedStyles:
549 - empty_lines
550 - empty_lines_except_namespace
551 - empty_lines_special
552 - no_empty_lines
553 - beginning_only
554 - ending_only
555
556Layout/EmptyLinesAroundExceptionHandlingKeywords:
557 Description: "Keeps track of empty lines around exception handling keywords."
558 StyleGuide: '#empty-lines-around-bodies'
559 Enabled: true
560 VersionAdded: '0.49'
561
562Layout/EmptyLinesAroundMethodBody:
563 Description: "Keeps track of empty lines around method bodies."
564 StyleGuide: '#empty-lines-around-bodies'
565 Enabled: true
566 VersionAdded: '0.49'
567
568Layout/EmptyLinesAroundModuleBody:
569 Description: "Keeps track of empty lines around module bodies."
570 StyleGuide: '#empty-lines-around-bodies'
571 Enabled: true
572 VersionAdded: '0.49'
573 EnforcedStyle: no_empty_lines
574 SupportedStyles:
575 - empty_lines
576 - empty_lines_except_namespace
577 - empty_lines_special
578 - no_empty_lines
579
580Layout/EndAlignment:
581 Description: 'Align ends correctly.'
582 Enabled: true
583 VersionAdded: '0.53'
584 # The value `keyword` means that `end` should be aligned with the matching
585 # keyword (`if`, `while`, etc.).
586 # The value `variable` means that in assignments, `end` should be aligned
587 # with the start of the variable on the left hand side of `=`. In all other
588 # situations, `end` should still be aligned with the keyword.
589 # The value `start_of_line` means that `end` should be aligned with the start
590 # of the line which the matching keyword appears on.
591 EnforcedStyleAlignWith: keyword
592 SupportedStylesAlignWith:
593 - keyword
594 - variable
595 - start_of_line
596 AutoCorrect: false
597 Severity: warning
598
599Layout/EndOfLine:
600 Description: 'Use Unix-style line endings.'
601 StyleGuide: '#crlf'
602 Enabled: true
603 VersionAdded: '0.49'
604 # The `native` style means that CR+LF (Carriage Return + Line Feed) is
605 # enforced on Windows, and LF is enforced on other platforms. The other styles
606 # mean LF and CR+LF, respectively.
607 EnforcedStyle: native
608 SupportedStyles:
609 - native
610 - lf
611 - crlf
612
613Layout/ExtraSpacing:
614 Description: 'Do not use unnecessary spacing.'
615 Enabled: true
616 VersionAdded: '0.49'
617 # When true, allows most uses of extra spacing if the intent is to align
618 # things with the previous or next line, not counting empty lines or comment
619 # lines.
620 AllowForAlignment: true
621 # When true, allows things like 'obj.meth(arg) # comment',
622 # rather than insisting on 'obj.meth(arg) # comment'.
623 # If done for alignment, either this OR AllowForAlignment will allow it.
624 AllowBeforeTrailingComments: false
625 # When true, forces the alignment of `=` in assignments on consecutive lines.
626 ForceEqualSignAlignment: false
627
628Layout/FirstArrayElementLineBreak:
629 Description: >-
630 Checks for a line break before the first element in a
631 multi-line array.
632 Enabled: false
633 VersionAdded: '0.49'
634
635Layout/FirstHashElementLineBreak:
636 Description: >-
637 Checks for a line break before the first element in a
638 multi-line hash.
639 Enabled: false
640 VersionAdded: '0.49'
641
642Layout/FirstMethodArgumentLineBreak:
643 Description: >-
644 Checks for a line break before the first argument in a
645 multi-line method call.
646 Enabled: false
647 VersionAdded: '0.49'
648
649Layout/FirstMethodParameterLineBreak:
650 Description: >-
651 Checks for a line break before the first parameter in a
652 multi-line method parameter definition.
653 Enabled: false
654 VersionAdded: '0.49'
655
656Layout/HeredocArgumentClosingParenthesis:
657 Description: >-
658 Checks for the placement of the closing parenthesis in a
659 method call that passes a HEREDOC string as an argument.
660 Enabled: false
661 StyleGuide: '#heredoc-argument-closing-parentheses'
662 VersionAdded: '0.68'
663
664Layout/IndentAssignment:
665 Description: >-
666 Checks the indentation of the first line of the
667 right-hand-side of a multi-line assignment.
668 Enabled: true
669 VersionAdded: '0.49'
670 # By default, the indentation width from `Layout/IndentationWidth` is used
671 # But it can be overridden by setting this parameter
672 IndentationWidth: ~
673
674Layout/IndentFirstArgument:
675 Description: 'Checks the indentation of the first argument in a method call.'
676 Enabled: true
677 VersionAdded: '0.68'
678 EnforcedStyle: special_for_inner_method_call_in_parentheses
679 SupportedStyles:
680 # The first parameter should always be indented one step more than the
681 # preceding line.
682 - consistent
683 # The first parameter should always be indented one level relative to the
684 # parent that is receiving the parameter
685 - consistent_relative_to_receiver
686 # The first parameter should normally be indented one step more than the
687 # preceding line, but if it's a parameter for a method call that is itself
688 # a parameter in a method call, then the inner parameter should be indented
689 # relative to the inner method.
690 - special_for_inner_method_call
691 # Same as `special_for_inner_method_call` except that the special rule only
692 # applies if the outer method call encloses its arguments in parentheses.
693 - special_for_inner_method_call_in_parentheses
694 # By default, the indentation width from `Layout/IndentationWidth` is used
695 # But it can be overridden by setting this parameter
696 IndentationWidth: ~
697
698Layout/IndentFirstArrayElement:
699 Description: >-
700 Checks the indentation of the first element in an array
701 literal.
702 Enabled: true
703 VersionAdded: '0.68'
704 # The value `special_inside_parentheses` means that array literals with
705 # brackets that have their opening bracket on the same line as a surrounding
706 # opening round parenthesis, shall have their first element indented relative
707 # to the first position inside the parenthesis.
708 #
709 # The value `consistent` means that the indentation of the first element shall
710 # always be relative to the first position of the line where the opening
711 # bracket is.
712 #
713 # The value `align_brackets` means that the indentation of the first element
714 # shall always be relative to the position of the opening bracket.
715 EnforcedStyle: special_inside_parentheses
716 SupportedStyles:
717 - special_inside_parentheses
718 - consistent
719 - align_brackets
720 # By default, the indentation width from `Layout/IndentationWidth` is used
721 # But it can be overridden by setting this parameter
722 IndentationWidth: ~
723
724Layout/IndentFirstHashElement:
725 Description: 'Checks the indentation of the first key in a hash literal.'
726 Enabled: true
727 VersionAdded: '0.68'
728 # The value `special_inside_parentheses` means that hash literals with braces
729 # that have their opening brace on the same line as a surrounding opening
730 # round parenthesis, shall have their first key indented relative to the
731 # first position inside the parenthesis.
732 #
733 # The value `consistent` means that the indentation of the first key shall
734 # always be relative to the first position of the line where the opening
735 # brace is.
736 #
737 # The value `align_braces` means that the indentation of the first key shall
738 # always be relative to the position of the opening brace.
739 EnforcedStyle: special_inside_parentheses
740 SupportedStyles:
741 - special_inside_parentheses
742 - consistent
743 - align_braces
744 # By default, the indentation width from `Layout/IndentationWidth` is used
745 # But it can be overridden by setting this parameter
746 IndentationWidth: ~
747
748Layout/IndentFirstParameter:
749 Description: >-
750 Checks the indentation of the first parameter in a
751 method definition.
752 Enabled: true
753 VersionAdded: '0.49'
754 VersionChanged: '0.68'
755 EnforcedStyle: consistent
756 SupportedStyles:
757 - consistent
758 - align_parentheses
759 # By default, the indentation width from `Layout/IndentationWidth` is used
760 # But it can be overridden by setting this parameter
761 IndentationWidth: ~
762
763Layout/IndentHeredoc:
764 Description: 'This cop checks the indentation of the here document bodies.'
765 StyleGuide: '#squiggly-heredocs'
766 Enabled: true
767 VersionAdded: '0.49'
768 VersionChanged: '0.69'
769 EnforcedStyle: squiggly
770 SupportedStyles:
771 - squiggly
772 - active_support
773 - powerpack
774 - unindent
775
776Layout/IndentationConsistency:
777 Description: 'Keep indentation straight.'
778 StyleGuide: '#spaces-indentation'
779 Enabled: true
780 VersionAdded: '0.49'
781 # The difference between `rails` and `normal` is that the `rails` style
782 # prescribes that in classes and modules the `protected` and `private`
783 # modifier keywords shall be indented the same as public methods and that
784 # protected and private members shall be indented one step more than the
785 # modifiers. Other than that, both styles mean that entities on the same
786 # logical depth shall have the same indentation.
787 EnforcedStyle: normal
788 SupportedStyles:
789 - normal
790 - rails
791 Reference:
792 # A reference to `EnforcedStyle: rails`.
793 - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
794
795Layout/IndentationWidth:
796 Description: 'Use 2 spaces for indentation.'
797 StyleGuide: '#spaces-indentation'
798 Enabled: true
799 VersionAdded: '0.49'
800 # Number of spaces for each indentation level.
801 Width: 2
802 IgnoredPatterns: []
803
804Layout/InitialIndentation:
805 Description: >-
806 Checks the indentation of the first non-blank non-comment line in a file.
807 Enabled: true
808 VersionAdded: '0.49'
809
810Layout/LeadingBlankLines:
811 Description: Check for unnecessary blank lines at the beginning of a file.
812 Enabled: true
813 VersionAdded: '0.57'
814
815Layout/LeadingCommentSpace:
816 Description: 'Comments should start with a space.'
817 StyleGuide: '#hash-space'
818 Enabled: true
819 VersionAdded: '0.49'
820
821Layout/MultilineArrayBraceLayout:
822 Description: >-
823 Checks that the closing brace in an array literal is
824 either on the same line as the last array element, or
825 a new line.
826 Enabled: true
827 VersionAdded: '0.49'
828 EnforcedStyle: symmetrical
829 SupportedStyles:
830 # symmetrical: closing brace is positioned in same way as opening brace
831 # new_line: closing brace is always on a new line
832 # same_line: closing brace is always on the same line as last element
833 - symmetrical
834 - new_line
835 - same_line
836
837Layout/MultilineArrayLineBreaks:
838 Description: >-
839 Checks that each item in a multi-line array literal
840 starts on a separate line.
841 Enabled: false
842 VersionAdded: '0.67'
843
844Layout/MultilineAssignmentLayout:
845 Description: 'Check for a newline after the assignment operator in multi-line assignments.'
846 StyleGuide: '#indent-conditional-assignment'
847 Enabled: false
848 VersionAdded: '0.49'
849 # The types of assignments which are subject to this rule.
850 SupportedTypes:
851 - block
852 - case
853 - class
854 - if
855 - kwbegin
856 - module
857 EnforcedStyle: new_line
858 SupportedStyles:
859 # Ensures that the assignment operator and the rhs are on the same line for
860 # the set of supported types.
861 - same_line
862 # Ensures that the assignment operator and the rhs are on separate lines
863 # for the set of supported types.
864 - new_line
865
866Layout/MultilineBlockLayout:
867 Description: 'Ensures newlines after multiline block do statements.'
868 Enabled: true
869 VersionAdded: '0.49'
870
871Layout/MultilineHashBraceLayout:
872 Description: >-
873 Checks that the closing brace in a hash literal is
874 either on the same line as the last hash element, or
875 a new line.
876 Enabled: true
877 VersionAdded: '0.49'
878 EnforcedStyle: symmetrical
879 SupportedStyles:
880 # symmetrical: closing brace is positioned in same way as opening brace
881 # new_line: closing brace is always on a new line
882 # same_line: closing brace is always on same line as last element
883 - symmetrical
884 - new_line
885 - same_line
886
887Layout/MultilineHashKeyLineBreaks:
888 Description: >-
889 Checks that each item in a multi-line hash literal
890 starts on a separate line.
891 Enabled: false
892 VersionAdded: '0.67'
893
894Layout/MultilineMethodArgumentLineBreaks:
895 Description: >-
896 Checks that each argument in a multi-line method call
897 starts on a separate line.
898 Enabled: false
899 VersionAdded: '0.67'
900
901Layout/MultilineMethodCallBraceLayout:
902 Description: >-
903 Checks that the closing brace in a method call is
904 either on the same line as the last method argument, or
905 a new line.
906 Enabled: true
907 VersionAdded: '0.49'
908 EnforcedStyle: symmetrical
909 SupportedStyles:
910 # symmetrical: closing brace is positioned in same way as opening brace
911 # new_line: closing brace is always on a new line
912 # same_line: closing brace is always on the same line as last argument
913 - symmetrical
914 - new_line
915 - same_line
916
917Layout/MultilineMethodCallIndentation:
918 Description: >-
919 Checks indentation of method calls with the dot operator
920 that span more than one line.
921 Enabled: true
922 VersionAdded: '0.49'
923 EnforcedStyle: aligned
924 SupportedStyles:
925 - aligned
926 - indented
927 - indented_relative_to_receiver
928 # By default, the indentation width from Layout/IndentationWidth is used
929 # But it can be overridden by setting this parameter
930 IndentationWidth: ~
931
932Layout/MultilineMethodDefinitionBraceLayout:
933 Description: >-
934 Checks that the closing brace in a method definition is
935 either on the same line as the last method parameter, or
936 a new line.
937 Enabled: true
938 VersionAdded: '0.49'
939 EnforcedStyle: symmetrical
940 SupportedStyles:
941 # symmetrical: closing brace is positioned in same way as opening brace
942 # new_line: closing brace is always on a new line
943 # same_line: closing brace is always on the same line as last parameter
944 - symmetrical
945 - new_line
946 - same_line
947
948Layout/MultilineOperationIndentation:
949 Description: >-
950 Checks indentation of binary operations that span more than
951 one line.
952 Enabled: true
953 VersionAdded: '0.49'
954 EnforcedStyle: aligned
955 SupportedStyles:
956 - aligned
957 - indented
958 # By default, the indentation width from `Layout/IndentationWidth` is used
959 # But it can be overridden by setting this parameter
960 IndentationWidth: ~
961
962Layout/RescueEnsureAlignment:
963 Description: 'Align rescues and ensures correctly.'
964 Enabled: true
965 VersionAdded: '0.49'
966
967Layout/SpaceAfterColon:
968 Description: 'Use spaces after colons.'
969 StyleGuide: '#spaces-operators'
970 Enabled: true
971 VersionAdded: '0.49'
972
973Layout/SpaceAfterComma:
974 Description: 'Use spaces after commas.'
975 StyleGuide: '#spaces-operators'
976 Enabled: true
977 VersionAdded: '0.49'
978
979Layout/SpaceAfterMethodName:
980 Description: >-
981 Do not put a space between a method name and the opening
982 parenthesis in a method definition.
983 StyleGuide: '#parens-no-spaces'
984 Enabled: true
985 VersionAdded: '0.49'
986
987Layout/SpaceAfterNot:
988 Description: Tracks redundant space after the ! operator.
989 StyleGuide: '#no-space-bang'
990 Enabled: true
991 VersionAdded: '0.49'
992
993Layout/SpaceAfterSemicolon:
994 Description: 'Use spaces after semicolons.'
995 StyleGuide: '#spaces-operators'
996 Enabled: true
997 VersionAdded: '0.49'
998
999Layout/SpaceAroundBlockParameters:
1000 Description: 'Checks the spacing inside and after block parameters pipes.'
1001 Enabled: true
1002 VersionAdded: '0.49'
1003 EnforcedStyleInsidePipes: no_space
1004 SupportedStylesInsidePipes:
1005 - space
1006 - no_space
1007
1008Layout/SpaceAroundEqualsInParameterDefault:
1009 Description: >-
1010 Checks that the equals signs in parameter default assignments
1011 have or don't have surrounding space depending on
1012 configuration.
1013 StyleGuide: '#spaces-around-equals'
1014 Enabled: true
1015 VersionAdded: '0.49'
1016 EnforcedStyle: space
1017 SupportedStyles:
1018 - space
1019 - no_space
1020
1021Layout/SpaceAroundKeyword:
1022 Description: 'Use a space around keywords if appropriate.'
1023 Enabled: true
1024 VersionAdded: '0.49'
1025
1026Layout/SpaceAroundOperators:
1027 Description: 'Use a single space around operators.'
1028 StyleGuide: '#spaces-operators'
1029 Enabled: true
1030 VersionAdded: '0.49'
1031 # When `true`, allows most uses of extra spacing if the intent is to align
1032 # with an operator on the previous or next line, not counting empty lines
1033 # or comment lines.
1034 AllowForAlignment: true
1035
1036Layout/SpaceBeforeBlockBraces:
1037 Description: >-
1038 Checks that the left block brace has or doesn't have space
1039 before it.
1040 Enabled: true
1041 VersionAdded: '0.49'
1042 EnforcedStyle: space
1043 SupportedStyles:
1044 - space
1045 - no_space
1046 EnforcedStyleForEmptyBraces: space
1047 SupportedStylesForEmptyBraces:
1048 - space
1049 - no_space
1050 VersionChanged: '0.52.1'
1051
1052Layout/SpaceBeforeComma:
1053 Description: 'No spaces before commas.'
1054 Enabled: true
1055 VersionAdded: '0.49'
1056
1057Layout/SpaceBeforeComment:
1058 Description: >-
1059 Checks for missing space between code and a comment on the
1060 same line.
1061 Enabled: true
1062 VersionAdded: '0.49'
1063
1064Layout/SpaceBeforeFirstArg:
1065 Description: >-
1066 Checks that exactly one space is used between a method name
1067 and the first argument for method calls without parentheses.
1068 Enabled: true
1069 VersionAdded: '0.49'
1070 # When `true`, allows most uses of extra spacing if the intent is to align
1071 # things with the previous or next line, not counting empty lines or comment
1072 # lines.
1073 AllowForAlignment: true
1074
1075Layout/SpaceBeforeSemicolon:
1076 Description: 'No spaces before semicolons.'
1077 Enabled: true
1078 VersionAdded: '0.49'
1079
1080Layout/SpaceInLambdaLiteral:
1081 Description: 'Checks for spaces in lambda literals.'
1082 Enabled: true
1083 VersionAdded: '0.49'
1084 EnforcedStyle: require_no_space
1085 SupportedStyles:
1086 - require_no_space
1087 - require_space
1088
1089Layout/SpaceInsideArrayLiteralBrackets:
1090 Description: 'Checks the spacing inside array literal brackets.'
1091 Enabled: true
1092 VersionAdded: '0.52'
1093 EnforcedStyle: no_space
1094 SupportedStyles:
1095 - space
1096 - no_space
1097 # 'compact' normally requires a space inside the brackets, with the exception
1098 # that successive left brackets or right brackets are collapsed together
1099 - compact
1100 EnforcedStyleForEmptyBrackets: no_space
1101 SupportedStylesForEmptyBrackets:
1102 - space
1103 - no_space
1104
1105Layout/SpaceInsideArrayPercentLiteral:
1106 Description: 'No unnecessary additional spaces between elements in %i/%w literals.'
1107 Enabled: true
1108 VersionAdded: '0.49'
1109
1110Layout/SpaceInsideBlockBraces:
1111 Description: >-
1112 Checks that block braces have or don't have surrounding space.
1113 For blocks taking parameters, checks that the left brace has
1114 or doesn't have trailing space.
1115 Enabled: true
1116 VersionAdded: '0.49'
1117 EnforcedStyle: space
1118 SupportedStyles:
1119 - space
1120 - no_space
1121 EnforcedStyleForEmptyBraces: no_space
1122 SupportedStylesForEmptyBraces:
1123 - space
1124 - no_space
1125 # Space between `{` and `|`. Overrides `EnforcedStyle` if there is a conflict.
1126 SpaceBeforeBlockParameters: true
1127
1128Layout/SpaceInsideHashLiteralBraces:
1129 Description: "Use spaces inside hash literal braces - or don't."
1130 StyleGuide: '#spaces-operators'
1131 Enabled: true
1132 VersionAdded: '0.49'
1133 EnforcedStyle: space
1134 SupportedStyles:
1135 - space
1136 - no_space
1137 # 'compact' normally requires a space inside hash braces, with the exception
1138 # that successive left braces or right braces are collapsed together
1139 - compact
1140 EnforcedStyleForEmptyBraces: no_space
1141 SupportedStylesForEmptyBraces:
1142 - space
1143 - no_space
1144
1145
1146Layout/SpaceInsideParens:
1147 Description: 'No spaces after ( or before ).'
1148 StyleGuide: '#spaces-braces'
1149 Enabled: true
1150 VersionAdded: '0.49'
1151 VersionChanged: '0.55'
1152 EnforcedStyle: no_space
1153 SupportedStyles:
1154 - space
1155 - no_space
1156
1157Layout/SpaceInsidePercentLiteralDelimiters:
1158 Description: 'No unnecessary spaces inside delimiters of %i/%w/%x literals.'
1159 Enabled: true
1160 VersionAdded: '0.49'
1161
1162Layout/SpaceInsideRangeLiteral:
1163 Description: 'No spaces inside range literals.'
1164 StyleGuide: '#no-space-inside-range-literals'
1165 Enabled: true
1166 VersionAdded: '0.49'
1167
1168Layout/SpaceInsideReferenceBrackets:
1169 Description: 'Checks the spacing inside referential brackets.'
1170 Enabled: true
1171 VersionAdded: '0.52'
1172 VersionChanged: '0.53'
1173 EnforcedStyle: no_space
1174 SupportedStyles:
1175 - space
1176 - no_space
1177 EnforcedStyleForEmptyBrackets: no_space
1178 SupportedStylesForEmptyBrackets:
1179 - space
1180 - no_space
1181
1182Layout/SpaceInsideStringInterpolation:
1183 Description: 'Checks for padding/surrounding spaces inside string interpolation.'
1184 StyleGuide: '#string-interpolation'
1185 Enabled: true
1186 VersionAdded: '0.49'
1187 EnforcedStyle: no_space
1188 SupportedStyles:
1189 - space
1190 - no_space
1191
1192Layout/Tab:
1193 Description: 'No hard tabs.'
1194 StyleGuide: '#spaces-indentation'
1195 Enabled: true
1196 VersionAdded: '0.49'
1197 VersionChanged: '0.51'
1198 # By default, the indentation width from Layout/IndentationWidth is used
1199 # But it can be overridden by setting this parameter
1200 # It is used during auto-correction to determine how many spaces should
1201 # replace each tab.
1202 IndentationWidth: ~
1203
1204Layout/TrailingBlankLines:
1205 Description: 'Checks trailing blank lines and final newline.'
1206 StyleGuide: '#newline-eof'
1207 Enabled: true
1208 VersionAdded: '0.49'
1209 EnforcedStyle: final_newline
1210 SupportedStyles:
1211 - final_newline
1212 - final_blank_line
1213
1214Layout/TrailingWhitespace:
1215 Description: 'Avoid trailing whitespace.'
1216 StyleGuide: '#no-trailing-whitespace'
1217 Enabled: true
1218 VersionAdded: '0.49'
1219 VersionChanged: '0.55'
1220 AllowInHeredoc: false
1221
1222#################### Lint ##################################
1223### Warnings
1224
1225Lint/AmbiguousBlockAssociation:
1226 Description: >-
1227 Checks for ambiguous block association with method when param passed without
1228 parentheses.
1229 StyleGuide: '#syntax'
1230 Enabled: true
1231 VersionAdded: '0.48'
1232
1233Lint/AmbiguousOperator:
1234 Description: >-
1235 Checks for ambiguous operators in the first argument of a
1236 method invocation without parentheses.
1237 StyleGuide: '#method-invocation-parens'
1238 Enabled: true
1239 VersionAdded: '0.17'
1240
1241Lint/AmbiguousRegexpLiteral:
1242 Description: >-
1243 Checks for ambiguous regexp literals in the first argument of
1244 a method invocation without parentheses.
1245 Enabled: true
1246 VersionAdded: '0.17'
1247
1248Lint/AssignmentInCondition:
1249 Description: "Don't use assignment in conditions."
1250 StyleGuide: '#safe-assignment-in-condition'
1251 Enabled: true
1252 VersionAdded: '0.9'
1253 AllowSafeAssignment: true
1254
1255Lint/BigDecimalNew:
1256 Description: '`BigDecimal.new()` is deprecated. Use `BigDecimal()` instead.'
1257 Enabled: true
1258 VersionAdded: '0.53'
1259
1260Lint/BooleanSymbol:
1261 Description: 'Check for `:true` and `:false` symbols.'
1262 Enabled: true
1263 VersionAdded: '0.50'
1264
1265Lint/CircularArgumentReference:
1266 Description: "Default values in optional keyword arguments and optional ordinal arguments should not refer back to the name of the argument."
1267 Enabled: true
1268 VersionAdded: '0.33'
1269
1270Lint/Debugger:
1271 Description: 'Check for debugger calls.'
1272 Enabled: true
1273 VersionAdded: '0.14'
1274 VersionChanged: '0.49'
1275
1276Lint/DeprecatedClassMethods:
1277 Description: 'Check for deprecated class method calls.'
1278 Enabled: true
1279 VersionAdded: '0.19'
1280
1281Lint/DisjunctiveAssignmentInConstructor:
1282 Description: 'In constructor, plain assignment is preferred over disjunctive.'
1283 Enabled: true
1284 Safe: false
1285 VersionAdded: '0.62'
1286
1287Lint/DuplicateCaseCondition:
1288 Description: 'Do not repeat values in case conditionals.'
1289 Enabled: true
1290 VersionAdded: '0.45'
1291
1292Lint/DuplicateMethods:
1293 Description: 'Check for duplicate method definitions.'
1294 Enabled: true
1295 VersionAdded: '0.29'
1296
1297Lint/DuplicatedKey:
1298 Description: 'Check for duplicate keys in hash literals.'
1299 Enabled: true
1300 VersionAdded: '0.34'
1301
1302Lint/EachWithObjectArgument:
1303 Description: 'Check for immutable argument given to each_with_object.'
1304 Enabled: true
1305 VersionAdded: '0.31'
1306
1307Lint/ElseLayout:
1308 Description: 'Check for odd code arrangement in an else block.'
1309 Enabled: true
1310 VersionAdded: '0.17'
1311
1312Lint/EmptyEnsure:
1313 Description: 'Checks for empty ensure block.'
1314 Enabled: true
1315 VersionAdded: '0.10'
1316 VersionChanged: '0.48'
1317 AutoCorrect: false
1318
1319Lint/EmptyExpression:
1320 Description: 'Checks for empty expressions.'
1321 Enabled: true
1322 VersionAdded: '0.45'
1323
1324Lint/EmptyInterpolation:
1325 Description: 'Checks for empty string interpolation.'
1326 Enabled: true
1327 VersionAdded: '0.20'
1328 VersionChanged: '0.45'
1329
1330Lint/EmptyWhen:
1331 Description: 'Checks for `when` branches with empty bodies.'
1332 Enabled: true
1333 VersionAdded: '0.45'
1334
1335Lint/EndInMethod:
1336 Description: 'END blocks should not be placed inside method definitions.'
1337 Enabled: true
1338 VersionAdded: '0.9'
1339
1340Lint/EnsureReturn:
1341 Description: 'Do not use return in an ensure block.'
1342 StyleGuide: '#no-return-ensure'
1343 Enabled: true
1344 VersionAdded: '0.9'
1345
1346Lint/ErbNewArguments:
1347 Description: 'Use `:trim_mode` and `:eoutvar` keyword arguments to `ERB.new`.'
1348 Enabled: true
1349 VersionAdded: '0.56'
1350
1351Lint/FlipFlop:
1352 Description: 'Checks for flip-flops'
1353 StyleGuide: '#no-flip-flops'
1354 Enabled: true
1355 VersionAdded: '0.16'
1356
1357Lint/FloatOutOfRange:
1358 Description: >-
1359 Catches floating-point literals too large or small for Ruby to
1360 represent.
1361 Enabled: true
1362 VersionAdded: '0.36'
1363
1364Lint/FormatParameterMismatch:
1365 Description: 'The number of parameters to format/sprint must match the fields.'
1366 Enabled: true
1367 VersionAdded: '0.33'
1368
1369Lint/HandleExceptions:
1370 Description: "Don't suppress exception."
1371 StyleGuide: '#dont-hide-exceptions'
1372 Enabled: true
1373 AllowComments: false
1374 VersionAdded: '0.9'
1375 VersionChanged: '0.70'
1376
1377Lint/HeredocMethodCallPosition:
1378 Description: >-
1379 Checks for the ordering of a method call where
1380 the receiver of the call is a HEREDOC.
1381 Enabled: false
1382 StyleGuide: '#heredoc-method-calls'
1383 VersionAdded: '0.68'
1384
1385Lint/ImplicitStringConcatenation:
1386 Description: >-
1387 Checks for adjacent string literals on the same line, which
1388 could better be represented as a single string literal.
1389 Enabled: true
1390 VersionAdded: '0.36'
1391
1392Lint/IneffectiveAccessModifier:
1393 Description: >-
1394 Checks for attempts to use `private` or `protected` to set
1395 the visibility of a class method, which does not work.
1396 Enabled: true
1397 VersionAdded: '0.36'
1398
1399Lint/InheritException:
1400 Description: 'Avoid inheriting from the `Exception` class.'
1401 Enabled: true
1402 VersionAdded: '0.41'
1403 # The default base class in favour of `Exception`.
1404 EnforcedStyle: runtime_error
1405 SupportedStyles:
1406 - runtime_error
1407 - standard_error
1408
1409Lint/InterpolationCheck:
1410 Description: 'Raise warning for interpolation in single q strs'
1411 Enabled: true
1412 VersionAdded: '0.50'
1413
1414Lint/LiteralAsCondition:
1415 Description: 'Checks of literals used in conditions.'
1416 Enabled: true
1417 VersionAdded: '0.51'
1418
1419Lint/LiteralInInterpolation:
1420 Description: 'Checks for literals used in interpolation.'
1421 Enabled: true
1422 VersionAdded: '0.19'
1423 VersionChanged: '0.32'
1424
1425Lint/Loop:
1426 Description: >-
1427 Use Kernel#loop with break rather than begin/end/until or
1428 begin/end/while for post-loop tests.
1429 StyleGuide: '#loop-with-break'
1430 Enabled: true
1431 VersionAdded: '0.9'
1432
1433Lint/MissingCopEnableDirective:
1434 Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`'
1435 Enabled: true
1436 VersionAdded: '0.52'
1437 # Maximum number of consecutive lines the cop can be disabled for.
1438 # 0 allows only single-line disables
1439 # 1 would mean the maximum allowed is the following:
1440 # # rubocop:disable SomeCop
1441 # a = 1
1442 # # rubocop:enable SomeCop
1443 # .inf for any size
1444 MaximumRangeSize: .inf
1445
1446Lint/MultipleCompare:
1447 Description: "Use `&&` operator to compare multiple value."
1448 Enabled: true
1449 VersionAdded: '0.47'
1450
1451Lint/NestedMethodDefinition:
1452 Description: 'Do not use nested method definitions.'
1453 StyleGuide: '#no-nested-methods'
1454 Enabled: true
1455 VersionAdded: '0.32'
1456
1457Lint/NestedPercentLiteral:
1458 Description: 'Checks for nested percent literals.'
1459 Enabled: true
1460 VersionAdded: '0.52'
1461
1462Lint/NextWithoutAccumulator:
1463 Description: >-
1464 Do not omit the accumulator when calling `next`
1465 in a `reduce`/`inject` block.
1466 Enabled: true
1467 VersionAdded: '0.36'
1468
1469Lint/NonLocalExitFromIterator:
1470 Description: 'Do not use return in iterator to cause non-local exit.'
1471 Enabled: true
1472 VersionAdded: '0.30'
1473
1474Lint/NumberConversion:
1475 Description: 'Checks unsafe usage of number conversion methods.'
1476 Enabled: false
1477 VersionAdded: '0.53'
1478 VersionChanged: '0.70'
1479 SafeAutoCorrect: false
1480
1481Lint/OrderedMagicComments:
1482 Description: 'Checks the proper ordering of magic comments and whether a magic comment is not placed before a shebang.'
1483 Enabled: true
1484 VersionAdded: '0.53'
1485
1486Lint/ParenthesesAsGroupedExpression:
1487 Description: >-
1488 Checks for method calls with a space before the opening
1489 parenthesis.
1490 StyleGuide: '#parens-no-spaces'
1491 Enabled: true
1492 VersionAdded: '0.12'
1493
1494Lint/PercentStringArray:
1495 Description: >-
1496 Checks for unwanted commas and quotes in %w/%W literals.
1497 Enabled: true
1498 Safe: false
1499 VersionAdded: '0.41'
1500
1501Lint/PercentSymbolArray:
1502 Description: >-
1503 Checks for unwanted commas and colons in %i/%I literals.
1504 Enabled: true
1505 VersionAdded: '0.41'
1506
1507Lint/RandOne:
1508 Description: >-
1509 Checks for `rand(1)` calls. Such calls always return `0`
1510 and most likely a mistake.
1511 Enabled: true
1512 VersionAdded: '0.36'
1513
1514Lint/RedundantWithIndex:
1515 Description: 'Checks for redundant `with_index`.'
1516 Enabled: true
1517 VersionAdded: '0.50'
1518
1519Lint/RedundantWithObject:
1520 Description: 'Checks for redundant `with_object`.'
1521 Enabled: true
1522 VersionAdded: '0.51'
1523
1524Lint/RegexpAsCondition:
1525 Description: >-
1526 Do not use regexp literal as a condition.
1527 The regexp literal matches `$_` implicitly.
1528 Enabled: true
1529 VersionAdded: '0.51'
1530
1531Lint/RequireParentheses:
1532 Description: >-
1533 Use parentheses in the method call to avoid confusion
1534 about precedence.
1535 Enabled: true
1536 VersionAdded: '0.18'
1537
1538Lint/RescueException:
1539 Description: 'Avoid rescuing the Exception class.'
1540 StyleGuide: '#no-blind-rescues'
1541 Enabled: true
1542 VersionAdded: '0.9'
1543 VersionChanged: '0.27.1'
1544
1545Lint/RescueType:
1546 Description: 'Avoid rescuing from non constants that could result in a `TypeError`.'
1547 Enabled: true
1548 VersionAdded: '0.49'
1549
1550Lint/ReturnInVoidContext:
1551 Description: 'Checks for return in void context.'
1552 Enabled: true
1553 VersionAdded: '0.50'
1554
1555Lint/SafeNavigationChain:
1556 Description: 'Do not chain ordinary method call after safe navigation operator.'
1557 Enabled: true
1558 VersionAdded: '0.47'
1559 VersionChanged: '0.56'
1560 Whitelist:
1561 - present?
1562 - blank?
1563 - presence
1564 - try
1565 - try!
1566
1567Lint/SafeNavigationConsistency:
1568 Description: >-
1569 Check to make sure that if safe navigation is used for a method
1570 call in an `&&` or `||` condition that safe navigation is used
1571 for all method calls on that same object.
1572 Enabled: true
1573 VersionAdded: '0.55'
1574 Whitelist:
1575 - present?
1576 - blank?
1577 - presence
1578 - try
1579 - try!
1580
1581
1582Lint/SafeNavigationWithEmpty:
1583 Description: 'Avoid `foo&.empty?` in conditionals.'
1584 Enabled: true
1585 VersionAdded: '0.62'
1586
1587Lint/ScriptPermission:
1588 Description: 'Grant script file execute permission.'
1589 Enabled: true
1590 VersionAdded: '0.49'
1591 VersionChanged: '0.50'
1592
1593Lint/ShadowedArgument:
1594 Description: 'Avoid reassigning arguments before they were used.'
1595 Enabled: true
1596 VersionAdded: '0.52'
1597 IgnoreImplicitReferences: false
1598
1599
1600Lint/ShadowedException:
1601 Description: >-
1602 Avoid rescuing a higher level exception
1603 before a lower level exception.
1604 Enabled: true
1605 VersionAdded: '0.41'
1606
1607Lint/ShadowingOuterLocalVariable:
1608 Description: >-
1609 Do not use the same name as outer local variable
1610 for block arguments or block local variables.
1611 Enabled: true
1612 VersionAdded: '0.9'
1613
1614Lint/StringConversionInInterpolation:
1615 Description: 'Checks for Object#to_s usage in string interpolation.'
1616 StyleGuide: '#no-to-s'
1617 Enabled: true
1618 VersionAdded: '0.19'
1619 VersionChanged: '0.20'
1620
1621Lint/Syntax:
1622 Description: 'Checks syntax error'
1623 Enabled: true
1624 VersionAdded: '0.9'
1625
1626
1627Lint/ToJSON:
1628 Description: 'Ensure #to_json includes an optional argument.'
1629 Enabled: true
1630
1631Lint/UnderscorePrefixedVariableName:
1632 Description: 'Do not use prefix `_` for a variable that is used.'
1633 Enabled: true
1634 VersionAdded: '0.21'
1635 AllowKeywordBlockArguments: false
1636
1637Lint/UnifiedInteger:
1638 Description: 'Use Integer instead of Fixnum or Bignum'
1639 Enabled: true
1640 VersionAdded: '0.43'
1641
1642Lint/UnneededCopDisableDirective:
1643 Description: >-
1644 Checks for rubocop:disable comments that can be removed.
1645 Note: this cop is not disabled when disabling all cops.
1646 It must be explicitly disabled.
1647 Enabled: true
1648 VersionAdded: '0.53'
1649
1650Lint/UnneededCopEnableDirective:
1651 Description: Checks for rubocop:enable comments that can be removed.
1652 Enabled: true
1653 VersionAdded: '0.53'
1654
1655Lint/UnneededRequireStatement:
1656 Description: 'Checks for unnecessary `require` statement.'
1657 Enabled: true
1658 VersionAdded: '0.51'
1659
1660Lint/UnneededSplatExpansion:
1661 Description: 'Checks for splat unnecessarily being called on literals'
1662 Enabled: true
1663 VersionAdded: '0.43'
1664
1665Lint/UnreachableCode:
1666 Description: 'Unreachable code.'
1667 Enabled: true
1668 VersionAdded: '0.9'
1669
1670Lint/UnusedBlockArgument:
1671 Description: 'Checks for unused block arguments.'
1672 StyleGuide: '#underscore-unused-vars'
1673 Enabled: true
1674 VersionAdded: '0.21'
1675 VersionChanged: '0.22'
1676 IgnoreEmptyBlocks: true
1677 AllowUnusedKeywordArguments: false
1678
1679Lint/UnusedMethodArgument:
1680 Description: 'Checks for unused method arguments.'
1681 StyleGuide: '#underscore-unused-vars'
1682 Enabled: true
1683 VersionAdded: '0.21'
1684 VersionChanged: '0.35'
1685 AllowUnusedKeywordArguments: false
1686 IgnoreEmptyMethods: true
1687
1688Lint/UriEscapeUnescape:
1689 Description: >-
1690 `URI.escape` method is obsolete and should not be used. Instead, use
1691 `CGI.escape`, `URI.encode_www_form` or `URI.encode_www_form_component`
1692 depending on your specific use case.
1693 Also `URI.unescape` method is obsolete and should not be used. Instead, use
1694 `CGI.unescape`, `URI.decode_www_form` or `URI.decode_www_form_component`
1695 depending on your specific use case.
1696 Enabled: true
1697 VersionAdded: '0.50'
1698
1699Lint/UriRegexp:
1700 Description: 'Use `URI::DEFAULT_PARSER.make_regexp` instead of `URI.regexp`.'
1701 Enabled: true
1702 VersionAdded: '0.50'
1703
1704Lint/UselessAccessModifier:
1705 Description: 'Checks for useless access modifiers.'
1706 Enabled: true
1707 VersionAdded: '0.20'
1708 VersionChanged: '0.47'
1709 ContextCreatingMethods: []
1710 MethodCreatingMethods: []
1711
1712Lint/UselessAssignment:
1713 Description: 'Checks for useless assignment to a local variable.'
1714 StyleGuide: '#underscore-unused-vars'
1715 Enabled: true
1716 VersionAdded: '0.11'
1717
1718Lint/UselessComparison:
1719 Description: 'Checks for comparison of something with itself.'
1720 Enabled: true
1721 VersionAdded: '0.11'
1722
1723Lint/UselessElseWithoutRescue:
1724 Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
1725 Enabled: true
1726 VersionAdded: '0.17'
1727
1728Lint/UselessSetterCall:
1729 Description: 'Checks for useless setter call to a local variable.'
1730 Enabled: true
1731 VersionAdded: '0.13'
1732
1733Lint/Void:
1734 Description: 'Possible use of operator/literal/variable in void context.'
1735 Enabled: true
1736 VersionAdded: '0.9'
1737 CheckForMethodsWithNoSideEffects: false
1738
1739#################### Metrics ###############################
1740
1741Metrics/AbcSize:
1742 Description: >-
1743 A calculated magnitude based on number of assignments,
1744 branches, and conditions.
1745 Reference:
1746 - http://c2.com/cgi/wiki?AbcMetric
1747 - https://en.wikipedia.org/wiki/ABC_Software_Metric'
1748 Enabled: false
1749 VersionAdded: '0.27'
1750 VersionChanged: '0.66'
1751 # The ABC size is a calculated magnitude, so this number can be an Integer or
1752 # a Float.
1753 Max: 15
1754
1755Metrics/BlockLength:
1756 Description: 'Avoid long blocks with many lines.'
1757 Enabled: true
1758 VersionAdded: '0.44'
1759 VersionChanged: '0.66'
1760 CountComments: false # count full line comments?
1761 Max: 50
1762 ExcludedMethods:
1763 # By default, exclude the `#refine` method, as it tends to have larger
1764 # associated blocks.
1765 - refine
1766 Exclude:
1767 - '**/*.gemspec'
1768
1769Metrics/BlockNesting:
1770 Description: 'Avoid excessive block nesting'
1771 StyleGuide: '#three-is-the-number-thou-shalt-count'
1772 Enabled: true
1773 VersionAdded: '0.25'
1774 VersionChanged: '0.47'
1775 CountBlocks: false
1776 Max: 4
1777
1778Metrics/ClassLength:
1779 Description: 'Avoid classes longer than 100 lines of code.'
1780 Enabled: true
1781 VersionAdded: '0.25'
1782 CountComments: false # count full line comments?
1783 Max: 100
1784
1785# Avoid complex methods.
1786Metrics/CyclomaticComplexity:
1787 Description: >-
1788 A complexity metric that is strongly correlated to the number
1789 of test cases needed to validate a method.
1790 Enabled: false
1791 VersionAdded: '0.25'
1792 Max: 6
1793
1794Metrics/LineLength:
1795 Description: 'Limit lines to 100 characters.'
1796 StyleGuide: '#80-character-limits'
1797 Enabled: true
1798 VersionAdded: '0.25'
1799 VersionChanged: '0.68'
1800 AutoCorrect: false
1801 Max: 100
1802 # To make it possible to copy or click on URIs in the code, we allow lines
1803 # containing a URI to be longer than Max.
1804 AllowHeredoc: true
1805 AllowURI: true
1806 URISchemes:
1807 - http
1808 - https
1809 # The IgnoreCopDirectives option causes the LineLength rule to ignore cop
1810 # directives like '# rubocop: enable ...' when calculating a line's length.
1811 IgnoreCopDirectives: false
1812 # The IgnoredPatterns option is a list of !ruby/regexp and/or string
1813 # elements. Strings will be converted to Regexp objects. A line that matches
1814 # any regular expression listed in this option will be ignored by LineLength.
1815 IgnoredPatterns: []
1816
1817Metrics/MethodLength:
1818 Description: 'Avoid methods longer than 10 lines of code.'
1819 StyleGuide: '#short-methods'
1820 Enabled: true
1821 VersionAdded: '0.25'
1822 VersionChanged: '0.59.2'
1823 CountComments: false # count full line comments?
1824 Max: 20
1825 ExcludedMethods: []
1826
1827Metrics/ModuleLength:
1828 Description: 'Avoid modules longer than 100 lines of code.'
1829 Enabled: true
1830 VersionAdded: '0.31'
1831 CountComments: false # count full line comments?
1832 Max: 100
1833
1834Metrics/ParameterLists:
1835 Description: 'Avoid parameter lists longer than three or four parameters.'
1836 StyleGuide: '#too-many-params'
1837 Enabled: true
1838 VersionAdded: '0.25'
1839 Max: 5
1840 CountKeywordArgs: true
1841
1842Metrics/PerceivedComplexity:
1843 Description: >-
1844 A complexity metric geared towards measuring complexity for a
1845 human reader.
1846 Enabled: false
1847 VersionAdded: '0.25'
1848 Max: 7
1849
1850#################### Naming ##############################
1851
1852Naming/AccessorMethodName:
1853 Description: Check the naming of accessor methods for get_/set_.
1854 StyleGuide: '#accessor_mutator_method_names'
1855 Enabled: true
1856 VersionAdded: '0.50'
1857
1858Naming/AsciiIdentifiers:
1859 Description: 'Use only ascii symbols in identifiers.'
1860 StyleGuide: '#english-identifiers'
1861 Enabled: true
1862 VersionAdded: '0.50'
1863
1864Naming/BinaryOperatorParameterName:
1865 Description: 'When defining binary operators, name the argument other.'
1866 StyleGuide: '#other-arg'
1867 Enabled: true
1868 VersionAdded: '0.50'
1869
1870Naming/ClassAndModuleCamelCase:
1871 Description: 'Use CamelCase for classes and modules.'
1872 StyleGuide: '#camelcase-classes'
1873 Enabled: true
1874 VersionAdded: '0.50'
1875
1876Naming/ConstantName:
1877 Description: 'Constants should use SCREAMING_SNAKE_CASE.'
1878 StyleGuide: '#screaming-snake-case'
1879 Enabled: true
1880 VersionAdded: '0.50'
1881
1882Naming/FileName:
1883 Description: 'Use snake_case for source file names.'
1884 StyleGuide: '#snake-case-files'
1885 Enabled: true
1886 VersionAdded: '0.50'
1887 # Camel case file names listed in `AllCops:Include` and all file names listed
1888 # in `AllCops:Exclude` are excluded by default. Add extra excludes here.
1889 Exclude: []
1890 # When `true`, requires that each source file should define a class or module
1891 # with a name which matches the file name (converted to ... case).
1892 # It further expects it to be nested inside modules which match the names
1893 # of subdirectories in its path.
1894 ExpectMatchingDefinition: false
1895 # If non-`nil`, expect all source file names to match the following regex.
1896 # Only the file name itself is matched, not the entire file path.
1897 # Use anchors as necessary if you want to match the entire name rather than
1898 # just a part of it.
1899 Regex: ~
1900 # With `IgnoreExecutableScripts` set to `true`, this cop does not
1901 # report offending filenames for executable scripts (i.e. source
1902 # files with a shebang in the first line).
1903 IgnoreExecutableScripts: true
1904 AllowedAcronyms:
1905 - CLI
1906 - DSL
1907 - ACL
1908 - API
1909 - ASCII
1910 - CPU
1911 - CSS
1912 - DNS
1913 - EOF
1914 - GUID
1915 - HTML
1916 - HTTP
1917 - HTTPS
1918 - ID
1919 - IP
1920 - JSON
1921 - LHS
1922 - QPS
1923 - RAM
1924 - RHS
1925 - RPC
1926 - SLA
1927 - SMTP
1928 - SQL
1929 - SSH
1930 - TCP
1931 - TLS
1932 - TTL
1933 - UDP
1934 - UI
1935 - UID
1936 - UUID
1937 - URI
1938 - URL
1939 - UTF8
1940 - VM
1941 - XML
1942 - XMPP
1943 - XSRF
1944 - XSS
1945
1946Naming/HeredocDelimiterCase:
1947 Description: 'Use configured case for heredoc delimiters.'
1948 StyleGuide: '#heredoc-delimiters'
1949 Enabled: true
1950 VersionAdded: '0.50'
1951 EnforcedStyle: uppercase
1952 SupportedStyles:
1953 - lowercase
1954 - uppercase
1955
1956Naming/HeredocDelimiterNaming:
1957 Description: 'Use descriptive heredoc delimiters.'
1958 StyleGuide: '#heredoc-delimiters'
1959 Enabled: true
1960 VersionAdded: '0.50'
1961 Blacklist:
1962 - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/'
1963
1964Naming/MemoizedInstanceVariableName:
1965 Description: >-
1966 Memoized method name should match memo instance variable name.
1967 Enabled: true
1968 VersionAdded: '0.53'
1969 VersionChanged: '0.58'
1970 EnforcedStyleForLeadingUnderscores: disallowed
1971 SupportedStylesForLeadingUnderscores:
1972 - disallowed
1973 - required
1974 - optional
1975
1976Naming/MethodName:
1977 Description: 'Use the configured style when naming methods.'
1978 StyleGuide: '#snake-case-symbols-methods-vars'
1979 Enabled: true
1980 VersionAdded: '0.50'
1981 EnforcedStyle: snake_case
1982 SupportedStyles:
1983 - snake_case
1984 - camelCase
1985
1986Naming/PredicateName:
1987 Description: 'Check the names of predicate methods.'
1988 StyleGuide: '#bool-methods-qmark'
1989 Enabled: true
1990 VersionAdded: '0.50'
1991 VersionChanged: '0.51'
1992 # Predicate name prefixes.
1993 NamePrefix:
1994 - is_
1995 - has_
1996 - have_
1997 # Predicate name prefixes that should be removed.
1998 NamePrefixBlacklist:
1999 - is_
2000 - has_
2001 - have_
2002 # Predicate names which, despite having a blacklisted prefix, or no `?`,
2003 # should still be accepted
2004 NameWhitelist:
2005 - is_a?
2006 # Method definition macros for dynamically generated methods.
2007 MethodDefinitionMacros:
2008 - define_method
2009 - define_singleton_method
2010 # Exclude Rspec specs because there is a strong convention to write spec
2011 # helpers in the form of `have_something` or `be_something`.
2012 Exclude:
2013 - 'spec/**/*'
2014
2015Naming/RescuedExceptionsVariableName:
2016 Description: 'Use consistent rescued exceptions variables naming.'
2017 Enabled: true
2018 VersionAdded: '0.67'
2019 VersionChanged: '0.68'
2020 PreferredName: e
2021
2022Naming/UncommunicativeBlockParamName:
2023 Description: >-
2024 Checks for block parameter names that contain capital letters,
2025 end in numbers, or do not meet a minimal length.
2026 Enabled: true
2027 VersionAdded: '0.53'
2028 # Parameter names may be equal to or greater than this value
2029 MinNameLength: 1
2030 AllowNamesEndingInNumbers: true
2031 # Whitelisted names that will not register an offense
2032 AllowedNames: []
2033 # Blacklisted names that will register an offense
2034 ForbiddenNames: []
2035
2036Naming/UncommunicativeMethodParamName:
2037 Description: >-
2038 Checks for method parameter names that contain capital letters,
2039 end in numbers, or do not meet a minimal length.
2040 Enabled: true
2041 VersionAdded: '0.53'
2042 VersionChanged: '0.59'
2043 # Parameter names may be equal to or greater than this value
2044 MinNameLength: 3
2045 AllowNamesEndingInNumbers: true
2046 # Whitelisted names that will not register an offense
2047 AllowedNames:
2048 - io
2049 - id
2050 - to
2051 - by
2052 - 'on'
2053 - in
2054 - at
2055 - ip
2056 - db
2057 # Blacklisted names that will register an offense
2058 ForbiddenNames: []
2059
2060
2061Naming/VariableName:
2062 Description: 'Use the configured style when naming variables.'
2063 StyleGuide: '#snake-case-symbols-methods-vars'
2064 Enabled: true
2065 VersionAdded: '0.50'
2066 EnforcedStyle: snake_case
2067 SupportedStyles:
2068 - snake_case
2069 - camelCase
2070
2071Naming/VariableNumber:
2072 Description: 'Use the configured style when numbering variables.'
2073 Enabled: true
2074 VersionAdded: '0.50'
2075 EnforcedStyle: normalcase
2076 SupportedStyles:
2077 - snake_case
2078 - normalcase
2079 - non_integer
2080
2081#################### Rails #################################
2082
2083# By default, the rails cops are not run. Override in project or home
2084# directory .rubocop.yml files, or by giving the -R/--rails option.
2085Rails:
2086 Enabled: false
2087
2088Rails/ActionFilter:
2089 Description: 'Enforces consistent use of action filter methods.'
2090 Enabled: true
2091 VersionAdded: '0.19'
2092 EnforcedStyle: action
2093 SupportedStyles:
2094 - action
2095 - filter
2096 Include:
2097 - app/controllers/**/*.rb
2098
2099Rails/ActiveRecordAliases:
2100 Description: >-
2101 Avoid Active Record aliases:
2102 Use `update` instead of `update_attributes`.
2103 Use `update!` instead of `update_attributes!`.
2104 Enabled: true
2105 VersionAdded: '0.53'
2106
2107Rails/ActiveRecordOverride:
2108 Description: >-
2109 Check for overriding Active Record methods instead of using
2110 callbacks.
2111 Enabled: true
2112 VersionAdded: '0.67'
2113 Include:
2114 - app/models/**/*.rb
2115
2116Rails/ActiveSupportAliases:
2117 Description: >-
2118 Avoid ActiveSupport aliases of standard ruby methods:
2119 `String#starts_with?`, `String#ends_with?`,
2120 `Array#append`, `Array#prepend`.
2121 Enabled: true
2122 VersionAdded: '0.48'
2123
2124Rails/ApplicationJob:
2125 Description: 'Check that jobs subclass ApplicationJob.'
2126 Enabled: true
2127 VersionAdded: '0.49'
2128
2129Rails/ApplicationRecord:
2130 Description: 'Check that models subclass ApplicationRecord.'
2131 Enabled: true
2132 VersionAdded: '0.49'
2133
2134Rails/AssertNot:
2135 Description: 'Use `assert_not` instead of `assert !`.'
2136 Enabled: true
2137 VersionAdded: '0.56'
2138 Include:
2139 - '**/test/**/*'
2140
2141Rails/BelongsTo:
2142 Description: >-
2143 Use `optional: true` instead of `required: false` for
2144 `belongs_to` relations'
2145 Enabled: true
2146 VersionAdded: '0.62'
2147
2148Rails/Blank:
2149 Description: 'Enforces use of `blank?`.'
2150 Enabled: true
2151 VersionAdded: '0.48'
2152 VersionChanged: '0.67'
2153 # Convert usages of `nil? || empty?` to `blank?`
2154 NilOrEmpty: true
2155 # Convert usages of `!present?` to `blank?`
2156 NotPresent: true
2157 # Convert usages of `unless present?` to `if blank?`
2158 UnlessPresent: true
2159
2160Rails/BulkChangeTable:
2161 Description: 'Check whether alter queries are combinable.'
2162 Enabled: true
2163 VersionAdded: '0.57'
2164 Database: null
2165 SupportedDatabases:
2166 - mysql
2167 - postgresql
2168 Include:
2169 - db/migrate/*.rb
2170
2171Rails/CreateTableWithTimestamps:
2172 Description: >-
2173 Checks the migration for which timestamps are not included
2174 when creating a new table.
2175 Enabled: true
2176 VersionAdded: '0.52'
2177 Include:
2178 - db/migrate/*.rb
2179
2180Rails/Date:
2181 Description: >-
2182 Checks the correct usage of date aware methods,
2183 such as Date.today, Date.current etc.
2184 Enabled: true
2185 VersionAdded: '0.30'
2186 VersionChanged: '0.33'
2187 # The value `strict` disallows usage of `Date.today`, `Date.current`,
2188 # `Date#to_time` etc.
2189 # The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
2190 # (but not `Date.today`) which are overridden by ActiveSupport to handle current
2191 # time zone.
2192 EnforcedStyle: flexible
2193 SupportedStyles:
2194 - strict
2195 - flexible
2196
2197Rails/Delegate:
2198 Description: 'Prefer delegate method for delegations.'
2199 Enabled: true
2200 VersionAdded: '0.21'
2201 VersionChanged: '0.50'
2202 # When set to true, using the target object as a prefix of the
2203 # method name without using the `delegate` method will be a
2204 # violation. When set to false, this case is legal.
2205 EnforceForPrefixed: true
2206
2207Rails/DelegateAllowBlank:
2208 Description: 'Do not use allow_blank as an option to delegate.'
2209 Enabled: true
2210 VersionAdded: '0.44'
2211
2212Rails/DynamicFindBy:
2213 Description: 'Use `find_by` instead of dynamic `find_by_*`.'
2214 StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find_by'
2215 Enabled: true
2216 VersionAdded: '0.44'
2217 Whitelist:
2218 - find_by_sql
2219
2220Rails/EnumUniqueness:
2221 Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
2222 Enabled: true
2223 VersionAdded: '0.46'
2224 Include:
2225 - app/models/**/*.rb
2226
2227Rails/EnvironmentComparison:
2228 Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`"
2229 Enabled: true
2230 VersionAdded: '0.52'
2231
2232Rails/Exit:
2233 Description: >-
2234 Favor `fail`, `break`, `return`, etc. over `exit` in
2235 application or library code outside of Rake files to avoid
2236 exits during unit testing or running in production.
2237 Enabled: true
2238 VersionAdded: '0.41'
2239 Include:
2240 - app/**/*.rb
2241 - config/**/*.rb
2242 - lib/**/*.rb
2243 Exclude:
2244 - lib/**/*.rake
2245
2246Rails/FilePath:
2247 Description: 'Use `Rails.root.join` for file path joining.'
2248 Enabled: true
2249 VersionAdded: '0.47'
2250 VersionChanged: '0.57'
2251 EnforcedStyle: arguments
2252 SupportedStyles:
2253 - slashes
2254 - arguments
2255
2256Rails/FindBy:
2257 Description: 'Prefer find_by over where.first.'
2258 StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find_by'
2259 Enabled: true
2260 VersionAdded: '0.30'
2261 Include:
2262 - app/models/**/*.rb
2263
2264Rails/FindEach:
2265 Description: 'Prefer all.find_each over all.find.'
2266 StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find-each'
2267 Enabled: true
2268 VersionAdded: '0.30'
2269 Include:
2270 - app/models/**/*.rb
2271
2272Rails/HasAndBelongsToMany:
2273 Description: 'Prefer has_many :through to has_and_belongs_to_many.'
2274 StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#has-many-through'
2275 Enabled: true
2276 VersionAdded: '0.12'
2277 Include:
2278 - app/models/**/*.rb
2279
2280Rails/HasManyOrHasOneDependent:
2281 Description: 'Define the dependent option to the has_many and has_one associations.'
2282 StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#has_many-has_one-dependent-option'
2283 Enabled: true
2284 VersionAdded: '0.50'
2285 Include:
2286 - app/models/**/*.rb
2287
2288Rails/HttpPositionalArguments:
2289 Description: 'Use keyword arguments instead of positional arguments in http method calls.'
2290 Enabled: true
2291 VersionAdded: '0.44'
2292 Include:
2293 - 'spec/**/*'
2294 - 'test/**/*'
2295
2296Rails/HttpStatus:
2297 Description: 'Enforces use of symbolic or numeric value to define HTTP status.'
2298 Enabled: true
2299 VersionAdded: '0.54'
2300 EnforcedStyle: symbolic
2301 SupportedStyles:
2302 - numeric
2303 - symbolic
2304
2305Rails/IgnoredSkipActionFilterOption:
2306 Description: 'Checks that `if` and `only` (or `except`) are not used together as options of `skip_*` action filter.'
2307 Reference: 'https://api.rubyonrails.org/classes/AbstractController/Callbacks/ClassMethods.html#method-i-_normalize_callback_options'
2308 Enabled: true
2309 VersionAdded: '0.63'
2310 Include:
2311 - app/controllers/**/*.rb
2312
2313Rails/InverseOf:
2314 Description: 'Checks for associations where the inverse cannot be determined automatically.'
2315 Enabled: true
2316 VersionAdded: '0.52'
2317 Include:
2318 - app/models/**/*.rb
2319
2320Rails/LexicallyScopedActionFilter:
2321 Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller."
2322 StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#lexically-scoped-action-filter'
2323 Enabled: true
2324 Safe: false
2325 VersionAdded: '0.52'
2326 Include:
2327 - app/controllers/**/*.rb
2328
2329Rails/LinkToBlank:
2330 Description: 'Checks that `link_to` with a `target: "_blank"` have a `rel: "noopener"` option passed to them.'
2331 Reference:
2332 - https://mathiasbynens.github.io/rel-noopener/
2333 - https://html.spec.whatwg.org/multipage/links.html#link-type-noopener
2334 - https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer
2335 Enabled: true
2336 VersionAdded: '0.62'
2337
2338Rails/NotNullColumn:
2339 Description: 'Do not add a NOT NULL column without a default value'
2340 Enabled: true
2341 VersionAdded: '0.43'
2342 Include:
2343 - db/migrate/*.rb
2344
2345Rails/Output:
2346 Description: 'Checks for calls to puts, print, etc.'
2347 Enabled: true
2348 VersionAdded: '0.15'
2349 VersionChanged: '0.19'
2350 Include:
2351 - app/**/*.rb
2352 - config/**/*.rb
2353 - db/**/*.rb
2354 - lib/**/*.rb
2355
2356Rails/OutputSafety:
2357 Description: 'The use of `html_safe` or `raw` may be a security risk.'
2358 Enabled: true
2359 VersionAdded: '0.41'
2360
2361Rails/PluralizationGrammar:
2362 Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
2363 Enabled: true
2364 VersionAdded: '0.35'
2365
2366Rails/Presence:
2367 Description: 'Checks code that can be written more easily using `Object#presence` defined by Active Support.'
2368 Enabled: true
2369 VersionAdded: '0.52'
2370
2371Rails/Present:
2372 Description: 'Enforces use of `present?`.'
2373 Enabled: true
2374 VersionAdded: '0.48'
2375 VersionChanged: '0.67'
2376 # Convert usages of `!nil? && !empty?` to `present?`
2377 NotNilAndNotEmpty: true
2378 # Convert usages of `!blank?` to `present?`
2379 NotBlank: true
2380 # Convert usages of `unless blank?` to `if present?`
2381 UnlessBlank: true
2382
2383Rails/ReadWriteAttribute:
2384 Description: >-
2385 Checks for read_attribute(:attr) and
2386 write_attribute(:attr, val).
2387 StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#read-attribute'
2388 Enabled: true
2389 VersionAdded: '0.20'
2390 VersionChanged: '0.29'
2391 Include:
2392 - app/models/**/*.rb
2393
2394Rails/RedundantAllowNil:
2395 Description: >-
2396 Finds redundant use of `allow_nil` when `allow_blank` is set to
2397 certain values in model validations.
2398 Enabled: true
2399 VersionAdded: '0.67'
2400 Include:
2401 - app/models/**/*.rb
2402
2403Rails/RedundantReceiverInWithOptions:
2404 Description: 'Checks for redundant receiver in `with_options`.'
2405 Enabled: true
2406 VersionAdded: '0.52'
2407
2408Rails/ReflectionClassName:
2409 Description: 'Use a string for `class_name` option value in the definition of a reflection.'
2410 Enabled: true
2411 VersionAdded: '0.64'
2412
2413Rails/RefuteMethods:
2414 Description: 'Use `assert_not` methods instead of `refute` methods.'
2415 Enabled: true
2416 VersionAdded: '0.56'
2417 Include:
2418 - '**/test/**/*'
2419
2420Rails/RelativeDateConstant:
2421 Description: 'Do not assign relative date to constants.'
2422 Enabled: true
2423 VersionAdded: '0.48'
2424 VersionChanged: '0.59'
2425 AutoCorrect: false
2426
2427Rails/RequestReferer:
2428 Description: 'Use consistent syntax for request.referer.'
2429 Enabled: true
2430 VersionAdded: '0.41'
2431 EnforcedStyle: referer
2432 SupportedStyles:
2433 - referer
2434 - referrer
2435
2436Rails/ReversibleMigration:
2437 Description: 'Checks whether the change method of the migration file is reversible.'
2438 StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#reversible-migration'
2439 Reference: 'https://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
2440 Enabled: true
2441 VersionAdded: '0.47'
2442 Include:
2443 - db/migrate/*.rb
2444
2445Rails/SafeNavigation:
2446 Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
2447 Enabled: true
2448 VersionAdded: '0.43'
2449 # This will convert usages of `try` to use safe navigation as well as `try!`.
2450 # `try` and `try!` work slightly differently. `try!` and safe navigation will
2451 # both raise a `NoMethodError` if the receiver of the method call does not
2452 # implement the intended method. `try` will not raise an exception for this.
2453 ConvertTry: false
2454
2455Rails/SaveBang:
2456 Description: 'Identifies possible cases where Active Record save! or related should be used.'
2457 StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#save-bang'
2458 Enabled: false
2459 VersionAdded: '0.42'
2460 VersionChanged: '0.59'
2461 AllowImplicitReturn: true
2462 AllowedReceivers: []
2463
2464Rails/ScopeArgs:
2465 Description: 'Checks the arguments of ActiveRecord scopes.'
2466 Enabled: true
2467 VersionAdded: '0.19'
2468 Include:
2469 - app/models/**/*.rb
2470
2471Rails/SkipsModelValidations:
2472 Description: >-
2473 Use methods that skips model validations with caution.
2474 See reference for more information.
2475 Reference: 'https://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
2476 Enabled: true
2477 VersionAdded: '0.47'
2478 VersionChanged: '0.60'
2479 Blacklist:
2480 - decrement!
2481 - decrement_counter
2482 - increment!
2483 - increment_counter
2484 - toggle!
2485 - touch
2486 - update_all
2487 - update_attribute
2488 - update_column
2489 - update_columns
2490 - update_counters
2491 Whitelist: []
2492
2493Rails/TimeZone:
2494 Description: 'Checks the correct usage of time zone aware methods.'
2495 StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#time'
2496 Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
2497 Enabled: true
2498 Safe: false
2499 VersionAdded: '0.30'
2500 VersionChanged: '0.68'
2501 # The value `strict` means that `Time` should be used with `zone`.
2502 # The value `flexible` allows usage of `in_time_zone` instead of `zone`.
2503 EnforcedStyle: flexible
2504 SupportedStyles:
2505 - strict
2506 - flexible
2507
2508Rails/UniqBeforePluck:
2509 Description: 'Prefer the use of uniq or distinct before pluck.'
2510 Enabled: true
2511 VersionAdded: '0.40'
2512 VersionChanged: '0.47'
2513 EnforcedStyle: conservative
2514 SupportedStyles:
2515 - conservative
2516 - aggressive
2517 AutoCorrect: false
2518
2519Rails/UnknownEnv:
2520 Description: 'Use correct environment name.'
2521 Enabled: true
2522 VersionAdded: '0.51'
2523 Environments:
2524 - development
2525 - test
2526 - production
2527
2528Rails/Validation:
2529 Description: 'Use validates :attribute, hash of validations.'
2530 Enabled: true
2531 VersionAdded: '0.9'
2532 VersionChanged: '0.41'
2533 Include:
2534 - app/models/**/*.rb
2535
2536#################### Security ##############################
2537
2538Security/Eval:
2539 Description: 'The use of eval represents a serious security risk.'
2540 Enabled: true
2541 VersionAdded: '0.47'
2542
2543Security/JSONLoad:
2544 Description: >-
2545 Prefer usage of `JSON.parse` over `JSON.load` due to potential
2546 security issues. See reference for more information.
2547 Reference: 'https://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load'
2548 Enabled: true
2549 VersionAdded: '0.43'
2550 VersionChanged: '0.44'
2551 # Autocorrect here will change to a method that may cause crashes depending
2552 # on the value of the argument.
2553 AutoCorrect: false
2554 SafeAutoCorrect: false
2555
2556Security/MarshalLoad:
2557 Description: >-
2558 Avoid using of `Marshal.load` or `Marshal.restore` due to potential
2559 security issues. See reference for more information.
2560 Reference: 'https://ruby-doc.org/core-2.3.3/Marshal.html#module-Marshal-label-Security+considerations'
2561 Enabled: true
2562 VersionAdded: '0.47'
2563
2564Security/Open:
2565 Description: 'The use of Kernel#open represents a serious security risk.'
2566 Enabled: true
2567 VersionAdded: '0.53'
2568 Safe: false
2569
2570Security/YAMLLoad:
2571 Description: >-
2572 Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
2573 security issues. See reference for more information.
2574 Reference: 'https://ruby-doc.org/stdlib-2.3.3/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
2575 Enabled: true
2576 VersionAdded: '0.47'
2577 SafeAutoCorrect: false
2578
2579#################### Style ###############################
2580
2581Style/AccessModifierDeclarations:
2582 Description: 'Checks style of how access modifiers are used.'
2583 Enabled: true
2584 VersionAdded: '0.57'
2585 EnforcedStyle: group
2586 SupportedStyles:
2587 - inline
2588 - group
2589
2590Style/Alias:
2591 Description: 'Use alias instead of alias_method.'
2592 StyleGuide: '#alias-method'
2593 Enabled: true
2594 VersionAdded: '0.9'
2595 VersionChanged: '0.36'
2596 EnforcedStyle: prefer_alias
2597 SupportedStyles:
2598 - prefer_alias
2599 - prefer_alias_method
2600
2601Style/AndOr:
2602 Description: 'Use &&/|| instead of and/or.'
2603 StyleGuide: '#no-and-or-or'
2604 Enabled: true
2605 VersionAdded: '0.9'
2606 VersionChanged: '0.25'
2607 # Whether `and` and `or` are banned only in conditionals (conditionals)
2608 # or completely (always).
2609 EnforcedStyle: always
2610 SupportedStyles:
2611 - always
2612 - conditionals
2613
2614Style/ArrayJoin:
2615 Description: 'Use Array#join instead of Array#*.'
2616 StyleGuide: '#array-join'
2617 Enabled: true
2618 VersionAdded: '0.20'
2619 VersionChanged: '0.31'
2620
2621Style/AsciiComments:
2622 Description: 'Use only ascii symbols in comments.'
2623 StyleGuide: '#english-comments'
2624 Enabled: true
2625 VersionAdded: '0.9'
2626 VersionChanged: '0.52'
2627 AllowedChars: []
2628
2629Style/Attr:
2630 Description: 'Checks for uses of Module#attr.'
2631 StyleGuide: '#attr'
2632 Enabled: true
2633 VersionAdded: '0.9'
2634 VersionChanged: '0.12'
2635
2636Style/AutoResourceCleanup:
2637 Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
2638 Enabled: false
2639 VersionAdded: '0.30'
2640
2641Style/BarePercentLiterals:
2642 Description: 'Checks if usage of %() or %Q() matches configuration.'
2643 StyleGuide: '#percent-q-shorthand'
2644 Enabled: true
2645 VersionAdded: '0.25'
2646 EnforcedStyle: bare_percent
2647 SupportedStyles:
2648 - percent_q
2649 - bare_percent
2650
2651Style/BeginBlock:
2652 Description: 'Avoid the use of BEGIN blocks.'
2653 StyleGuide: '#no-BEGIN-blocks'
2654 Enabled: true
2655 VersionAdded: '0.9'
2656
2657Style/BlockComments:
2658 Description: 'Do not use block comments.'
2659 StyleGuide: '#no-block-comments'
2660 Enabled: true
2661 VersionAdded: '0.9'
2662 VersionChanged: '0.23'
2663
2664Style/BlockDelimiters:
2665 Description: >-
2666 Avoid using {...} for multi-line blocks (multiline chaining is
2667 always ugly).
2668 Prefer {...} over do...end for single-line blocks.
2669 StyleGuide: '#single-line-blocks'
2670 Enabled: true
2671 VersionAdded: '0.30'
2672 VersionChanged: '0.35'
2673 EnforcedStyle: line_count_based
2674 SupportedStyles:
2675 # The `line_count_based` style enforces braces around single line blocks and
2676 # do..end around multi-line blocks.
2677 - line_count_based
2678 # The `semantic` style enforces braces around functional blocks, where the
2679 # primary purpose of the block is to return a value and do..end for
2680 # multi-line procedural blocks, where the primary purpose of the block is
2681 # its side-effects. Single-line procedural blocks may only use do-end,
2682 # unless AllowBracesOnProceduralOneLiners has a truthy value (see below).
2683 #
2684 # This looks at the usage of a block's method to determine its type (e.g. is
2685 # the result of a `map` assigned to a variable or passed to another
2686 # method) but exceptions are permitted in the `ProceduralMethods`,
2687 # `FunctionalMethods` and `IgnoredMethods` sections below.
2688 - semantic
2689 # The `braces_for_chaining` style enforces braces around single line blocks
2690 # and do..end around multi-line blocks, except for multi-line blocks whose
2691 # return value is being chained with another method (in which case braces
2692 # are enforced).
2693 - braces_for_chaining
2694 # The `always_braces` style always enforces braces.
2695 - always_braces
2696 ProceduralMethods:
2697 # Methods that are known to be procedural in nature but look functional from
2698 # their usage, e.g.
2699 #
2700 # time = Benchmark.realtime do
2701 # foo.bar
2702 # end
2703 #
2704 # Here, the return value of the block is discarded but the return value of
2705 # `Benchmark.realtime` is used.
2706 - benchmark
2707 - bm
2708 - bmbm
2709 - create
2710 - each_with_object
2711 - measure
2712 - new
2713 - realtime
2714 - tap
2715 - with_object
2716 FunctionalMethods:
2717 # Methods that are known to be functional in nature but look procedural from
2718 # their usage, e.g.
2719 #
2720 # let(:foo) { Foo.new }
2721 #
2722 # Here, the return value of `Foo.new` is used to define a `foo` helper but
2723 # doesn't appear to be used from the return value of `let`.
2724 - let
2725 - let!
2726 - subject
2727 - watch
2728 IgnoredMethods:
2729 # Methods that can be either procedural or functional and cannot be
2730 # categorised from their usage alone, e.g.
2731 #
2732 # foo = lambda do |x|
2733 # puts "Hello, #{x}"
2734 # end
2735 #
2736 # foo = lambda do |x|
2737 # x * 100
2738 # end
2739 #
2740 # Here, it is impossible to tell from the return value of `lambda` whether
2741 # the inner block's return value is significant.
2742 - lambda
2743 - proc
2744 - it
2745 # The AllowBracesOnProceduralOneLiners option is ignored unless the
2746 # EnforcedStyle is set to `semantic`. If so:
2747 #
2748 # If AllowBracesOnProceduralOneLiners is unspecified, or set to any
2749 # falsey value, then semantic purity is maintained, so one-line
2750 # procedural blocks must use do-end, not braces.
2751 #
2752 # # bad
2753 # collection.each { |element| puts element }
2754 #
2755 # # good
2756 # collection.each do |element| puts element end
2757 #
2758 # If AllowBracesOnProceduralOneLiners is set to any truthy value,
2759 # then one-line procedural blocks may use either style.
2760 #
2761 # # good
2762 # collection.each { |element| puts element }
2763 #
2764 # # also good
2765 # collection.each do |element| puts element end
2766 AllowBracesOnProceduralOneLiners: false
2767
2768Style/BracesAroundHashParameters:
2769 Description: 'Enforce braces style around hash parameters.'
2770 Enabled: true
2771 VersionAdded: '0.14.1'
2772 VersionChanged: '0.28'
2773 EnforcedStyle: no_braces
2774 SupportedStyles:
2775 # The `braces` style enforces braces around all method parameters that are
2776 # hashes.
2777 - braces
2778 # The `no_braces` style checks that the last parameter doesn't have braces
2779 # around it.
2780 - no_braces
2781 # The `context_dependent` style checks that the last parameter doesn't have
2782 # braces around it, but requires braces if the second to last parameter is
2783 # also a hash literal.
2784 - context_dependent
2785
2786Style/CaseEquality:
2787 Description: 'Avoid explicit use of the case equality operator(===).'
2788 StyleGuide: '#no-case-equality'
2789 Enabled: true
2790 VersionAdded: '0.9'
2791
2792Style/CharacterLiteral:
2793 Description: 'Checks for uses of character literals.'
2794 StyleGuide: '#no-character-literals'
2795 Enabled: true
2796 VersionAdded: '0.9'
2797
2798Style/ClassAndModuleChildren:
2799 Description: 'Checks style of children classes and modules.'
2800 StyleGuide: '#namespace-definition'
2801 # Moving from compact to nested children requires knowledge of whether the
2802 # outer parent is a module or a class. Moving from nested to compact requires
2803 # verification that the outer parent is defined elsewhere. Rubocop does not
2804 # have the knowledge to perform either operation safely and thus requires
2805 # manual oversight.
2806 SafeAutoCorrect: false
2807 AutoCorrect: false
2808 Enabled: true
2809 VersionAdded: '0.19'
2810 #
2811 # Basically there are two different styles:
2812 #
2813 # `nested` - have each child on a separate line
2814 # class Foo
2815 # class Bar
2816 # end
2817 # end
2818 #
2819 # `compact` - combine definitions as much as possible
2820 # class Foo::Bar
2821 # end
2822 #
2823 # The compact style is only forced, for classes or modules with one child.
2824 EnforcedStyle: nested
2825 SupportedStyles:
2826 - nested
2827 - compact
2828
2829Style/ClassCheck:
2830 Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.'
2831 Enabled: true
2832 VersionAdded: '0.24'
2833 EnforcedStyle: is_a?
2834 SupportedStyles:
2835 - is_a?
2836 - kind_of?
2837
2838Style/ClassMethods:
2839 Description: 'Use self when defining module/class methods.'
2840 StyleGuide: '#def-self-class-methods'
2841 Enabled: true
2842 VersionAdded: '0.9'
2843 VersionChanged: '0.20'
2844
2845Style/ClassVars:
2846 Description: 'Avoid the use of class variables.'
2847 StyleGuide: '#no-class-vars'
2848 Enabled: true
2849 VersionAdded: '0.13'
2850
2851# Align with the style guide.
2852Style/CollectionMethods:
2853 Description: 'Preferred collection methods.'
2854 StyleGuide: '#map-find-select-reduce-size'
2855 Enabled: false
2856 VersionAdded: '0.9'
2857 VersionChanged: '0.27'
2858 Safe: false
2859 # Mapping from undesired method to desired method
2860 # e.g. to use `detect` over `find`:
2861 #
2862 # Style/CollectionMethods:
2863 # PreferredMethods:
2864 # find: detect
2865 PreferredMethods:
2866 collect: 'map'
2867 collect!: 'map!'
2868 inject: 'reduce'
2869 detect: 'find'
2870 find_all: 'select'
2871
2872Style/ColonMethodCall:
2873 Description: 'Do not use :: for method call.'
2874 StyleGuide: '#double-colons'
2875 Enabled: true
2876 VersionAdded: '0.9'
2877
2878Style/ColonMethodDefinition:
2879 Description: 'Do not use :: for defining class methods.'
2880 StyleGuide: '#colon-method-definition'
2881 Enabled: true
2882 VersionAdded: '0.52'
2883
2884Style/CommandLiteral:
2885 Description: 'Use `` or %x around command literals.'
2886 StyleGuide: '#percent-x'
2887 Enabled: true
2888 VersionAdded: '0.30'
2889 EnforcedStyle: backticks
2890 # backticks: Always use backticks.
2891 # percent_x: Always use `%x`.
2892 # mixed: Use backticks on single-line commands, and `%x` on multi-line commands.
2893 SupportedStyles:
2894 - backticks
2895 - percent_x
2896 - mixed
2897 # If `false`, the cop will always recommend using `%x` if one or more backticks
2898 # are found in the command string.
2899 AllowInnerBackticks: false
2900
2901# Checks formatting of special comments
2902Style/CommentAnnotation:
2903 Description: >-
2904 Checks formatting of special comments
2905 (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
2906 StyleGuide: '#annotate-keywords'
2907 Enabled: true
2908 VersionAdded: '0.10'
2909 VersionChanged: '0.31'
2910 Keywords:
2911 - TODO
2912 - FIXME
2913 - OPTIMIZE
2914 - HACK
2915 - REVIEW
2916
2917Style/CommentedKeyword:
2918 Description: 'Do not place comments on the same line as certain keywords.'
2919 Enabled: true
2920 VersionAdded: '0.51'
2921
2922Style/ConditionalAssignment:
2923 Description: >-
2924 Use the return value of `if` and `case` statements for
2925 assignment to a variable and variable comparison instead
2926 of assigning that variable inside of each branch.
2927 Enabled: true
2928 VersionAdded: '0.36'
2929 VersionChanged: '0.47'
2930 EnforcedStyle: assign_to_condition
2931 SupportedStyles:
2932 - assign_to_condition
2933 - assign_inside_condition
2934 # When configured to `assign_to_condition`, `SingleLineConditionsOnly`
2935 # will only register an offense when all branches of a condition are
2936 # a single line.
2937 # When configured to `assign_inside_condition`, `SingleLineConditionsOnly`
2938 # will only register an offense for assignment to a condition that has
2939 # at least one multiline branch.
2940 SingleLineConditionsOnly: true
2941 IncludeTernaryExpressions: true
2942
2943Style/ConstantVisibility:
2944 Description: >-
2945 Check that class- and module constants have
2946 visibility declarations.
2947 Enabled: false
2948 VersionAdded: '0.66'
2949
2950# Checks that you have put a copyright in a comment before any code.
2951#
2952# You can override the default Notice in your .rubocop.yml file.
2953#
2954# In order to use autocorrect, you must supply a value for the
2955# `AutocorrectNotice` key that matches the regexp Notice. A blank
2956# `AutocorrectNotice` will cause an error during autocorrect.
2957#
2958# Autocorrect will add a copyright notice in a comment at the top
2959# of the file immediately after any shebang or encoding comments.
2960#
2961# Example rubocop.yml:
2962#
2963# Style/Copyright:
2964# Enabled: true
2965# Notice: 'Copyright (\(c\) )?2015 Yahoo! Inc'
2966# AutocorrectNotice: '# Copyright (c) 2015 Yahoo! Inc.'
2967#
2968Style/Copyright:
2969 Description: 'Include a copyright notice in each file before any code.'
2970 Enabled: false
2971 VersionAdded: '0.30'
2972 Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
2973 AutocorrectNotice: ''
2974
2975Style/DateTime:
2976 Description: 'Use Time over DateTime.'
2977 StyleGuide: '#date--time'
2978 Enabled: false
2979 VersionAdded: '0.51'
2980 VersionChanged: '0.59'
2981 AllowCoercion: false
2982
2983Style/DefWithParentheses:
2984 Description: 'Use def with parentheses when there are arguments.'
2985 StyleGuide: '#method-parens'
2986 Enabled: true
2987 VersionAdded: '0.9'
2988 VersionChanged: '0.12'
2989
2990Style/Dir:
2991 Description: >-
2992 Use the `__dir__` method to retrieve the canonicalized
2993 absolute path to the current file.
2994 Enabled: true
2995 VersionAdded: '0.50'
2996
2997Style/Documentation:
2998 Description: 'Document classes and non-namespace modules.'
2999 Enabled: true
3000 VersionAdded: '0.9'
3001 Exclude:
3002 - 'spec/**/*'
3003 - 'test/**/*'
3004
3005Style/DocumentationMethod:
3006 Description: 'Checks for missing documentation comment for public methods.'
3007 Enabled: false
3008 VersionAdded: '0.43'
3009 Exclude:
3010 - 'spec/**/*'
3011 - 'test/**/*'
3012 RequireForNonPublicMethods: false
3013
3014Style/DoubleNegation:
3015 Description: 'Checks for uses of double negation (!!).'
3016 StyleGuide: '#no-bang-bang'
3017 Enabled: true
3018 VersionAdded: '0.19'
3019
3020Style/EachForSimpleLoop:
3021 Description: >-
3022 Use `Integer#times` for a simple loop which iterates a fixed
3023 number of times.
3024 Enabled: true
3025 VersionAdded: '0.41'
3026
3027Style/EachWithObject:
3028 Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
3029 Enabled: true
3030 VersionAdded: '0.22'
3031 VersionChanged: '0.42'
3032
3033Style/EmptyBlockParameter:
3034 Description: 'Omit pipes for empty block parameters.'
3035 Enabled: true
3036 VersionAdded: '0.52'
3037
3038Style/EmptyCaseCondition:
3039 Description: 'Avoid empty condition in case statements.'
3040 Enabled: true
3041 VersionAdded: '0.40'
3042
3043Style/EmptyElse:
3044 Description: 'Avoid empty else-clauses.'
3045 Enabled: true
3046 VersionAdded: '0.28'
3047 VersionChanged: '0.32'
3048 EnforcedStyle: both
3049 # empty - warn only on empty `else`
3050 # nil - warn on `else` with nil in it
3051 # both - warn on empty `else` and `else` with `nil` in it
3052 SupportedStyles:
3053 - empty
3054 - nil
3055 - both
3056
3057Style/EmptyLambdaParameter:
3058 Description: 'Omit parens for empty lambda parameters.'
3059 Enabled: true
3060 VersionAdded: '0.52'
3061
3062Style/EmptyLiteral:
3063 Description: 'Prefer literals to Array.new/Hash.new/String.new.'
3064 StyleGuide: '#literal-array-hash'
3065 Enabled: true
3066 VersionAdded: '0.9'
3067 VersionChanged: '0.12'
3068
3069Style/EmptyMethod:
3070 Description: 'Checks the formatting of empty method definitions.'
3071 StyleGuide: '#no-single-line-methods'
3072 Enabled: true
3073 VersionAdded: '0.46'
3074 EnforcedStyle: compact
3075 SupportedStyles:
3076 - compact
3077 - expanded
3078
3079Style/Encoding:
3080 Description: 'Use UTF-8 as the source file encoding.'
3081 StyleGuide: '#utf-8'
3082 Enabled: true
3083 VersionAdded: '0.9'
3084 VersionChanged: '0.50'
3085
3086Style/EndBlock:
3087 Description: 'Avoid the use of END blocks.'
3088 StyleGuide: '#no-END-blocks'
3089 Enabled: true
3090 VersionAdded: '0.9'
3091
3092Style/EvalWithLocation:
3093 Description: 'Pass `__FILE__` and `__LINE__` to `eval` method, as they are used by backtraces.'
3094 Enabled: true
3095 VersionAdded: '0.52'
3096
3097Style/EvenOdd:
3098 Description: 'Favor the use of Integer#even? && Integer#odd?'
3099 StyleGuide: '#predicate-methods'
3100 Enabled: true
3101 VersionAdded: '0.12'
3102 VersionChanged: '0.29'
3103
3104Style/ExpandPathArguments:
3105 Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
3106 Enabled: true
3107 VersionAdded: '0.53'
3108
3109Style/For:
3110 Description: 'Checks use of for or each in multiline loops.'
3111 StyleGuide: '#no-for-loops'
3112 Enabled: true
3113 VersionAdded: '0.13'
3114 VersionChanged: '0.59'
3115 EnforcedStyle: each
3116 SupportedStyles:
3117 - each
3118 - for
3119
3120Style/FormatString:
3121 Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
3122 StyleGuide: '#sprintf'
3123 Enabled: true
3124 VersionAdded: '0.19'
3125 VersionChanged: '0.49'
3126 EnforcedStyle: format
3127 SupportedStyles:
3128 - format
3129 - sprintf
3130 - percent
3131
3132Style/FormatStringToken:
3133 Description: 'Use a consistent style for format string tokens.'
3134 Enabled: true
3135 EnforcedStyle: annotated
3136 SupportedStyles:
3137 # Prefer tokens which contain a sprintf like type annotation like
3138 # `%<name>s`, `%<age>d`, `%<score>f`
3139 - annotated
3140 # Prefer simple looking "template" style tokens like `%{name}`, `%{age}`
3141 - template
3142 - unannotated
3143 VersionAdded: '0.49'
3144 VersionChanged: '0.52'
3145
3146Style/FrozenStringLiteralComment:
3147 Description: >-
3148 Add the frozen_string_literal comment to the top of files
3149 to help transition to frozen string literals by default.
3150 Enabled: true
3151 VersionAdded: '0.36'
3152 VersionChanged: '0.69'
3153 EnforcedStyle: never
3154 SupportedStyles:
3155 # `always` will always add the frozen string literal comment to a file
3156 # regardless of the Ruby version or if `freeze` or `<<` are called on a
3157 # string literal. If you run code against multiple versions of Ruby, it is
3158 # possible that this will create errors in Ruby 2.3.0+.
3159 - always
3160 # `never` will enforce that the frozen string literal comment does not
3161 # exist in a file.
3162 - never
3163
3164Style/GlobalVars:
3165 Description: 'Do not introduce global variables.'
3166 StyleGuide: '#instance-vars'
3167 Reference: 'https://www.zenspider.com/ruby/quickref.html'
3168 Enabled: true
3169 VersionAdded: '0.13'
3170 # Built-in global variables are allowed by default.
3171 AllowedVariables: []
3172
3173Style/GuardClause:
3174 Description: 'Check for conditionals that can be replaced with guard clauses'
3175 StyleGuide: '#no-nested-conditionals'
3176 Enabled: true
3177 VersionAdded: '0.20'
3178 VersionChanged: '0.22'
3179 # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
3180 # needs to have to trigger this cop
3181 MinBodyLength: 1
3182
3183Style/HashSyntax:
3184 Description: >-
3185 Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
3186 { :a => 1, :b => 2 }.
3187 StyleGuide: '#hash-literals'
3188 Enabled: true
3189 VersionAdded: '0.9'
3190 VersionChanged: '0.43'
3191 EnforcedStyle: ruby19
3192 SupportedStyles:
3193 # checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys
3194 - ruby19
3195 # checks for hash rocket syntax for all hashes
3196 - hash_rockets
3197 # forbids mixed key syntaxes (e.g. {a: 1, :b => 2})
3198 - no_mixed_keys
3199 # enforces both ruby19 and no_mixed_keys styles
3200 - ruby19_no_mixed_keys
3201 # Force hashes that have a symbol value to use hash rockets
3202 UseHashRocketsWithSymbolValues: false
3203 # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
3204 PreferHashRocketsForNonAlnumEndingSymbols: false
3205
3206Style/IdenticalConditionalBranches:
3207 Description: >-
3208 Checks that conditional statements do not have an identical
3209 line at the end of each branch, which can validly be moved
3210 out of the conditional.
3211 Enabled: true
3212 VersionAdded: '0.36'
3213
3214Style/IfInsideElse:
3215 Description: 'Finds if nodes inside else, which can be converted to elsif.'
3216 Enabled: true
3217 VersionAdded: '0.36'
3218
3219Style/IfUnlessModifier:
3220 Description: >-
3221 Favor modifier if/unless usage when you have a
3222 single-line body.
3223 StyleGuide: '#if-as-a-modifier'
3224 Enabled: true
3225 VersionAdded: '0.9'
3226 VersionChanged: '0.30'
3227
3228Style/IfUnlessModifierOfIfUnless:
3229 Description: >-
3230 Avoid modifier if/unless usage on conditionals.
3231 Enabled: true
3232 VersionAdded: '0.39'
3233
3234Style/IfWithSemicolon:
3235 Description: 'Do not use if x; .... Use the ternary operator instead.'
3236 StyleGuide: '#no-semicolon-ifs'
3237 Enabled: true
3238 VersionAdded: '0.9'
3239
3240Style/ImplicitRuntimeError:
3241 Description: >-
3242 Use `raise` or `fail` with an explicit exception class and
3243 message, rather than just a message.
3244 Enabled: false
3245 VersionAdded: '0.41'
3246
3247Style/InfiniteLoop:
3248 Description: 'Use Kernel#loop for infinite loops.'
3249 StyleGuide: '#infinite-loop'
3250 Enabled: true
3251 VersionAdded: '0.26'
3252 VersionChanged: '0.61'
3253 SafeAutoCorrect: true
3254
3255Style/InlineComment:
3256 Description: 'Avoid trailing inline comments.'
3257 Enabled: false
3258 VersionAdded: '0.23'
3259
3260Style/InverseMethods:
3261 Description: >-
3262 Use the inverse method instead of `!.method`
3263 if an inverse method is defined.
3264 Enabled: true
3265 Safe: false
3266 VersionAdded: '0.48'
3267 # `InverseMethods` are methods that can be inverted by a not (`not` or `!`)
3268 # The relationship of inverse methods only needs to be defined in one direction.
3269 # Keys and values both need to be defined as symbols.
3270 InverseMethods:
3271 :any?: :none?
3272 :even?: :odd?
3273 :==: :!=
3274 :=~: :!~
3275 :<: :>=
3276 :>: :<=
3277 # `ActiveSupport` defines some common inverse methods. They are listed below,
3278 # and not enabled by default.
3279 #:present?: :blank?,
3280 #:include?: :exclude?
3281 # `InverseBlocks` are methods that are inverted by inverting the return
3282 # of the block that is passed to the method
3283 InverseBlocks:
3284 :select: :reject
3285 :select!: :reject!
3286
3287Style/IpAddresses:
3288 Description: "Don't include literal IP addresses in code."
3289 Enabled: false
3290 VersionAdded: '0.58'
3291 # Allow strings to be whitelisted
3292 Whitelist:
3293 - "::"
3294 # :: is a valid IPv6 address, but could potentially be legitimately in code
3295
3296Style/Lambda:
3297 Description: 'Use the new lambda literal syntax for single-line blocks.'
3298 StyleGuide: '#lambda-multi-line'
3299 Enabled: true
3300 VersionAdded: '0.9'
3301 VersionChanged: '0.40'
3302 EnforcedStyle: line_count_dependent
3303 SupportedStyles:
3304 - line_count_dependent
3305 - lambda
3306 - literal
3307
3308Style/LambdaCall:
3309 Description: 'Use lambda.call(...) instead of lambda.(...).'
3310 StyleGuide: '#proc-call'
3311 Enabled: true
3312 VersionAdded: '0.13.1'
3313 VersionChanged: '0.14'
3314 EnforcedStyle: call
3315 SupportedStyles:
3316 - call
3317 - braces
3318
3319Style/LineEndConcatenation:
3320 Description: >-
3321 Use \ instead of + or << to concatenate two string literals at
3322 line end.
3323 Enabled: true
3324 SafeAutoCorrect: false
3325 VersionAdded: '0.18'
3326 VersionChanged: '0.64'
3327
3328Style/MethodCallWithArgsParentheses:
3329 Description: 'Use parentheses for method calls with arguments.'
3330 StyleGuide: '#method-invocation-parens'
3331 Enabled: false
3332 VersionAdded: '0.47'
3333 VersionChanged: '0.61'
3334 IgnoreMacros: true
3335 IgnoredMethods: []
3336 IncludedMacros: []
3337 AllowParenthesesInMultilineCall: false
3338 AllowParenthesesInChaining: false
3339 AllowParenthesesInCamelCaseMethod: false
3340 EnforcedStyle: require_parentheses
3341 SupportedStyles:
3342 - require_parentheses
3343 - omit_parentheses
3344
3345Style/MethodCallWithoutArgsParentheses:
3346 Description: 'Do not use parentheses for method calls with no arguments.'
3347 StyleGuide: '#method-invocation-parens'
3348 Enabled: true
3349 IgnoredMethods: []
3350 VersionAdded: '0.47'
3351 VersionChanged: '0.55'
3352
3353Style/MethodCalledOnDoEndBlock:
3354 Description: 'Avoid chaining a method call on a do...end block.'
3355 StyleGuide: '#single-line-blocks'
3356 Enabled: false
3357 VersionAdded: '0.14'
3358
3359Style/MethodDefParentheses:
3360 Description: >-
3361 Checks if the method definitions have or don't have
3362 parentheses.
3363 StyleGuide: '#method-parens'
3364 Enabled: true
3365 VersionAdded: '0.16'
3366 VersionChanged: '0.35'
3367 EnforcedStyle: require_no_parentheses
3368 SupportedStyles:
3369 - require_parentheses
3370 - require_no_parentheses
3371 - require_no_parentheses_except_multiline
3372
3373Style/MethodMissingSuper:
3374 Description: Checks for `method_missing` to call `super`.
3375 StyleGuide: '#no-method-missing'
3376 Enabled: true
3377 VersionAdded: '0.56'
3378
3379Style/MinMax:
3380 Description: >-
3381 Use `Enumerable#minmax` instead of `Enumerable#min`
3382 and `Enumerable#max` in conjunction.'
3383 Enabled: true
3384 VersionAdded: '0.50'
3385
3386Style/MissingElse:
3387 Description: >-
3388 Require if/case expressions to have an else branches.
3389 If enabled, it is recommended that
3390 Style/UnlessElse and Style/EmptyElse be enabled.
3391 This will conflict with Style/EmptyElse if
3392 Style/EmptyElse is configured to style "both"
3393 Enabled: false
3394 VersionAdded: '0.30'
3395 VersionChanged: '0.38'
3396 EnforcedStyle: both
3397 SupportedStyles:
3398 # if - warn when an if expression is missing an else branch
3399 # case - warn when a case expression is missing an else branch
3400 # both - warn when an if or case expression is missing an else branch
3401 - if
3402 - case
3403 - both
3404
3405Style/MissingRespondToMissing:
3406 Description: >-
3407 Checks if `method_missing` is implemented
3408 without implementing `respond_to_missing`.
3409 StyleGuide: '#no-method-missing'
3410 Enabled: true
3411 VersionAdded: '0.56'
3412
3413Style/MixinGrouping:
3414 Description: 'Checks for grouping of mixins in `class` and `module` bodies.'
3415 StyleGuide: '#mixin-grouping'
3416 Enabled: true
3417 VersionAdded: '0.48'
3418 VersionChanged: '0.49'
3419 EnforcedStyle: separated
3420 SupportedStyles:
3421 # separated: each mixed in module goes in a separate statement.
3422 # grouped: mixed in modules are grouped into a single statement.
3423 - separated
3424 - grouped
3425
3426Style/MixinUsage:
3427 Description: 'Checks that `include`, `extend` and `prepend` exists at the top level.'
3428 Enabled: true
3429 VersionAdded: '0.51'
3430
3431Style/ModuleFunction:
3432 Description: 'Checks for usage of `extend self` in modules.'
3433 StyleGuide: '#module-function'
3434 Enabled: true
3435 VersionAdded: '0.11'
3436 VersionChanged: '0.65'
3437 EnforcedStyle: module_function
3438 SupportedStyles:
3439 - module_function
3440 - extend_self
3441 Autocorrect: false
3442 SafeAutoCorrect: false
3443
3444Style/MultilineBlockChain:
3445 Description: 'Avoid multi-line chains of blocks.'
3446 StyleGuide: '#single-line-blocks'
3447 Enabled: true
3448 VersionAdded: '0.13'
3449
3450Style/MultilineIfModifier:
3451 Description: 'Only use if/unless modifiers on single line statements.'
3452 StyleGuide: '#no-multiline-if-modifiers'
3453 Enabled: true
3454 VersionAdded: '0.45'
3455
3456Style/MultilineIfThen:
3457 Description: 'Do not use then for multi-line if/unless.'
3458 StyleGuide: '#no-then'
3459 Enabled: true
3460 VersionAdded: '0.9'
3461 VersionChanged: '0.26'
3462
3463Style/MultilineMemoization:
3464 Description: 'Wrap multiline memoizations in a `begin` and `end` block.'
3465 Enabled: true
3466 VersionAdded: '0.44'
3467 VersionChanged: '0.48'
3468 EnforcedStyle: keyword
3469 SupportedStyles:
3470 - keyword
3471 - braces
3472
3473Style/MultilineMethodSignature:
3474 Description: 'Avoid multi-line method signatures.'
3475 Enabled: false
3476 VersionAdded: '0.59'
3477
3478Style/MultilineTernaryOperator:
3479 Description: >-
3480 Avoid multi-line ?: (the ternary operator);
3481 use if/unless instead.
3482 StyleGuide: '#no-multiline-ternary'
3483 Enabled: true
3484 VersionAdded: '0.9'
3485
3486Style/MultipleComparison:
3487 Description: >-
3488 Avoid comparing a variable with multiple items in a conditional,
3489 use Array#include? instead.
3490 Enabled: false
3491 VersionAdded: '0.49'
3492
3493Style/MutableConstant:
3494 Description: 'Do not assign mutable objects to constants.'
3495 Enabled: true
3496 VersionAdded: '0.34'
3497 VersionChanged: '0.65'
3498 EnforcedStyle: literals
3499 SupportedStyles:
3500 # literals: freeze literals assigned to constants
3501 # strict: freeze all constants
3502 # Strict mode is considered an experimental feature. It has not been updated
3503 # with an exhaustive list of all methods that will produce frozen objects so
3504 # there is a decent chance of getting some false positives. Luckily, there is
3505 # no harm in freezing an already frozen object.
3506 - literals
3507 - strict
3508
3509Style/NegatedIf:
3510 Description: >-
3511 Favor unless over if for negative conditions
3512 (or control flow or).
3513 StyleGuide: '#unless-for-negatives'
3514 Enabled: true
3515 VersionAdded: '0.20'
3516 VersionChanged: '0.48'
3517 EnforcedStyle: both
3518 SupportedStyles:
3519 # both: prefix and postfix negated `if` should both use `unless`
3520 # prefix: only use `unless` for negated `if` statements positioned before the body of the statement
3521 # postfix: only use `unless` for negated `if` statements positioned after the body of the statement
3522 - both
3523 - prefix
3524 - postfix
3525
3526Style/NegatedUnless:
3527 Description: 'Favor if over unless for negative conditions.'
3528 StyleGuide: '#if-for-negatives'
3529 Enabled: true
3530 VersionAdded: '0.69'
3531 EnforcedStyle: both
3532 SupportedStyles:
3533 # both: prefix and postfix negated `unless` should both use `if`
3534 # prefix: only use `if` for negated `unless` statements positioned before the body of the statement
3535 # postfix: only use `if` for negated `unless` statements positioned after the body of the statement
3536 - both
3537 - prefix
3538 - postfix
3539
3540Style/NegatedWhile:
3541 Description: 'Favor until over while for negative conditions.'
3542 StyleGuide: '#until-for-negatives'
3543 Enabled: true
3544 VersionAdded: '0.20'
3545
3546Style/NestedModifier:
3547 Description: 'Avoid using nested modifiers.'
3548 StyleGuide: '#no-nested-modifiers'
3549 Enabled: true
3550 VersionAdded: '0.35'
3551
3552Style/NestedParenthesizedCalls:
3553 Description: >-
3554 Parenthesize method calls which are nested inside the
3555 argument list of another parenthesized method call.
3556 Enabled: true
3557 VersionAdded: '0.36'
3558 VersionChanged: '0.50'
3559 Whitelist:
3560 - be
3561 - be_a
3562 - be_an
3563 - be_between
3564 - be_falsey
3565 - be_kind_of
3566 - be_instance_of
3567 - be_truthy
3568 - be_within
3569 - eq
3570 - eql
3571 - end_with
3572 - include
3573 - match
3574 - raise_error
3575 - respond_to
3576 - start_with
3577
3578Style/NestedTernaryOperator:
3579 Description: 'Use one expression per branch in a ternary operator.'
3580 StyleGuide: '#no-nested-ternary'
3581 Enabled: true
3582 VersionAdded: '0.9'
3583
3584Style/Next:
3585 Description: 'Use `next` to skip iteration instead of a condition at the end.'
3586 StyleGuide: '#no-nested-conditionals'
3587 Enabled: true
3588 VersionAdded: '0.22'
3589 VersionChanged: '0.35'
3590 # With `always` all conditions at the end of an iteration needs to be
3591 # replaced by next - with `skip_modifier_ifs` the modifier if like this one
3592 # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
3593 EnforcedStyle: skip_modifier_ifs
3594 # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
3595 # needs to have to trigger this cop
3596 MinBodyLength: 3
3597 SupportedStyles:
3598 - skip_modifier_ifs
3599 - always
3600
3601Style/NilComparison:
3602 Description: 'Prefer x.nil? to x == nil.'
3603 StyleGuide: '#predicate-methods'
3604 Enabled: true
3605 VersionAdded: '0.12'
3606 VersionChanged: '0.59'
3607 EnforcedStyle: predicate
3608 SupportedStyles:
3609 - predicate
3610 - comparison
3611
3612Style/NonNilCheck:
3613 Description: 'Checks for redundant nil checks.'
3614 StyleGuide: '#no-non-nil-checks'
3615 Enabled: true
3616 VersionAdded: '0.20'
3617 VersionChanged: '0.22'
3618 # With `IncludeSemanticChanges` set to `true`, this cop reports offenses for
3619 # `!x.nil?` and autocorrects that and `x != nil` to solely `x`, which is
3620 # **usually** OK, but might change behavior.
3621 #
3622 # With `IncludeSemanticChanges` set to `false`, this cop does not report
3623 # offenses for `!x.nil?` and does no changes that might change behavior.
3624 IncludeSemanticChanges: false
3625
3626Style/Not:
3627 Description: 'Use ! instead of not.'
3628 StyleGuide: '#bang-not-not'
3629 Enabled: true
3630 VersionAdded: '0.9'
3631 VersionChanged: '0.20'
3632
3633Style/NumericLiteralPrefix:
3634 Description: 'Use smallcase prefixes for numeric literals.'
3635 StyleGuide: '#numeric-literal-prefixes'
3636 Enabled: true
3637 VersionAdded: '0.41'
3638 EnforcedOctalStyle: zero_with_o
3639 SupportedOctalStyles:
3640 - zero_with_o
3641 - zero_only
3642
3643
3644Style/NumericLiterals:
3645 Description: >-
3646 Add underscores to large numeric literals to improve their
3647 readability.
3648 StyleGuide: '#underscores-in-numerics'
3649 Enabled: true
3650 VersionAdded: '0.9'
3651 VersionChanged: '0.48'
3652 MinDigits: 5
3653 Strict: false
3654
3655Style/NumericPredicate:
3656 Description: >-
3657 Checks for the use of predicate- or comparison methods for
3658 numeric comparisons.
3659 StyleGuide: '#predicate-methods'
3660 Safe: false
3661 # This will change to a new method call which isn't guaranteed to be on the
3662 # object. Switching these methods has to be done with knowledge of the types
3663 # of the variables which rubocop doesn't have.
3664 SafeAutoCorrect: false
3665 AutoCorrect: false
3666 Enabled: true
3667 VersionAdded: '0.42'
3668 VersionChanged: '0.59'
3669 EnforcedStyle: predicate
3670 SupportedStyles:
3671 - predicate
3672 - comparison
3673 IgnoredMethods: []
3674 # Exclude RSpec specs because assertions like `expect(1).to be > 0` cause
3675 # false positives.
3676 Exclude:
3677 - 'spec/**/*'
3678
3679Style/OneLineConditional:
3680 Description: >-
3681 Favor the ternary operator(?:) over
3682 if/then/else/end constructs.
3683 StyleGuide: '#ternary-operator'
3684 Enabled: true
3685 VersionAdded: '0.9'
3686 VersionChanged: '0.38'
3687
3688Style/OptionHash:
3689 Description: "Don't use option hashes when you can use keyword arguments."
3690 Enabled: false
3691 VersionAdded: '0.33'
3692 VersionChanged: '0.34'
3693 # A list of parameter names that will be flagged by this cop.
3694 SuspiciousParamNames:
3695 - options
3696 - opts
3697 - args
3698 - params
3699 - parameters
3700
3701Style/OptionalArguments:
3702 Description: >-
3703 Checks for optional arguments that do not appear at the end
3704 of the argument list
3705 StyleGuide: '#optional-arguments'
3706 Enabled: true
3707 VersionAdded: '0.33'
3708
3709Style/OrAssignment:
3710 Description: 'Recommend usage of double pipe equals (||=) where applicable.'
3711 StyleGuide: '#double-pipe-for-uninit'
3712 Enabled: true
3713 VersionAdded: '0.50'
3714
3715Style/ParallelAssignment:
3716 Description: >-
3717 Check for simple usages of parallel assignment.
3718 It will only warn when the number of variables
3719 matches on both sides of the assignment.
3720 StyleGuide: '#parallel-assignment'
3721 Enabled: true
3722 VersionAdded: '0.32'
3723
3724Style/ParenthesesAroundCondition:
3725 Description: >-
3726 Don't use parentheses around the condition of an
3727 if/unless/while.
3728 StyleGuide: '#no-parens-around-condition'
3729 Enabled: true
3730 VersionAdded: '0.9'
3731 VersionChanged: '0.56'
3732 AllowSafeAssignment: true
3733 AllowInMultilineConditions: false
3734
3735Style/PercentLiteralDelimiters:
3736 Description: 'Use `%`-literal delimiters consistently'
3737 StyleGuide: '#percent-literal-braces'
3738 Enabled: true
3739 VersionAdded: '0.19'
3740 # Specify the default preferred delimiter for all types with the 'default' key
3741 # Override individual delimiters (even with default specified) by specifying
3742 # an individual key
3743 PreferredDelimiters:
3744 default: ()
3745 '%i': '[]'
3746 '%I': '[]'
3747 '%r': '{}'
3748 '%w': '[]'
3749 '%W': '[]'
3750 VersionChanged: '0.48.1'
3751
3752Style/PercentQLiterals:
3753 Description: 'Checks if uses of %Q/%q match the configured preference.'
3754 Enabled: true
3755 VersionAdded: '0.25'
3756 EnforcedStyle: lower_case_q
3757 SupportedStyles:
3758 - lower_case_q # Use `%q` when possible, `%Q` when necessary
3759 - upper_case_q # Always use `%Q`
3760
3761Style/PerlBackrefs:
3762 Description: 'Avoid Perl-style regex back references.'
3763 StyleGuide: '#no-perl-regexp-last-matchers'
3764 Enabled: true
3765 VersionAdded: '0.13'
3766
3767Style/PreferredHashMethods:
3768 Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
3769 StyleGuide: '#hash-key'
3770 Enabled: true
3771 Safe: false
3772 VersionAdded: '0.41'
3773 VersionChanged: '0.70'
3774 EnforcedStyle: short
3775 SupportedStyles:
3776 - short
3777 - verbose
3778
3779Style/Proc:
3780 Description: 'Use proc instead of Proc.new.'
3781 StyleGuide: '#proc'
3782 Enabled: true
3783 VersionAdded: '0.9'
3784 VersionChanged: '0.18'
3785
3786Style/RaiseArgs:
3787 Description: 'Checks the arguments passed to raise/fail.'
3788 StyleGuide: '#exception-class-messages'
3789 Enabled: true
3790 VersionAdded: '0.14'
3791 VersionChanged: '0.40'
3792 EnforcedStyle: exploded
3793 SupportedStyles:
3794 - compact # raise Exception.new(msg)
3795 - exploded # raise Exception, msg
3796
3797Style/RandomWithOffset:
3798 Description: >-
3799 Prefer to use ranges when generating random numbers instead of
3800 integers with offsets.
3801 StyleGuide: '#random-numbers'
3802 Enabled: true
3803 VersionAdded: '0.52'
3804
3805Style/RedundantBegin:
3806 Description: "Don't use begin blocks when they are not needed."
3807 StyleGuide: '#begin-implicit'
3808 Enabled: true
3809 VersionAdded: '0.10'
3810 VersionChanged: '0.21'
3811
3812Style/RedundantConditional:
3813 Description: "Don't return true/false from a conditional."
3814 Enabled: true
3815 VersionAdded: '0.50'
3816
3817Style/RedundantException:
3818 Description: "Checks for an obsolete RuntimeException argument in raise/fail."
3819 StyleGuide: '#no-explicit-runtimeerror'
3820 Enabled: true
3821 VersionAdded: '0.14'
3822 VersionChanged: '0.29'
3823
3824Style/RedundantFreeze:
3825 Description: "Checks usages of Object#freeze on immutable objects."
3826 Enabled: true
3827 VersionAdded: '0.34'
3828 VersionChanged: '0.66'
3829
3830Style/RedundantParentheses:
3831 Description: "Checks for parentheses that seem not to serve any purpose."
3832 Enabled: true
3833 VersionAdded: '0.36'
3834
3835Style/RedundantReturn:
3836 Description: "Don't use return where it's not required."
3837 StyleGuide: '#no-explicit-return'
3838 Enabled: true
3839 VersionAdded: '0.10'
3840 VersionChanged: '0.14'
3841 # When `true` allows code like `return x, y`.
3842 AllowMultipleReturnValues: false
3843
3844Style/RedundantSelf:
3845 Description: "Don't use self where it's not needed."
3846 StyleGuide: '#no-self-unless-required'
3847 Enabled: true
3848 VersionAdded: '0.10'
3849 VersionChanged: '0.13'
3850
3851Style/RedundantSortBy:
3852 Description: 'Use `sort` instead of `sort_by { |x| x }`.'
3853 Enabled: true
3854 VersionAdded: '0.36'
3855
3856Style/RegexpLiteral:
3857 Description: 'Use / or %r around regular expressions.'
3858 StyleGuide: '#percent-r'
3859 Enabled: true
3860 VersionAdded: '0.9'
3861 VersionChanged: '0.30'
3862 EnforcedStyle: slashes
3863 # slashes: Always use slashes.
3864 # percent_r: Always use `%r`.
3865 # mixed: Use slashes on single-line regexes, and `%r` on multi-line regexes.
3866 SupportedStyles:
3867 - slashes
3868 - percent_r
3869 - mixed
3870 # If `false`, the cop will always recommend using `%r` if one or more slashes
3871 # are found in the regexp string.
3872 AllowInnerSlashes: false
3873
3874Style/RescueModifier:
3875 Description: 'Avoid using rescue in its modifier form.'
3876 StyleGuide: '#no-rescue-modifiers'
3877 Enabled: true
3878 VersionAdded: '0.9'
3879 VersionChanged: '0.34'
3880
3881Style/RescueStandardError:
3882 Description: 'Avoid rescuing without specifying an error class.'
3883 Enabled: true
3884 VersionAdded: '0.52'
3885 EnforcedStyle: explicit
3886 # implicit: Do not include the error class, `rescue`
3887 # explicit: Require an error class `rescue StandardError`
3888 SupportedStyles:
3889 - implicit
3890 - explicit
3891
3892Style/ReturnNil:
3893 Description: 'Use return instead of return nil.'
3894 Enabled: false
3895 EnforcedStyle: return
3896 SupportedStyles:
3897 - return
3898 - return_nil
3899 VersionAdded: '0.50'
3900
3901Style/SafeNavigation:
3902 Description: >-
3903 This cop transforms usages of a method call safeguarded by
3904 a check for the existence of the object to
3905 safe navigation (`&.`).
3906 Enabled: true
3907 VersionAdded: '0.43'
3908 VersionChanged: '0.56'
3909 # Safe navigation may cause a statement to start returning `nil` in addition
3910 # to whatever it used to return.
3911 ConvertCodeThatCanStartToReturnNil: false
3912 Whitelist:
3913 - present?
3914 - blank?
3915 - presence
3916 - try
3917 - try!
3918
3919Style/Sample:
3920 Description: >-
3921 Use `sample` instead of `shuffle.first`,
3922 `shuffle.last`, and `shuffle[Integer]`.
3923 Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
3924 Enabled: true
3925 VersionAdded: '0.30'
3926
3927Style/SelfAssignment:
3928 Description: >-
3929 Checks for places where self-assignment shorthand should have
3930 been used.
3931 StyleGuide: '#self-assignment'
3932 Enabled: true
3933 VersionAdded: '0.19'
3934 VersionChanged: '0.29'
3935
3936Style/Semicolon:
3937 Description: "Don't use semicolons to terminate expressions."
3938 StyleGuide: '#no-semicolon'
3939 Enabled: true
3940 VersionAdded: '0.9'
3941 VersionChanged: '0.19'
3942 # Allow `;` to separate several expressions on the same line.
3943 AllowAsExpressionSeparator: false
3944
3945Style/Send:
3946 Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
3947 StyleGuide: '#prefer-public-send'
3948 Enabled: false
3949 VersionAdded: '0.33'
3950
3951Style/SignalException:
3952 Description: 'Checks for proper usage of fail and raise.'
3953 StyleGuide: '#prefer-raise-over-fail'
3954 Enabled: true
3955 VersionAdded: '0.11'
3956 VersionChanged: '0.37'
3957 EnforcedStyle: only_raise
3958 SupportedStyles:
3959 - only_raise
3960 - only_fail
3961 - semantic
3962
3963Style/SingleLineBlockParams:
3964 Description: 'Enforces the names of some block params.'
3965 Enabled: false
3966 VersionAdded: '0.16'
3967 VersionChanged: '0.47'
3968 Methods:
3969 - reduce:
3970 - acc
3971 - elem
3972 - inject:
3973 - acc
3974 - elem
3975
3976Style/SingleLineMethods:
3977 Description: 'Avoid single-line methods.'
3978 StyleGuide: '#no-single-line-methods'
3979 Enabled: true
3980 VersionAdded: '0.9'
3981 VersionChanged: '0.19'
3982 AllowIfMethodIsEmpty: true
3983
3984Style/SpecialGlobalVars:
3985 Description: 'Avoid Perl-style global variables.'
3986 StyleGuide: '#no-cryptic-perlisms'
3987 Enabled: true
3988 VersionAdded: '0.13'
3989 VersionChanged: '0.36'
3990 SafeAutoCorrect: false
3991 EnforcedStyle: use_english_names
3992 SupportedStyles:
3993 - use_perl_names
3994 - use_english_names
3995
3996Style/StabbyLambdaParentheses:
3997 Description: 'Check for the usage of parentheses around stabby lambda arguments.'
3998 StyleGuide: '#stabby-lambda-with-args'
3999 Enabled: true
4000 VersionAdded: '0.35'
4001 EnforcedStyle: require_parentheses
4002 SupportedStyles:
4003 - require_parentheses
4004 - require_no_parentheses
4005
4006Style/StderrPuts:
4007 Description: 'Use `warn` instead of `$stderr.puts`.'
4008 StyleGuide: '#warn'
4009 Enabled: true
4010 VersionAdded: '0.51'
4011
4012Style/StringHashKeys:
4013 Description: 'Prefer symbols instead of strings as hash keys.'
4014 StyleGuide: '#symbols-as-keys'
4015 Enabled: false
4016 VersionAdded: '0.52'
4017
4018Style/StringLiterals:
4019 Description: 'Checks if uses of quotes match the configured preference.'
4020 StyleGuide: '#consistent-string-literals'
4021 Enabled: true
4022 VersionAdded: '0.9'
4023 VersionChanged: '0.36'
4024 EnforcedStyle: single_quotes
4025 SupportedStyles:
4026 - single_quotes
4027 - double_quotes
4028 # If `true`, strings which span multiple lines using `\` for continuation must
4029 # use the same type of quotes on each line.
4030 ConsistentQuotesInMultiline: false
4031
4032Style/StringLiteralsInInterpolation:
4033 Description: >-
4034 Checks if uses of quotes inside expressions in interpolated
4035 strings match the configured preference.
4036 Enabled: true
4037 VersionAdded: '0.27'
4038 EnforcedStyle: single_quotes
4039 SupportedStyles:
4040 - single_quotes
4041 - double_quotes
4042
4043Style/StringMethods:
4044 Description: 'Checks if configured preferred methods are used over non-preferred.'
4045 Enabled: false
4046 VersionAdded: '0.34'
4047 VersionChanged: '0.34.2'
4048 # Mapping from undesired method to desired_method
4049 # e.g. to use `to_sym` over `intern`:
4050 #
4051 # StringMethods:
4052 # PreferredMethods:
4053 # intern: to_sym
4054 PreferredMethods:
4055 intern: to_sym
4056
4057Style/Strip:
4058 Description: 'Use `strip` instead of `lstrip.rstrip`.'
4059 Enabled: true
4060 VersionAdded: '0.36'
4061
4062Style/StructInheritance:
4063 Description: 'Checks for inheritance from Struct.new.'
4064 StyleGuide: '#no-extend-struct-new'
4065 Enabled: true
4066 VersionAdded: '0.29'
4067
4068Style/SymbolArray:
4069 Description: 'Use %i or %I for arrays of symbols.'
4070 StyleGuide: '#percent-i'
4071 Enabled: true
4072 VersionAdded: '0.9'
4073 VersionChanged: '0.49'
4074 EnforcedStyle: percent
4075 MinSize: 2
4076 SupportedStyles:
4077 - percent
4078 - brackets
4079
4080Style/SymbolLiteral:
4081 Description: 'Use plain symbols instead of string symbols when possible.'
4082 Enabled: true
4083 VersionAdded: '0.30'
4084
4085Style/SymbolProc:
4086 Description: 'Use symbols as procs instead of blocks when possible.'
4087 Enabled: true
4088 SafeAutoCorrect: false
4089 VersionAdded: '0.26'
4090 VersionChanged: '0.64'
4091 # A list of method names to be ignored by the check.
4092 # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
4093 IgnoredMethods:
4094 - respond_to
4095 - define_method
4096
4097Style/TernaryParentheses:
4098 Description: 'Checks for use of parentheses around ternary conditions.'
4099 Enabled: true
4100 VersionAdded: '0.42'
4101 VersionChanged: '0.46'
4102 EnforcedStyle: require_no_parentheses
4103 SupportedStyles:
4104 - require_parentheses
4105 - require_no_parentheses
4106 - require_parentheses_when_complex
4107 AllowSafeAssignment: true
4108
4109Style/TrailingBodyOnClass:
4110 Description: 'Class body goes below class statement.'
4111 Enabled: true
4112 VersionAdded: '0.53'
4113
4114Style/TrailingBodyOnMethodDefinition:
4115 Description: 'Method body goes below definition.'
4116 Enabled: true
4117 VersionAdded: '0.52'
4118
4119Style/TrailingBodyOnModule:
4120 Description: 'Module body goes below module statement.'
4121 Enabled: true
4122 VersionAdded: '0.53'
4123
4124Style/TrailingCommaInArguments:
4125 Description: 'Checks for trailing comma in argument lists.'
4126 StyleGuide: '#no-trailing-params-comma'
4127 Enabled: true
4128 VersionAdded: '0.36'
4129 # If `comma`, the cop requires a comma after the last argument, but only for
4130 # parenthesized method calls where each argument is on its own line.
4131 # If `consistent_comma`, the cop requires a comma after the last argument,
4132 # for all parenthesized method calls with arguments.
4133 EnforcedStyleForMultiline: no_comma
4134 SupportedStylesForMultiline:
4135 - comma
4136 - consistent_comma
4137 - no_comma
4138
4139Style/TrailingCommaInArrayLiteral:
4140 Description: 'Checks for trailing comma in array literals.'
4141 StyleGuide: '#no-trailing-array-commas'
4142 Enabled: true
4143 VersionAdded: '0.53'
4144 # but only when each item is on its own line.
4145 # If `consistent_comma`, the cop requires a comma after the last item of all
4146 # non-empty array literals.
4147 EnforcedStyleForMultiline: no_comma
4148 SupportedStylesForMultiline:
4149 - comma
4150 - consistent_comma
4151 - no_comma
4152
4153Style/TrailingCommaInHashLiteral:
4154 Description: 'Checks for trailing comma in hash literals.'
4155 Enabled: true
4156 # If `comma`, the cop requires a comma after the last item in a hash,
4157 # but only when each item is on its own line.
4158 # If `consistent_comma`, the cop requires a comma after the last item of all
4159 # non-empty hash literals.
4160 EnforcedStyleForMultiline: no_comma
4161 SupportedStylesForMultiline:
4162 - comma
4163 - consistent_comma
4164 - no_comma
4165 VersionAdded: '0.53'
4166
4167Style/TrailingMethodEndStatement:
4168 Description: 'Checks for trailing end statement on line of method body.'
4169 Enabled: true
4170 VersionAdded: '0.52'
4171
4172Style/TrailingUnderscoreVariable:
4173 Description: >-
4174 Checks for the usage of unneeded trailing underscores at the
4175 end of parallel variable assignment.
4176 AllowNamedUnderscoreVariables: true
4177 Enabled: true
4178 VersionAdded: '0.31'
4179 VersionChanged: '0.35'
4180
4181# `TrivialAccessors` requires exact name matches and doesn't allow
4182# predicated methods by default.
4183Style/TrivialAccessors:
4184 Description: 'Prefer attr_* methods to trivial readers/writers.'
4185 StyleGuide: '#attr_family'
4186 Enabled: true
4187 VersionAdded: '0.9'
4188 VersionChanged: '0.38'
4189 # When set to `false` the cop will suggest the use of accessor methods
4190 # in situations like:
4191 #
4192 # def name
4193 # @other_name
4194 # end
4195 #
4196 # This way you can uncover "hidden" attributes in your code.
4197 ExactNameMatch: true
4198 AllowPredicates: true
4199 # Allows trivial writers that don't end in an equal sign. e.g.
4200 #
4201 # def on_exception(action)
4202 # @on_exception=action
4203 # end
4204 # on_exception :restart
4205 #
4206 # Commonly used in DSLs
4207 AllowDSLWriters: false
4208 IgnoreClassMethods: false
4209 Whitelist:
4210 - to_ary
4211 - to_a
4212 - to_c
4213 - to_enum
4214 - to_h
4215 - to_hash
4216 - to_i
4217 - to_int
4218 - to_io
4219 - to_open
4220 - to_path
4221 - to_proc
4222 - to_r
4223 - to_regexp
4224 - to_str
4225 - to_s
4226 - to_sym
4227
4228Style/UnlessElse:
4229 Description: >-
4230 Do not use unless with else. Rewrite these with the positive
4231 case first.
4232 StyleGuide: '#no-else-with-unless'
4233 Enabled: true
4234 VersionAdded: '0.9'
4235
4236Style/UnneededCapitalW:
4237 Description: 'Checks for %W when interpolation is not needed.'
4238 Enabled: true
4239 VersionAdded: '0.21'
4240 VersionChanged: '0.24'
4241
4242Style/UnneededCondition:
4243 Description: 'Checks for unnecessary conditional expressions.'
4244 Enabled: true
4245 VersionAdded: '0.57'
4246
4247Style/UnneededInterpolation:
4248 Description: 'Checks for strings that are just an interpolated expression.'
4249 Enabled: true
4250 VersionAdded: '0.36'
4251
4252Style/UnneededPercentQ:
4253 Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
4254 StyleGuide: '#percent-q'
4255 Enabled: true
4256 VersionAdded: '0.24'
4257
4258Style/UnneededSort:
4259 Description: >-
4260 Use `min` instead of `sort.first`,
4261 `max_by` instead of `sort_by...last`, etc.
4262 Enabled: true
4263 VersionAdded: '0.55'
4264
4265Style/UnpackFirst:
4266 Description: >-
4267 Checks for accessing the first element of `String#unpack`
4268 instead of using `unpack1`
4269 Enabled: true
4270 VersionAdded: '0.54'
4271
4272Style/VariableInterpolation:
4273 Description: >-
4274 Don't interpolate global, instance and class variables
4275 directly in strings.
4276 StyleGuide: '#curlies-interpolate'
4277 Enabled: true
4278 VersionAdded: '0.9'
4279 VersionChanged: '0.20'
4280
4281Style/WhenThen:
4282 Description: 'Use when x then ... for one-line cases.'
4283 StyleGuide: '#one-line-cases'
4284 Enabled: true
4285 VersionAdded: '0.9'
4286
4287Style/WhileUntilDo:
4288 Description: 'Checks for redundant do after while or until.'
4289 StyleGuide: '#no-multiline-while-do'
4290 Enabled: true
4291 VersionAdded: '0.9'
4292
4293Style/WhileUntilModifier:
4294 Description: >-
4295 Favor modifier while/until usage when you have a
4296 single-line body.
4297 StyleGuide: '#while-as-a-modifier'
4298 Enabled: true
4299 VersionAdded: '0.9'
4300 VersionChanged: '0.30'
4301
4302Style/WordArray:
4303 Description: 'Use %w or %W for arrays of words.'
4304 StyleGuide: '#percent-w'
4305 Enabled: true
4306 VersionAdded: '0.9'
4307 VersionChanged: '0.36'
4308 EnforcedStyle: percent
4309 SupportedStyles:
4310 # percent style: %w(word1 word2)
4311 - percent
4312 # bracket style: ['word1', 'word2']
4313 - brackets
4314 # The `MinSize` option causes the `WordArray` rule to be ignored for arrays
4315 # smaller than a certain size. The rule is only applied to arrays
4316 # whose element count is greater than or equal to `MinSize`.
4317 MinSize: 2
4318 # The regular expression `WordRegex` decides what is considered a word.
4319 WordRegex: !ruby/regexp '/\A[\p{Word}\n\t]+\z/'
4320
4321Style/YodaCondition:
4322 Description: 'Forbid or enforce yoda conditions.'
4323 Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
4324 Enabled: true
4325 EnforcedStyle: forbid_for_all_comparison_operators
4326 SupportedStyles:
4327 # check all comparison operators
4328 - forbid_for_all_comparison_operators
4329 # check only equality operators: `!=` and `==`
4330 - forbid_for_equality_operators_only
4331 # enforce yoda for all comparison operators
4332 - require_for_all_comparison_operators
4333 # enforce yoda only for equality operators: `!=` and `==`
4334 - require_for_equality_operators_only
4335 VersionAdded: '0.49'
4336 VersionChanged: '0.63'
4337
4338Style/ZeroLengthPredicate:
4339 Description: 'Use #empty? when testing for objects of length 0.'
4340 Enabled: true
4341 Safe: false
4342 VersionAdded: '0.37'
4343 VersionChanged: '0.39'