rubocop-rubomatic 1.0.0.pre.rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/config/style.yml ADDED
@@ -0,0 +1,2545 @@
1
+ Style/AccessModifierDeclarations:
2
+ Description: 'Checks style of how access modifiers are used.'
3
+ Enabled: true
4
+ VersionAdded: '0.57'
5
+ VersionChanged: '0.81'
6
+ EnforcedStyle: group
7
+ SupportedStyles:
8
+ - inline
9
+ - group
10
+ AllowModifiersOnSymbols: true
11
+ SafeAutoCorrect: false
12
+
13
+ Style/AccessorGrouping:
14
+ Description: 'Checks for grouping of accessors in `class` and `module` bodies.'
15
+ Enabled: true
16
+ VersionAdded: '0.87'
17
+ EnforcedStyle: separated
18
+ SupportedStyles:
19
+ # separated: each accessor goes in a separate statement.
20
+ # grouped: accessors are grouped into a single statement.
21
+ - separated
22
+ - grouped
23
+
24
+ Style/Alias:
25
+ Description: 'Use alias instead of alias_method.'
26
+ StyleGuide: '#alias-method-lexically'
27
+ Enabled: true
28
+ VersionAdded: '0.9'
29
+ VersionChanged: '0.36'
30
+ EnforcedStyle: prefer_alias
31
+ SupportedStyles:
32
+ - prefer_alias
33
+ - prefer_alias_method
34
+
35
+ Style/AndOr:
36
+ Description: 'Use &&/|| instead of and/or.'
37
+ StyleGuide: '#no-and-or-or'
38
+ Enabled: true
39
+ SafeAutoCorrect: false
40
+ VersionAdded: '0.9'
41
+ VersionChanged: '1.21'
42
+ # Whether `and` and `or` are banned only in conditionals (conditionals)
43
+ # or completely (always).
44
+ EnforcedStyle: conditionals
45
+ SupportedStyles:
46
+ - always
47
+ - conditionals
48
+
49
+ Style/ArgumentsForwarding:
50
+ Description: 'Use arguments forwarding.'
51
+ StyleGuide: '#arguments-forwarding'
52
+ Enabled: true
53
+ AllowOnlyRestArgument: true
54
+ VersionAdded: '1.1'
55
+
56
+ Style/ArrayCoercion:
57
+ Description: >-
58
+ Use Array() instead of explicit Array check or [*var], when dealing
59
+ with a variable you want to treat as an Array, but you're not certain it's an array.
60
+ StyleGuide: '#array-coercion'
61
+ Safe: false
62
+ Enabled: true
63
+ VersionAdded: '0.88'
64
+
65
+ <% if RuboCop::Version.document_version.to_f >= 1.40 %>
66
+ Style/ArrayIntersect:
67
+ Description: 'Use `array1.intersect?(array2)` instead of `(array1 & array2).any?`.'
68
+ Enabled: true
69
+ VersionAdded: '1.40'
70
+ <% end %>
71
+
72
+ Style/ArrayJoin:
73
+ Description: 'Use Array#join instead of Array#*.'
74
+ StyleGuide: '#array-join'
75
+ Enabled: true
76
+ VersionAdded: '0.20'
77
+ VersionChanged: '0.31'
78
+
79
+ Style/AsciiComments:
80
+ Description: 'Use only ascii symbols in comments.'
81
+ StyleGuide: '#english-comments'
82
+ Enabled: true
83
+ VersionAdded: '0.9'
84
+ VersionChanged: '1.21'
85
+ AllowedChars:
86
+ - ©
87
+
88
+ Style/Attr:
89
+ Description: 'Checks for uses of Module#attr.'
90
+ StyleGuide: '#attr'
91
+ Enabled: true
92
+ VersionAdded: '0.9'
93
+ VersionChanged: '0.12'
94
+
95
+ Style/AutoResourceCleanup:
96
+ Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
97
+ Enabled: true
98
+ VersionAdded: '0.30'
99
+
100
+ Style/BarePercentLiterals:
101
+ Description: 'Checks if usage of %() or %Q() matches configuration.'
102
+ StyleGuide: '#percent-q-shorthand'
103
+ Enabled: true
104
+ VersionAdded: '0.25'
105
+ EnforcedStyle: bare_percent
106
+ SupportedStyles:
107
+ - percent_q
108
+ - bare_percent
109
+
110
+ Style/BeginBlock:
111
+ Description: 'Avoid the use of BEGIN blocks.'
112
+ StyleGuide: '#no-BEGIN-blocks'
113
+ Enabled: true
114
+ VersionAdded: '0.9'
115
+
116
+ Style/BisectedAttrAccessor:
117
+ Description: >-
118
+ Checks for places where `attr_reader` and `attr_writer`
119
+ for the same method can be combined into single `attr_accessor`.
120
+ Enabled: true
121
+ VersionAdded: '0.87'
122
+
123
+ Style/BlockComments:
124
+ Description: 'Do not use block comments.'
125
+ StyleGuide: '#no-block-comments'
126
+ Enabled: true
127
+ VersionAdded: '0.9'
128
+ VersionChanged: '0.23'
129
+
130
+ Style/BlockDelimiters:
131
+ Description: >-
132
+ Avoid using {...} for multi-line blocks (multiline chaining is
133
+ always ugly).
134
+ Prefer {...} over do...end for single-line blocks.
135
+ StyleGuide: '#single-line-blocks'
136
+ Enabled: true
137
+ VersionAdded: '0.30'
138
+ VersionChanged: '0.35'
139
+ EnforcedStyle: line_count_based
140
+ SupportedStyles:
141
+ # The `line_count_based` style enforces braces around single line blocks and
142
+ # do..end around multi-line blocks.
143
+ - line_count_based
144
+ # The `semantic` style enforces braces around functional blocks, where the
145
+ # primary purpose of the block is to return a value and do..end for
146
+ # multi-line procedural blocks, where the primary purpose of the block is
147
+ # its side-effects. Single-line procedural blocks may only use do-end,
148
+ # unless AllowBracesOnProceduralOneLiners has a truthy value (see below).
149
+ #
150
+ # This looks at the usage of a block's method to determine its type (e.g. is
151
+ # the result of a `map` assigned to a variable or passed to another
152
+ # method) but exceptions are permitted in the `ProceduralMethods`,
153
+ # `FunctionalMethods` and `AllowedMethods` sections below.
154
+ - semantic
155
+ # The `braces_for_chaining` style enforces braces around single line blocks
156
+ # and do..end around multi-line blocks, except for multi-line blocks whose
157
+ # return value is being chained with another method (in which case braces
158
+ # are enforced).
159
+ - braces_for_chaining
160
+ # The `always_braces` style always enforces braces.
161
+ - always_braces
162
+ ProceduralMethods:
163
+ # Methods that are known to be procedural in nature but look functional from
164
+ # their usage, e.g.
165
+ #
166
+ # time = Benchmark.realtime do
167
+ # foo.bar
168
+ # end
169
+ #
170
+ # Here, the return value of the block is discarded but the return value of
171
+ # `Benchmark.realtime` is used.
172
+ - benchmark
173
+ - bm
174
+ - bmbm
175
+ - create
176
+ - each_with_object
177
+ - measure
178
+ - new
179
+ - realtime
180
+ - tap
181
+ - with_object
182
+ FunctionalMethods:
183
+ # Methods that are known to be functional in nature but look procedural from
184
+ # their usage, e.g.
185
+ #
186
+ # let(:foo) { Foo.new }
187
+ #
188
+ # Here, the return value of `Foo.new` is used to define a `foo` helper but
189
+ # doesn't appear to be used from the return value of `let`.
190
+ - let
191
+ - let!
192
+ - subject
193
+ - watch
194
+ AllowedMethods:
195
+ # Methods that can be either procedural or functional and cannot be
196
+ # categorised from their usage alone, e.g.
197
+ #
198
+ # foo = lambda do |x|
199
+ # puts "Hello, #{x}"
200
+ # end
201
+ #
202
+ # foo = lambda do |x|
203
+ # x * 100
204
+ # end
205
+ #
206
+ # Here, it is impossible to tell from the return value of `lambda` whether
207
+ # the inner block's return value is significant.
208
+ - lambda
209
+ - proc
210
+ - it
211
+ AllowedPatterns: [ ]
212
+ # The AllowBracesOnProceduralOneLiners option is ignored unless the
213
+ # EnforcedStyle is set to `semantic`. If so:
214
+ #
215
+ # If AllowBracesOnProceduralOneLiners is unspecified, or set to any
216
+ # falsey value, then semantic purity is maintained, so one-line
217
+ # procedural blocks must use do-end, not braces.
218
+ #
219
+ # # bad
220
+ # collection.each { |element| puts element }
221
+ #
222
+ # # good
223
+ # collection.each do |element| puts element end
224
+ #
225
+ # If AllowBracesOnProceduralOneLiners is set to any truthy value,
226
+ # then one-line procedural blocks may use either style.
227
+ #
228
+ # # good
229
+ # collection.each { |element| puts element }
230
+ #
231
+ # # also good
232
+ # collection.each do |element| puts element end
233
+ AllowBracesOnProceduralOneLiners: false
234
+ # The BracesRequiredMethods overrides all other configurations except
235
+ # IgnoredMethods. It can be used to enforce that all blocks for specific
236
+ # methods use braces. For example, you can use this to enforce Sorbet
237
+ # signatures use braces even when the rest of your codebase enforces
238
+ # the `line_count_based` style.
239
+ BracesRequiredMethods: [ ]
240
+
241
+ Style/CaseEquality:
242
+ Description: 'Avoid explicit use of the case equality operator(===).'
243
+ StyleGuide: '#no-case-equality'
244
+ Enabled: false
245
+ VersionAdded: '0.9'
246
+ VersionChanged: '0.89'
247
+ # If `AllowOnConstant` option is enabled, the cop will ignore violations when the receiver of
248
+ # the case equality operator is a constant.
249
+ #
250
+ # # bad
251
+ # /string/ === "string"
252
+ #
253
+ # # good
254
+ # String === "string"
255
+ AllowOnConstant: false
256
+ # If `AllowOnSelfClass` option is enabled, the cop will ignore violations when the receiver of
257
+ # the case equality operator is `self.class`.
258
+ #
259
+ # # bad
260
+ # some_class === object
261
+ #
262
+ # # good
263
+ # self.class === object
264
+ AllowOnSelfClass: false
265
+
266
+ Style/CaseLikeIf:
267
+ Description: 'Identifies places where `if-elsif` constructions can be replaced with `case-when`.'
268
+ StyleGuide: '#case-vs-if-else'
269
+ Enabled: true
270
+ Safe: false
271
+ VersionAdded: '0.88'
272
+
273
+ Style/CharacterLiteral:
274
+ Description: 'Checks for uses of character literals.'
275
+ StyleGuide: '#no-character-literals'
276
+ Enabled: true
277
+ VersionAdded: '0.9'
278
+
279
+ Style/ClassAndModuleChildren:
280
+ Description: 'Checks style of children classes and modules.'
281
+ StyleGuide: '#namespace-definition'
282
+ # Moving from compact to nested children requires knowledge of whether the
283
+ # outer parent is a module or a class. Moving from nested to compact requires
284
+ # verification that the outer parent is defined elsewhere. Rubocop does not
285
+ # have the knowledge to perform either operation safely and thus requires
286
+ # manual oversight.
287
+ SafeAutoCorrect: false
288
+ Enabled: true
289
+ VersionAdded: '0.19'
290
+ #
291
+ # Basically there are two different styles:
292
+ #
293
+ # `nested` - have each child on a separate line
294
+ # class Foo
295
+ # class Bar
296
+ # end
297
+ # end
298
+ #
299
+ # `compact` - combine definitions as much as possible
300
+ # class Foo::Bar
301
+ # end
302
+ #
303
+ # The compact style is only forced, for classes or modules with one child.
304
+ EnforcedStyle: nested
305
+ SupportedStyles:
306
+ - nested
307
+ - compact
308
+
309
+ Style/ClassCheck:
310
+ Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.'
311
+ StyleGuide: '#is-a-vs-kind-of'
312
+ Enabled: true
313
+ VersionAdded: '0.24'
314
+ EnforcedStyle: is_a?
315
+ SupportedStyles:
316
+ - is_a?
317
+ - kind_of?
318
+
319
+ Style/ClassEqualityComparison:
320
+ Description: 'Enforces the use of `Object#instance_of?` instead of class comparison for equality.'
321
+ StyleGuide: '#instance-of-vs-class-comparison'
322
+ Enabled: true
323
+ VersionAdded: '0.93'
324
+ AllowedMethods:
325
+ - ==
326
+ - equal?
327
+ - eql?
328
+ AllowedPatterns: [ ]
329
+
330
+ Style/ClassMethods:
331
+ Description: 'Use self when defining module/class methods.'
332
+ StyleGuide: '#def-self-class-methods'
333
+ Enabled: true
334
+ VersionAdded: '0.9'
335
+ VersionChanged: '0.20'
336
+
337
+ Style/ClassMethodsDefinitions:
338
+ Description: 'Enforces using `def self.method_name` or `class << self` to define class methods.'
339
+ StyleGuide: '#def-self-class-methods'
340
+ Enabled: false
341
+ VersionAdded: '0.89'
342
+ EnforcedStyle: def_self
343
+ SupportedStyles:
344
+ - def_self
345
+ - self_class
346
+
347
+ Style/ClassVars:
348
+ Description: 'Avoid the use of class variables.'
349
+ StyleGuide: '#no-class-vars'
350
+ Enabled: true
351
+ VersionAdded: '0.13'
352
+
353
+ Style/CollectionCompact:
354
+ Description: 'Use `{Array,Hash}#{compact,compact!}` instead of custom logic to reject nils.'
355
+ Enabled: true
356
+ Safe: false
357
+ VersionAdded: '1.2'
358
+ VersionChanged: '1.3'
359
+
360
+ # Align with the style guide.
361
+ Style/CollectionMethods:
362
+ Description: 'Preferred collection methods.'
363
+ StyleGuide: '#map-find-select-reduce-include-size'
364
+ Enabled: true
365
+ VersionAdded: '0.9'
366
+ VersionChanged: '1.7'
367
+ Safe: false
368
+ # Mapping from undesired method to desired method
369
+ # e.g. to use `detect` over `find`:
370
+ #
371
+ # Style/CollectionMethods:
372
+ # PreferredMethods:
373
+ # find: detect
374
+ PreferredMethods:
375
+ collect: 'map'
376
+ collect!: 'map!'
377
+ inject: 'reduce'
378
+ detect: 'find'
379
+ find_all: 'select'
380
+ member?: 'include?'
381
+ length: 'size'
382
+ # Methods in this array accept a final symbol as an implicit block
383
+ # eg. `inject(:+)`
384
+ MethodsAcceptingSymbol:
385
+ - inject
386
+ - reduce
387
+
388
+ Style/ColonMethodCall:
389
+ Description: 'Do not use :: for method call.'
390
+ StyleGuide: '#double-colons'
391
+ Enabled: true
392
+ VersionAdded: '0.9'
393
+
394
+ Style/ColonMethodDefinition:
395
+ Description: 'Do not use :: for defining class methods.'
396
+ StyleGuide: '#colon-method-definition'
397
+ Enabled: true
398
+ VersionAdded: '0.52'
399
+
400
+ Style/CombinableLoops:
401
+ Description: >-
402
+ Checks for places where multiple consecutive loops over the same data
403
+ can be combined into a single loop.
404
+ Enabled: true
405
+ Safe: false
406
+ VersionAdded: '0.90'
407
+
408
+ Style/CommandLiteral:
409
+ Description: 'Use `` or %x around command literals.'
410
+ StyleGuide: '#percent-x'
411
+ Enabled: true
412
+ VersionAdded: '0.30'
413
+ EnforcedStyle: backticks
414
+ # backticks: Always use backticks.
415
+ # percent_x: Always use `%x`.
416
+ # mixed: Use backticks on single-line commands, and `%x` on multi-line commands.
417
+ SupportedStyles:
418
+ - backticks
419
+ - percent_x
420
+ - mixed
421
+ # If `false`, the cop will always recommend using `%x` if one or more backticks
422
+ # are found in the command string.
423
+ AllowInnerBackticks: false
424
+
425
+ # Checks formatting of special comments
426
+ Style/CommentAnnotation:
427
+ Description: >-
428
+ Checks formatting of special comments
429
+ (TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE).
430
+ StyleGuide: '#annotate-keywords'
431
+ Enabled: true
432
+ VersionAdded: '0.10'
433
+ VersionChanged: '1.20'
434
+ Keywords:
435
+ - TODO
436
+ - FIXME
437
+ - OPTIMIZE
438
+ - HACK
439
+ - REVIEW
440
+ - NOTE
441
+ RequireColon: true
442
+
443
+ Style/CommentedKeyword:
444
+ Description: 'Do not place comments on the same line as certain keywords.'
445
+ Enabled: true
446
+ SafeAutoCorrect: false
447
+ VersionAdded: '0.51'
448
+ VersionChanged: '1.19'
449
+
450
+ <% if RuboCop::Version.document_version.to_f >= 1.44 %>
451
+ Style/ComparableClamp:
452
+ Description: 'Enforces the use of `Comparable#clamp` instead of comparison by minimum and maximum.'
453
+ Enabled: true
454
+ VersionAdded: '1.44'
455
+ <% end %>
456
+
457
+ <% if RuboCop::Version.document_version.to_f >= 1.41 %>
458
+ Style/ConcatArrayLiterals:
459
+ Description: 'Enforces the use of `Array#push(item)` instead of `Array#concat([item])` to avoid redundant array literals.'
460
+ Enabled: true
461
+ Safe: false
462
+ VersionAdded: '1.41'
463
+ <% end %>
464
+
465
+ Style/ConditionalAssignment:
466
+ Description: >-
467
+ Use the return value of `if` and `case` statements for
468
+ assignment to a variable and variable comparison instead
469
+ of assigning that variable inside of each branch.
470
+ Enabled: true
471
+ VersionAdded: '0.36'
472
+ VersionChanged: '0.47'
473
+ EnforcedStyle: assign_to_condition
474
+ SupportedStyles:
475
+ - assign_to_condition
476
+ - assign_inside_condition
477
+ # When configured to `assign_to_condition`, `SingleLineConditionsOnly`
478
+ # will only register an offense when all branches of a condition are
479
+ # a single line.
480
+ # When configured to `assign_inside_condition`, `SingleLineConditionsOnly`
481
+ # will only register an offense for assignment to a condition that has
482
+ # at least one multiline branch.
483
+ SingleLineConditionsOnly: true
484
+ IncludeTernaryExpressions: true
485
+
486
+ Style/ConstantVisibility:
487
+ Description: >-
488
+ Check that class- and module constants have
489
+ visibility declarations.
490
+ Enabled: false
491
+ VersionAdded: '0.66'
492
+ VersionChanged: '1.10'
493
+ IgnoreModules: false
494
+
495
+ # Checks that you have put a copyright in a comment before any code.
496
+ #
497
+ # You can override the default Notice in your .rubocop.yml file.
498
+ #
499
+ # In order to use autocorrect, you must supply a value for the
500
+ # `AutocorrectNotice` key that matches the regexp Notice. A blank
501
+ # `AutocorrectNotice` will cause an error during autocorrect.
502
+ #
503
+ # Autocorrect will add a copyright notice in a comment at the top
504
+ # of the file immediately after any shebang or encoding comments.
505
+ #
506
+ # Example rubocop.yml:
507
+ #
508
+ # Style/Copyright:
509
+ # Enabled: true
510
+ # Notice: 'Copyright (\(c\) )?2015 Yahoo! Inc'
511
+ # AutocorrectNotice: '# Copyright (c) 2015 Yahoo! Inc.'
512
+ #
513
+ Style/Copyright:
514
+ Description: 'Include a copyright notice in each file before any code.'
515
+ Enabled: false
516
+ VersionAdded: '0.30'
517
+ Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
518
+ AutocorrectNotice: ''
519
+
520
+ Style/DataInheritance:
521
+ Description: Checks for inheritance from Data.define.
522
+ Enabled: <%= ENV['RUBY_MAJOR'].to_f >= 3.2 %>
523
+ VersionAdded: '1.49'
524
+
525
+ Style/DateTime:
526
+ Description: 'Use Time over DateTime.'
527
+ StyleGuide: '#date-time'
528
+ Enabled: false
529
+ VersionAdded: '0.51'
530
+ VersionChanged: '0.92'
531
+ SafeAutoCorrect: false
532
+ AllowCoercion: false
533
+
534
+ Style/DefWithParentheses:
535
+ Description: 'Use def with parentheses when there are arguments.'
536
+ StyleGuide: '#method-parens'
537
+ Enabled: true
538
+ VersionAdded: '0.9'
539
+ VersionChanged: '0.12'
540
+
541
+ Style/Dir:
542
+ Description: >-
543
+ Use the `__dir__` method to retrieve the canonicalized
544
+ absolute path to the current file.
545
+ Enabled: true
546
+ VersionAdded: '0.50'
547
+
548
+ <% if RuboCop::Version.document_version.to_f >= 1.48 %>
549
+ Style/DirEmpty:
550
+ Description: >-
551
+ Prefer to use `Dir.empty?('path/to/dir')` when checking if a directory is empty.
552
+ Enabled: true
553
+ VersionAdded: '1.48'
554
+ <% end %>
555
+
556
+ Style/DisableCopsWithinSourceCodeDirective:
557
+ Severity: info # Or warning
558
+ Description: >-
559
+ Forbids disabling/enabling cops within source code.
560
+ Enabled: true
561
+ VersionAdded: '0.82'
562
+ VersionChanged: '1.9'
563
+ AllowedCops: # Project specific
564
+
565
+ Style/DocumentDynamicEvalDefinition:
566
+ Description: >-
567
+ When using `class_eval` (or other `eval`) with string interpolation,
568
+ add a comment block showing its appearance if interpolated.
569
+ StyleGuide: '#eval-comment-docs'
570
+ Enabled: true
571
+ VersionAdded: '1.1'
572
+ VersionChanged: '1.3'
573
+
574
+ Style/Documentation:
575
+ Description: 'Document classes and non-namespace modules.'
576
+ Enabled: false
577
+ VersionAdded: '0.9'
578
+ AllowedConstants: [ ]
579
+ Exclude:
580
+ - 'spec/**/*'
581
+ - 'test/**/*'
582
+
583
+ Style/DocumentationMethod:
584
+ Description: 'Checks for missing documentation comment for public methods.'
585
+ Enabled: true
586
+ VersionAdded: '0.43'
587
+ RequireForNonPublicMethods: true
588
+ Exclude:
589
+ - 'db/migrate/*'
590
+ - 'spec/**/*'
591
+ - 'test/**/*'
592
+
593
+ Style/DoubleCopDisableDirective:
594
+ Description: 'Checks for double rubocop:disable comments on a single line.'
595
+ Enabled: true
596
+ VersionAdded: '0.73'
597
+
598
+ Style/DoubleNegation:
599
+ Description: 'Checks for uses of double negation (!!).'
600
+ StyleGuide: '#no-bang-bang'
601
+ Enabled: true
602
+ VersionAdded: '0.19'
603
+ VersionChanged: '1.2'
604
+ EnforcedStyle: allowed_in_returns
605
+ SafeAutoCorrect: false
606
+ SupportedStyles:
607
+ - allowed_in_returns
608
+ - forbidden
609
+
610
+ Style/EachForSimpleLoop:
611
+ Description: >-
612
+ Use `Integer#times` for a simple loop which iterates a fixed
613
+ number of times.
614
+ Enabled: true
615
+ VersionAdded: '0.41'
616
+
617
+ Style/EachWithObject:
618
+ Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
619
+ Enabled: true
620
+ VersionAdded: '0.22'
621
+ VersionChanged: '0.42'
622
+
623
+ Style/EmptyBlockParameter:
624
+ Description: 'Omit pipes for empty block parameters.'
625
+ Enabled: true
626
+ VersionAdded: '0.52'
627
+
628
+ Style/EmptyCaseCondition:
629
+ Description: 'Avoid empty condition in case statements.'
630
+ Enabled: true
631
+ VersionAdded: '0.40'
632
+
633
+ Style/EmptyElse:
634
+ Description: 'Avoid empty else-clauses.'
635
+ Enabled: true
636
+ VersionAdded: '0.28'
637
+ VersionChanged: '0.32'
638
+ EnforcedStyle: both
639
+ # empty - warn only on empty `else`
640
+ # nil - warn on `else` with nil in it
641
+ # both - warn on empty `else` and `else` with `nil` in it
642
+ SupportedStyles:
643
+ - empty
644
+ - nil
645
+ - both
646
+ AllowComments: false
647
+
648
+ Style/EmptyHeredoc:
649
+ Description: 'Checks for using empty heredoc to reduce redundancy.'
650
+ Enabled: true
651
+ VersionAdded: '1.32'
652
+
653
+ Style/EmptyLambdaParameter:
654
+ Description: 'Omit parens for empty lambda parameters.'
655
+ Enabled: true
656
+ VersionAdded: '0.52'
657
+
658
+ Style/EmptyLiteral:
659
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
660
+ StyleGuide: '#literal-array-hash'
661
+ Enabled: true
662
+ VersionAdded: '0.9'
663
+ VersionChanged: '0.12'
664
+
665
+ Style/EmptyMethod:
666
+ Description: 'Checks the formatting of empty method definitions.'
667
+ StyleGuide: '#no-single-line-methods'
668
+ Enabled: true
669
+ VersionAdded: '0.46'
670
+ EnforcedStyle: expanded
671
+ SupportedStyles:
672
+ - compact
673
+ - expanded
674
+
675
+ Style/Encoding:
676
+ Description: 'Use UTF-8 as the source file encoding.'
677
+ StyleGuide: '#utf-8'
678
+ Enabled: true
679
+ VersionAdded: '0.9'
680
+ VersionChanged: '0.50'
681
+
682
+ Style/EndBlock:
683
+ Description: 'Avoid the use of END blocks.'
684
+ StyleGuide: '#no-END-blocks'
685
+ Enabled: true
686
+ VersionAdded: '0.9'
687
+ VersionChanged: '0.81'
688
+
689
+ Style/EndlessMethod:
690
+ Description: 'Avoid the use of multi-lined endless method definitions.'
691
+ StyleGuide: '#endless-methods'
692
+ Enabled: true
693
+ VersionAdded: '1.8'
694
+ EnforcedStyle: disallow
695
+ SupportedStyles:
696
+ - allow_single_line
697
+ - allow_always
698
+ - disallow
699
+
700
+ Style/EnvHome:
701
+ Description: "Checks for consistent usage of `ENV['HOME']`."
702
+ Enabled: true
703
+ Safe: false
704
+ VersionAdded: '1.29'
705
+
706
+ Style/EvalWithLocation:
707
+ Description: 'Pass `__FILE__` and `__LINE__` to `eval` method, as they are used by backtraces.'
708
+ Enabled: true
709
+ VersionAdded: '0.52'
710
+
711
+ Style/EvenOdd:
712
+ Description: 'Favor the use of `Integer#even?` && `Integer#odd?`.'
713
+ StyleGuide: '#predicate-methods'
714
+ Enabled: true
715
+ VersionAdded: '0.12'
716
+ VersionChanged: '0.29'
717
+
718
+ Style/ExpandPathArguments:
719
+ Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
720
+ Enabled: true
721
+ VersionAdded: '0.53'
722
+
723
+ Style/ExplicitBlockArgument:
724
+ Description: >-
725
+ Consider using explicit block argument to avoid writing block literal
726
+ that just passes its arguments to another block.
727
+ StyleGuide: '#block-argument'
728
+ Enabled: true
729
+ VersionAdded: '0.89'
730
+ VersionChanged: '1.8'
731
+
732
+ Style/ExponentialNotation:
733
+ Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
734
+ StyleGuide: '#exponential-notation'
735
+ Enabled: true
736
+ VersionAdded: '0.82'
737
+ EnforcedStyle: scientific
738
+ SupportedStyles:
739
+ - scientific
740
+ - engineering
741
+ - integral
742
+
743
+ Style/FetchEnvVar:
744
+ Description: >-
745
+ Suggests `ENV.fetch` for the replacement of `ENV[]`.
746
+ Reference:
747
+ - https://rubystyle.guide/#hash-fetch-defaults
748
+ Enabled: true
749
+ VersionAdded: '1.28'
750
+ # Environment variables to be excluded from the inspection.
751
+ AllowedVars: [ ]
752
+
753
+ <% if RuboCop::Version.document_version.to_f >= 1.48 %>
754
+ Style/FileEmpty:
755
+ Description: >-
756
+ Prefer to use `File.empty?('path/to/file')` when checking if a file is empty.
757
+ Enabled: true
758
+ VersionAdded: '1.48'
759
+ <% end %>
760
+
761
+ Style/FileRead:
762
+ Description: 'Favor `File.(bin)read` convenience methods.'
763
+ StyleGuide: '#file-read'
764
+ Enabled: true
765
+ VersionAdded: '1.24'
766
+
767
+ Style/FileWrite:
768
+ Description: 'Favor `File.(bin)write` convenience methods.'
769
+ StyleGuide: '#file-write'
770
+ Enabled: true
771
+ VersionAdded: '1.24'
772
+
773
+ Style/FloatDivision:
774
+ Description: 'For performing float division, coerce one side only.'
775
+ StyleGuide: '#float-division'
776
+ Reference: 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
777
+ Enabled: true
778
+ VersionAdded: '0.72'
779
+ VersionChanged: '1.9'
780
+ Safe: false
781
+ EnforcedStyle: single_coerce
782
+ SupportedStyles:
783
+ - left_coerce
784
+ - right_coerce
785
+ - single_coerce
786
+ - fdiv
787
+
788
+ Style/For:
789
+ Description: 'Checks use of for or each in multiline loops.'
790
+ StyleGuide: '#no-for-loops'
791
+ Enabled: true
792
+ SafeAutoCorrect: false
793
+ VersionAdded: '0.13'
794
+ VersionChanged: '1.26'
795
+ EnforcedStyle: each
796
+ SupportedStyles:
797
+ - each
798
+ - for
799
+
800
+ Style/FormatString:
801
+ Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
802
+ StyleGuide: '#sprintf'
803
+ Enabled: true
804
+ VersionAdded: '0.19'
805
+ VersionChanged: '0.49'
806
+ EnforcedStyle: format
807
+ SupportedStyles:
808
+ - format
809
+ - sprintf
810
+ - percent
811
+
812
+ Style/FormatStringToken:
813
+ Description: 'Use a consistent style for format string tokens.'
814
+ Enabled: true
815
+ EnforcedStyle: template
816
+ SupportedStyles:
817
+ # Prefer tokens which contain a sprintf like type annotation like
818
+ # `%<name>s`, `%<age>d`, `%<score>f`
819
+ - annotated
820
+ # Prefer simple looking "template" style tokens like `%{name}`, `%{age}`
821
+ - template
822
+ - unannotated
823
+ # `MaxUnannotatedPlaceholdersAllowed` defines the number of `unannotated`
824
+ # style token in a format string to be allowed when enforced style is not
825
+ # `unannotated`.
826
+ MaxUnannotatedPlaceholdersAllowed: 0
827
+ VersionAdded: '0.49'
828
+ VersionChanged: '1.0'
829
+ AllowedMethods: [ ]
830
+ AllowedPatterns: [ ]
831
+
832
+ Style/FrozenStringLiteralComment:
833
+ Description: >-
834
+ Add the frozen_string_literal comment to the top of files
835
+ to help transition to frozen string literals by default.
836
+ Enabled: true
837
+ VersionAdded: '0.36'
838
+ VersionChanged: '0.79'
839
+ EnforcedStyle: always
840
+ SupportedStyles:
841
+ # `always` will always add the frozen string literal comment to a file
842
+ # regardless of the Ruby version or if `freeze` or `<<` are called on a
843
+ # string literal. It is possible that this will create errors.
844
+ - always
845
+ # `always_true` will add the frozen string literal comment to a file,
846
+ # similarly to the `always` style, but will also change any disabled
847
+ # comments (e.g. `# frozen_string_literal: false`) to be enabled.
848
+ - always_true
849
+ # `never` will enforce that the frozen string literal comment does not
850
+ # exist in a file.
851
+ - never
852
+ SafeAutoCorrect: false
853
+ Exclude:
854
+ - 'db/migrate/*'
855
+ - './**/*.json.jbuilder'
856
+
857
+ Style/GlobalStdStream:
858
+ Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
859
+ StyleGuide: '#global-stdout'
860
+ Enabled: true
861
+ VersionAdded: '0.89'
862
+ SafeAutoCorrect: false
863
+
864
+ Style/GlobalVars:
865
+ Description: 'Do not introduce global variables.'
866
+ StyleGuide: '#instance-vars'
867
+ Reference: 'https://www.zenspider.com/ruby/quickref.html'
868
+ Enabled: true
869
+ VersionAdded: '0.13'
870
+ # Built-in global variables are allowed by default.
871
+ AllowedVariables: [ ]
872
+
873
+ Style/GuardClause:
874
+ Description: 'Check for conditionals that can be replaced with guard clauses.'
875
+ StyleGuide: '#no-nested-conditionals'
876
+ Enabled: true
877
+ VersionAdded: '0.20'
878
+ VersionChanged: '1.31'
879
+ # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
880
+ # needs to have to trigger this cop
881
+ MinBodyLength: 1
882
+ AllowConsecutiveConditionals: false
883
+
884
+ Style/HashAsLastArrayItem:
885
+ Description: >-
886
+ Checks for presence or absence of braces around hash literal as a last
887
+ array item depending on configuration.
888
+ StyleGuide: '#hash-literal-as-last-array-item'
889
+ Enabled: true
890
+ VersionAdded: '0.88'
891
+ EnforcedStyle: braces
892
+ SupportedStyles:
893
+ - braces
894
+ - no_braces
895
+
896
+ Style/HashConversion:
897
+ Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.'
898
+ StyleGuide: '#avoid-hash-constructor'
899
+ Enabled: true
900
+ VersionAdded: '1.10'
901
+ VersionChanged: '1.11'
902
+ AllowSplatArgument: false
903
+
904
+ Style/HashEachMethods:
905
+ Description: 'Use Hash#each_key and Hash#each_value.'
906
+ StyleGuide: '#hash-each'
907
+ Enabled: true
908
+ Safe: false
909
+ VersionAdded: '0.80'
910
+ VersionChanged: '1.16'
911
+ AllowedReceivers: [ ]
912
+
913
+ Style/HashExcept:
914
+ Description: >-
915
+ Checks for usages of `Hash#reject`, `Hash#select`, and `Hash#filter` methods
916
+ that can be replaced with `Hash#except` method.
917
+ Enabled: true
918
+ Safe: false
919
+ VersionAdded: '1.7'
920
+ VersionChanged: '1.39'
921
+
922
+ Style/HashLikeCase:
923
+ Description: >-
924
+ Checks for places where `case-when` represents a simple 1:1
925
+ mapping and can be replaced with a hash lookup.
926
+ Enabled: true
927
+ VersionAdded: '0.88'
928
+ # `MinBranchesCount` defines the number of branches `case` needs to have
929
+ # to trigger this cop
930
+ MinBranchesCount: 3
931
+
932
+ Style/HashSyntax:
933
+ Description: >-
934
+ Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
935
+ { :a => 1, :b => 2 }.
936
+ StyleGuide: '#hash-literals'
937
+ Enabled: true
938
+ VersionAdded: '0.9'
939
+ VersionChanged: '1.24'
940
+ EnforcedStyle: ruby19_no_mixed_keys
941
+ SupportedStyles:
942
+ # checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys
943
+ - ruby19
944
+ # checks for hash rocket syntax for all hashes
945
+ - hash_rockets
946
+ # forbids mixed key syntaxes (e.g. {a: 1, :b => 2})
947
+ - no_mixed_keys
948
+ # enforces both ruby19 and no_mixed_keys styles
949
+ - ruby19_no_mixed_keys
950
+ # Force hashes that have a hash value omission
951
+ EnforcedShorthandSyntax: never
952
+ SupportedShorthandSyntax:
953
+ # forces use of the 3.1 syntax (e.g. {foo:}) when the hash key and value are the same.
954
+ - always
955
+ # forces use of explicit hash literal value.
956
+ - never
957
+ # accepts both shorthand and explicit use of hash literal value.
958
+ - either
959
+ # like "either", but will avoid mixing styles in a single hash
960
+ - consistent
961
+ # Force hashes that have a symbol value to use hash rockets
962
+ UseHashRocketsWithSymbolValues: false
963
+ # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
964
+ PreferHashRocketsForNonAlnumEndingSymbols: false
965
+
966
+ Style/HashTransformKeys:
967
+ Description: 'Prefer `transform_keys` over `each_with_object`, `map`, or `to_h`.'
968
+ Enabled: true
969
+ VersionAdded: '0.80'
970
+ VersionChanged: '0.90'
971
+ Safe: false
972
+
973
+ Style/HashTransformValues:
974
+ Description: 'Prefer `transform_values` over `each_with_object`, `map`, or `to_h`.'
975
+ Enabled: true
976
+ VersionAdded: '0.80'
977
+ VersionChanged: '0.90'
978
+ Safe: false
979
+
980
+ Style/IdenticalConditionalBranches:
981
+ Description: >-
982
+ Checks that conditional statements do not have an identical
983
+ line at the end of each branch, which can validly be moved
984
+ out of the conditional.
985
+ Enabled: true
986
+ SafeAutoCorrect: false
987
+ VersionAdded: '0.36'
988
+ VersionChanged: '1.19'
989
+
990
+ Style/IfInsideElse:
991
+ Description: 'Finds if nodes inside else, which can be converted to elsif.'
992
+ Enabled: true
993
+ AllowIfModifier: true
994
+ VersionAdded: '0.36'
995
+ VersionChanged: '1.3'
996
+
997
+ Style/IfUnlessModifier:
998
+ Description: >-
999
+ Favor modifier if/unless usage when you have a
1000
+ single-line body.
1001
+ StyleGuide: '#if-as-a-modifier'
1002
+ Enabled: false
1003
+ VersionAdded: '0.9'
1004
+ VersionChanged: '0.30'
1005
+
1006
+ Style/IfUnlessModifierOfIfUnless:
1007
+ Description: >-
1008
+ Avoid modifier if/unless usage on conditionals.
1009
+ Enabled: true
1010
+ VersionAdded: '0.39'
1011
+ VersionChanged: '0.87'
1012
+
1013
+ Style/IfWithBooleanLiteralBranches:
1014
+ Description: 'Checks for redundant `if` with boolean literal branches.'
1015
+ Enabled: true
1016
+ VersionAdded: '1.9'
1017
+ SafeAutoCorrect: false
1018
+ AllowedMethods:
1019
+ - nonzero?
1020
+
1021
+ Style/IfWithSemicolon:
1022
+ Description: 'Do not use if x; .... Use the ternary operator instead.'
1023
+ StyleGuide: '#no-semicolon-ifs'
1024
+ Enabled: true
1025
+ VersionAdded: '0.9'
1026
+ VersionChanged: '0.83'
1027
+
1028
+ Style/ImplicitRuntimeError:
1029
+ Description: >-
1030
+ Use `raise` or `fail` with an explicit exception class and
1031
+ message, rather than just a message.
1032
+ Enabled: false
1033
+ VersionAdded: '0.41'
1034
+
1035
+ Style/InPatternThen:
1036
+ Description: 'Checks for `in;` uses in `case` expressions.'
1037
+ StyleGuide: '#no-in-pattern-semicolons'
1038
+ Enabled: true
1039
+ VersionAdded: '1.16'
1040
+
1041
+ Style/InfiniteLoop:
1042
+ Description: >-
1043
+ Use Kernel#loop for infinite loops.
1044
+ This cop is unsafe if the body may raise a `StopIteration` exception.
1045
+ Safe: false
1046
+ StyleGuide: '#infinite-loop'
1047
+ Enabled: true
1048
+ VersionAdded: '0.26'
1049
+ VersionChanged: '0.61'
1050
+
1051
+ Style/InlineComment:
1052
+ Description: 'Avoid trailing inline comments.'
1053
+ Enabled: true
1054
+ VersionAdded: '0.23'
1055
+
1056
+ Style/InverseMethods:
1057
+ Description: >-
1058
+ Use the inverse method instead of `!.method`
1059
+ if an inverse method is defined.
1060
+ Enabled: true
1061
+ Safe: false
1062
+ VersionAdded: '0.48'
1063
+ # `InverseMethods` are methods that can be inverted by a not (`not` or `!`)
1064
+ # The relationship of inverse methods only needs to be defined in one direction.
1065
+ # Keys and values both need to be defined as symbols.
1066
+ InverseMethods:
1067
+ :any?: :none?
1068
+ :even?: :odd?
1069
+ :==: :!=
1070
+ :=~: :!~
1071
+ :<: :>=
1072
+ :>: :<=
1073
+ # `ActiveSupport` defines some common inverse methods. They are listed below,
1074
+ # and not enabled by default.
1075
+ # :present?: :blank?,
1076
+ # :include?: :exclude?
1077
+ # `InverseBlocks` are methods that are inverted by inverting the return
1078
+ # of the block that is passed to the method
1079
+ InverseBlocks:
1080
+ :select: :reject
1081
+ :select!: :reject!
1082
+
1083
+ <% if RuboCop::Version.document_version.to_f >= 1.44 %>
1084
+ Style/InvertibleUnlessCondition:
1085
+ Description: 'Favor `if` with inverted condition over `unless`.'
1086
+ Enabled: true
1087
+ VersionAdded: '1.44'
1088
+ # `InverseMethods` are methods that can be inverted in a `unless` condition.
1089
+ # The relationship of inverse methods needs to be defined in both directions.
1090
+ # Keys and values both need to be defined as symbols.
1091
+ InverseMethods:
1092
+ :!=: :==
1093
+ :>: :<=
1094
+ :<=: :>
1095
+ :<: :>=
1096
+ :>=: :<
1097
+ :!~: :=~
1098
+ :zero?: :nonzero?
1099
+ :nonzero?: :zero?
1100
+ :any?: :none?
1101
+ :none?: :any?
1102
+ :even?: :odd?
1103
+ :odd?: :even?
1104
+ :present?: :blank?
1105
+ :blank?: :present?
1106
+ :include?: :exclude?
1107
+ :exclude?: :include?
1108
+ # :one?: :many?
1109
+ # :many?: :one?
1110
+ <% end %>
1111
+
1112
+ Style/IpAddresses:
1113
+ Description: "Don't include literal IP addresses in code."
1114
+ Enabled: true
1115
+ VersionAdded: '0.58'
1116
+ VersionChanged: '0.91'
1117
+ # Allow addresses to be permitted
1118
+ AllowedAddresses:
1119
+ - "::"
1120
+ # :: is a valid IPv6 address, but could potentially be legitimately in code
1121
+ Exclude:
1122
+ - '**/*.gemfile'
1123
+ - '**/Gemfile'
1124
+ - '**/gems.rb'
1125
+ - '**/*.gemspec'
1126
+
1127
+ Style/KeywordParametersOrder:
1128
+ Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
1129
+ StyleGuide: '#keyword-parameters-order'
1130
+ Enabled: true
1131
+ VersionAdded: '0.90'
1132
+ VersionChanged: '1.7'
1133
+
1134
+ Style/Lambda:
1135
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
1136
+ StyleGuide: '#lambda-multi-line'
1137
+ Enabled: true
1138
+ VersionAdded: '0.9'
1139
+ VersionChanged: '0.40'
1140
+ EnforcedStyle: literal
1141
+ SupportedStyles:
1142
+ - line_count_dependent
1143
+ - lambda
1144
+ - literal
1145
+
1146
+ Style/LambdaCall:
1147
+ Description: 'Use lambda.call(...) instead of lambda.(...).'
1148
+ StyleGuide: '#proc-call'
1149
+ Enabled: true
1150
+ VersionAdded: '0.13'
1151
+ VersionChanged: '0.14'
1152
+ EnforcedStyle: call
1153
+ SupportedStyles:
1154
+ - call
1155
+ - braces
1156
+
1157
+ Style/LineEndConcatenation:
1158
+ Description: >-
1159
+ Use \ instead of + or << to concatenate two string literals at
1160
+ line end.
1161
+ Enabled: true
1162
+ SafeAutoCorrect: false
1163
+ VersionAdded: '0.18'
1164
+ VersionChanged: '0.64'
1165
+
1166
+ Style/MagicCommentFormat:
1167
+ Description: 'Use a consistent style for magic comments.'
1168
+ Enabled: true
1169
+ VersionAdded: '1.35'
1170
+ EnforcedStyle: snake_case
1171
+ SupportedStyles:
1172
+ # `snake` will enforce the magic comment is written
1173
+ # in snake case (words separated by underscores).
1174
+ # Eg: froze_string_literal: true
1175
+ - snake_case
1176
+ # `kebab` will enforce the magic comment is written
1177
+ # in kebab case (words separated by hyphens).
1178
+ # Eg: froze-string-literal: true
1179
+ - kebab_case
1180
+ DirectiveCapitalization: lowercase
1181
+ ValueCapitalization: lowercase
1182
+ SupportedCapitalizations:
1183
+ - lowercase
1184
+ - uppercase
1185
+
1186
+ Style/MapCompactWithConditionalBlock:
1187
+ Description: 'Prefer `select` or `reject` over `map { ... }.compact`.'
1188
+ Enabled: true
1189
+ VersionAdded: '1.30'
1190
+
1191
+ Style/MapToHash:
1192
+ Description: 'Prefer `to_h` with a block over `map.to_h`.'
1193
+ Enabled: true
1194
+ VersionAdded: '1.24'
1195
+ Safe: false
1196
+
1197
+ Style/MapToSet:
1198
+ Description: Prefer `to_set` with a block over `map.to_set`.
1199
+ Enabled: true
1200
+ Safe: false
1201
+ VersionAdded: '1.42'
1202
+
1203
+ Style/MethodCallWithArgsParentheses:
1204
+ Description: 'Use parentheses for method calls with arguments.'
1205
+ StyleGuide: '#method-invocation-parens'
1206
+ Enabled: true
1207
+ VersionAdded: '0.47'
1208
+ VersionChanged: '1.7'
1209
+ IgnoreMacros: true
1210
+ AllowedMethods: [ ]
1211
+ AllowedPatterns: [ ]
1212
+ IncludedMacros: [ ]
1213
+ AllowParenthesesInMultilineCall: false
1214
+ AllowParenthesesInChaining: false
1215
+ AllowParenthesesInCamelCaseMethod: false
1216
+ AllowParenthesesInStringInterpolation: false
1217
+ EnforcedStyle: require_parentheses
1218
+ SupportedStyles:
1219
+ - require_parentheses
1220
+ - omit_parentheses
1221
+ Exclude:
1222
+ - 'db/migrate/*'
1223
+
1224
+ Style/MethodCallWithoutArgsParentheses:
1225
+ Description: 'Do not use parentheses for method calls with no arguments.'
1226
+ StyleGuide: '#method-invocation-parens'
1227
+ Enabled: true
1228
+ AllowedMethods: [ ]
1229
+ AllowedPatterns: [ ]
1230
+ VersionAdded: '0.47'
1231
+ VersionChanged: '0.55'
1232
+
1233
+ Style/MethodCalledOnDoEndBlock:
1234
+ Description: 'Avoid chaining a method call on a do...end block.'
1235
+ StyleGuide: '#single-line-blocks'
1236
+ Enabled: true
1237
+ VersionAdded: '0.14'
1238
+
1239
+ Style/MethodDefParentheses:
1240
+ Description: >-
1241
+ Checks if the method definitions have or don't have
1242
+ parentheses.
1243
+ StyleGuide: '#method-parens'
1244
+ Enabled: true
1245
+ VersionAdded: '0.16'
1246
+ VersionChanged: '1.7'
1247
+ EnforcedStyle: require_parentheses
1248
+ SupportedStyles:
1249
+ - require_parentheses
1250
+ - require_no_parentheses
1251
+ - require_no_parentheses_except_multiline
1252
+
1253
+ Style/MinMax:
1254
+ Description: >-
1255
+ Use `Enumerable#minmax` instead of `Enumerable#min`
1256
+ and `Enumerable#max` in conjunction.
1257
+ Enabled: true
1258
+ VersionAdded: '0.50'
1259
+
1260
+ Style/MinMaxComparison:
1261
+ Description: Enforces the use of `max` or `min` instead of comparison for greater
1262
+ or less.
1263
+ Enabled: true
1264
+ Safe: false
1265
+ VersionAdded: '1.42'
1266
+
1267
+ Style/MissingElse:
1268
+ Description: >-
1269
+ Require if/case expressions to have an else branches.
1270
+ If enabled, it is recommended that
1271
+ Style/UnlessElse and Style/EmptyElse be enabled.
1272
+ This will conflict with Style/EmptyElse if
1273
+ Style/EmptyElse is configured to style "both".
1274
+ Enabled: false
1275
+ VersionAdded: '0.30'
1276
+ VersionChanged: '0.38'
1277
+ EnforcedStyle: both
1278
+ SupportedStyles:
1279
+ # if - warn when an if expression is missing an else branch
1280
+ # case - warn when a case expression is missing an else branch
1281
+ # both - warn when an if or case expression is missing an else branch
1282
+ - if
1283
+ - case
1284
+ - both
1285
+
1286
+ Style/MissingRespondToMissing:
1287
+ Description: >-
1288
+ Checks if `method_missing` is implemented
1289
+ without implementing `respond_to_missing`.
1290
+ StyleGuide: '#no-method-missing'
1291
+ Enabled: true
1292
+ VersionAdded: '0.56'
1293
+
1294
+ Style/MixinGrouping:
1295
+ Description: 'Checks for grouping of mixins in `class` and `module` bodies.'
1296
+ StyleGuide: '#mixin-grouping'
1297
+ Enabled: true
1298
+ VersionAdded: '0.48'
1299
+ VersionChanged: '0.49'
1300
+ EnforcedStyle: separated
1301
+ SupportedStyles:
1302
+ # separated: each mixed in module goes in a separate statement.
1303
+ # grouped: mixed in modules are grouped into a single statement.
1304
+ - separated
1305
+ - grouped
1306
+
1307
+ Style/MixinUsage:
1308
+ Description: 'Checks that `include`, `extend` and `prepend` exists at the top level.'
1309
+ Enabled: true
1310
+ VersionAdded: '0.51'
1311
+ Exclude:
1312
+ - './**/*.rake'
1313
+
1314
+ Style/ModuleFunction:
1315
+ Description: 'Checks for usage of `extend self` in modules.'
1316
+ StyleGuide: '#module-function'
1317
+ Enabled: true
1318
+ VersionAdded: '0.11'
1319
+ VersionChanged: '0.65'
1320
+ EnforcedStyle: module_function
1321
+ SupportedStyles:
1322
+ - module_function
1323
+ - extend_self
1324
+ - forbidden
1325
+ Autocorrect: false
1326
+ SafeAutoCorrect: false
1327
+
1328
+ Style/MultilineBlockChain:
1329
+ Description: 'Avoid multi-line chains of blocks.'
1330
+ StyleGuide: '#single-line-blocks'
1331
+ Enabled: true
1332
+ VersionAdded: '0.13'
1333
+
1334
+ Style/MultilineIfModifier:
1335
+ Description: 'Only use if/unless modifiers on single line statements.'
1336
+ StyleGuide: '#no-multiline-if-modifiers'
1337
+ Enabled: true
1338
+ VersionAdded: '0.45'
1339
+
1340
+ Style/MultilineIfThen:
1341
+ Description: 'Do not use then for multi-line if/unless.'
1342
+ StyleGuide: '#no-then'
1343
+ Enabled: true
1344
+ VersionAdded: '0.9'
1345
+ VersionChanged: '0.26'
1346
+
1347
+ Style/MultilineInPatternThen:
1348
+ Description: 'Do not use `then` for multi-line `in` statement.'
1349
+ StyleGuide: '#no-then'
1350
+ Enabled: true
1351
+ VersionAdded: '1.16'
1352
+
1353
+ Style/MultilineMemoization:
1354
+ Description: 'Wrap multiline memoizations in a `begin` and `end` block.'
1355
+ Enabled: true
1356
+ VersionAdded: '0.44'
1357
+ VersionChanged: '0.48'
1358
+ EnforcedStyle: keyword
1359
+ SupportedStyles:
1360
+ - keyword
1361
+ - braces
1362
+
1363
+ Style/MultilineMethodSignature:
1364
+ Description: 'Avoid multi-line method signatures.'
1365
+ Enabled: false
1366
+ VersionAdded: '0.59'
1367
+ VersionChanged: '1.7'
1368
+
1369
+ Style/MultilineTernaryOperator:
1370
+ Description: >-
1371
+ Avoid multi-line ?: (the ternary operator);
1372
+ use if/unless instead.
1373
+ StyleGuide: '#no-multiline-ternary'
1374
+ Enabled: true
1375
+ VersionAdded: '0.9'
1376
+ VersionChanged: '0.86'
1377
+
1378
+ Style/MultilineWhenThen:
1379
+ Description: 'Do not use then for multi-line when statement.'
1380
+ StyleGuide: '#no-then'
1381
+ Enabled: true
1382
+ VersionAdded: '0.73'
1383
+
1384
+ Style/MultipleComparison:
1385
+ Description: >-
1386
+ Avoid comparing a variable with multiple items in a conditional,
1387
+ use Array#include? instead.
1388
+ Enabled: true
1389
+ VersionAdded: '0.49'
1390
+ VersionChanged: '1.1'
1391
+ AllowMethodComparison: true
1392
+
1393
+ Style/MutableConstant:
1394
+ Description: 'Do not assign mutable objects to constants.'
1395
+ Enabled: true
1396
+ VersionAdded: '0.34'
1397
+ VersionChanged: '1.8'
1398
+ SafeAutoCorrect: false
1399
+ EnforcedStyle: literals
1400
+ SupportedStyles:
1401
+ # literals: freeze literals assigned to constants
1402
+ # strict: freeze all constants
1403
+ # Strict mode is considered an experimental feature. It has not been updated
1404
+ # with an exhaustive list of all methods that will produce frozen objects so
1405
+ # there is a decent chance of getting some false positives. Luckily, there is
1406
+ # no harm in freezing an already frozen object.
1407
+ - literals
1408
+ - strict
1409
+
1410
+ Style/NegatedIf:
1411
+ Description: >-
1412
+ Favor unless over if for negative conditions
1413
+ (or control flow or).
1414
+ StyleGuide: '#unless-for-negatives'
1415
+ Enabled: true
1416
+ VersionAdded: '0.20'
1417
+ VersionChanged: '0.48'
1418
+ EnforcedStyle: both
1419
+ SupportedStyles:
1420
+ # both: prefix and postfix negated `if` should both use `unless`
1421
+ # prefix: only use `unless` for negated `if` statements positioned before the body of the statement
1422
+ # postfix: only use `unless` for negated `if` statements positioned after the body of the statement
1423
+ - both
1424
+ - prefix
1425
+ - postfix
1426
+
1427
+ Style/NegatedIfElseCondition:
1428
+ Description: >-
1429
+ Checks for uses of `if-else` and ternary operators with a negated condition
1430
+ which can be simplified by inverting condition and swapping branches.
1431
+ Enabled: true
1432
+ VersionAdded: '1.2'
1433
+
1434
+ Style/NegatedUnless:
1435
+ Description: 'Favor if over unless for negative conditions.'
1436
+ StyleGuide: '#if-for-negatives'
1437
+ Enabled: true
1438
+ VersionAdded: '0.69'
1439
+ EnforcedStyle: both
1440
+ SupportedStyles:
1441
+ # both: prefix and postfix negated `unless` should both use `if`
1442
+ # prefix: only use `if` for negated `unless` statements positioned before the body of the statement
1443
+ # postfix: only use `if` for negated `unless` statements positioned after the body of the statement
1444
+ - both
1445
+ - prefix
1446
+ - postfix
1447
+
1448
+ Style/NegatedWhile:
1449
+ Description: 'Favor until over while for negative conditions.'
1450
+ StyleGuide: '#until-for-negatives'
1451
+ Enabled: true
1452
+ VersionAdded: '0.20'
1453
+
1454
+ Style/NestedFileDirname:
1455
+ Description: 'Checks for nested `File.dirname`.'
1456
+ Enabled: true
1457
+ VersionAdded: '1.26'
1458
+
1459
+ Style/NestedModifier:
1460
+ Description: 'Avoid using nested modifiers.'
1461
+ StyleGuide: '#no-nested-modifiers'
1462
+ Enabled: true
1463
+ VersionAdded: '0.35'
1464
+
1465
+ Style/NestedParenthesizedCalls:
1466
+ Description: >-
1467
+ Parenthesize method calls which are nested inside the
1468
+ argument list of another parenthesized method call.
1469
+ Enabled: true
1470
+ VersionAdded: '0.36'
1471
+ VersionChanged: '0.77'
1472
+ AllowedMethods:
1473
+ - be
1474
+ - be_a
1475
+ - be_an
1476
+ - be_between
1477
+ - be_falsey
1478
+ - be_kind_of
1479
+ - be_instance_of
1480
+ - be_truthy
1481
+ - be_within
1482
+ - eq
1483
+ - eql
1484
+ - end_with
1485
+ - include
1486
+ - match
1487
+ - raise_error
1488
+ - respond_to
1489
+ - start_with
1490
+
1491
+ Style/NestedTernaryOperator:
1492
+ Description: 'Use one expression per branch in a ternary operator.'
1493
+ StyleGuide: '#no-nested-ternary'
1494
+ Enabled: true
1495
+ VersionAdded: '0.9'
1496
+ VersionChanged: '0.86'
1497
+
1498
+ Style/Next:
1499
+ Description: 'Use `next` to skip iteration instead of a condition at the end.'
1500
+ StyleGuide: '#no-nested-conditionals'
1501
+ Enabled: true
1502
+ VersionAdded: '0.22'
1503
+ VersionChanged: '0.35'
1504
+ # With `always` all conditions at the end of an iteration needs to be
1505
+ # replaced by next - with `skip_modifier_ifs` the modifier if like this one
1506
+ # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
1507
+ EnforcedStyle: skip_modifier_ifs
1508
+ # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
1509
+ # needs to have to trigger this cop
1510
+ MinBodyLength: 3
1511
+ SupportedStyles:
1512
+ - skip_modifier_ifs
1513
+ - always
1514
+
1515
+ Style/NilComparison:
1516
+ Description: 'Prefer x.nil? to x == nil.'
1517
+ StyleGuide: '#predicate-methods'
1518
+ Enabled: true
1519
+ VersionAdded: '0.12'
1520
+ VersionChanged: '0.59'
1521
+ EnforcedStyle: predicate
1522
+ SupportedStyles:
1523
+ - predicate
1524
+ - comparison
1525
+
1526
+ Style/NilLambda:
1527
+ Description: 'Prefer `-> {}` to `-> { nil }`.'
1528
+ Enabled: true
1529
+ VersionAdded: '1.3'
1530
+ VersionChanged: '1.15'
1531
+
1532
+ Style/NonNilCheck:
1533
+ Description: 'Checks for redundant nil checks.'
1534
+ StyleGuide: '#no-non-nil-checks'
1535
+ Enabled: true
1536
+ VersionAdded: '0.20'
1537
+ VersionChanged: '0.22'
1538
+ # With `IncludeSemanticChanges` set to `true`, this cop reports offenses for
1539
+ # `!x.nil?` and autocorrects that and `x != nil` to solely `x`, which is
1540
+ # **usually** OK, but might change behavior.
1541
+ #
1542
+ # With `IncludeSemanticChanges` set to `false`, this cop does not report
1543
+ # offenses for `!x.nil?` and does no changes that might change behavior.
1544
+ IncludeSemanticChanges: false
1545
+
1546
+ Style/Not:
1547
+ Description: 'Use ! instead of not.'
1548
+ StyleGuide: '#bang-not-not'
1549
+ Enabled: true
1550
+ VersionAdded: '0.9'
1551
+ VersionChanged: '0.20'
1552
+
1553
+ Style/NumberedParameters:
1554
+ Description: 'Restrict the usage of numbered parameters.'
1555
+ Enabled: true
1556
+ VersionAdded: '1.22'
1557
+ EnforcedStyle: disallow
1558
+ SupportedStyles:
1559
+ - allow_single_line
1560
+ - disallow
1561
+
1562
+ Style/NumberedParametersLimit:
1563
+ Description: 'Avoid excessive numbered params in a single block.'
1564
+ Enabled: true
1565
+ VersionAdded: '1.22'
1566
+ Max: 0
1567
+
1568
+ Style/NumericLiteralPrefix:
1569
+ Description: 'Use smallcase prefixes for numeric literals.'
1570
+ StyleGuide: '#numeric-literal-prefixes'
1571
+ Enabled: true
1572
+ VersionAdded: '0.41'
1573
+ EnforcedOctalStyle: zero_with_o
1574
+ SupportedOctalStyles:
1575
+ - zero_with_o
1576
+ - zero_only
1577
+
1578
+ Style/NumericLiterals:
1579
+ Description: >-
1580
+ Add underscores to large numeric literals to improve their
1581
+ readability.
1582
+ StyleGuide: '#underscores-in-numerics'
1583
+ Enabled: true
1584
+ VersionAdded: '0.9'
1585
+ VersionChanged: '0.48'
1586
+ Strict: true
1587
+ MinDigits: 4
1588
+ # You can specify allowed numbers. (e.g. port number 3000, 8080, and etc)
1589
+ AllowedNumbers:
1590
+ - 3000
1591
+ - 3306
1592
+ - 3035
1593
+ - 5432
1594
+ - 6379
1595
+ - 8080
1596
+ - 11211
1597
+ AllowedPatterns: [ ]
1598
+
1599
+ Style/NumericPredicate:
1600
+ Description: >-
1601
+ Checks for the use of predicate- or comparison methods for
1602
+ numeric comparisons.
1603
+ StyleGuide: '#predicate-methods'
1604
+ Safe: false
1605
+ # This will change to a new method call which isn't guaranteed to be on the
1606
+ # object. Switching these methods has to be done with knowledge of the types
1607
+ # of the variables which rubocop doesn't have.
1608
+ SafeAutoCorrect: false
1609
+ Enabled: false
1610
+ VersionAdded: '0.42'
1611
+ VersionChanged: '0.59'
1612
+ EnforcedStyle: predicate
1613
+ SupportedStyles:
1614
+ - predicate
1615
+ - comparison
1616
+ AllowedMethods: [ ]
1617
+ AllowedPatterns: [ ]
1618
+ # Exclude RSpec specs because assertions like `expect(1).to be > 0` cause
1619
+ # false positives.
1620
+ Exclude:
1621
+ - 'spec/**/*'
1622
+
1623
+ Style/ObjectThen:
1624
+ Description: 'Enforces the use of consistent method names `Object#yield_self` or `Object#then`.'
1625
+ StyleGuide: '#object-yield-self-vs-object-then'
1626
+ Enabled: true
1627
+ VersionAdded: '1.28'
1628
+ # Use `Object#yield_self` or `Object#then`?
1629
+ # Prefer `Object#yield_self` to `Object#then` (yield_self)
1630
+ # Prefer `Object#then` to `Object#yield_self` (then)
1631
+ EnforcedStyle: yield_self
1632
+ SupportedStyles:
1633
+ - then
1634
+ - yield_self
1635
+
1636
+ Style/OneLineConditional:
1637
+ Description: >-
1638
+ Favor the ternary operator (?:) or multi-line constructs over
1639
+ single-line if/then/else/end constructs.
1640
+ StyleGuide: '#ternary-operator'
1641
+ Enabled: true
1642
+ AlwaysCorrectToMultiline: false
1643
+ VersionAdded: '0.9'
1644
+ VersionChanged: '0.90'
1645
+
1646
+ Style/OpenStructUse:
1647
+ Description: >-
1648
+ Avoid using OpenStruct. As of Ruby 3.0, use is officially discouraged due to performance,
1649
+ version compatibility, and potential security issues.
1650
+ Reference:
1651
+ - https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
1652
+ Enabled: true
1653
+ VersionAdded: '1.23'
1654
+
1655
+ Style/OperatorMethodCall:
1656
+ Description: 'Checks for redundant dot before operator method call.'
1657
+ StyleGuide: '#operator-method-call'
1658
+ Enabled: true
1659
+ VersionAdded: '1.37'
1660
+
1661
+ Style/OptionHash:
1662
+ Description: "Don't use option hashes when you can use keyword arguments."
1663
+ Enabled: false
1664
+ VersionAdded: '0.33'
1665
+ VersionChanged: '0.34'
1666
+ # A list of parameter names that will be flagged by this cop.
1667
+ SuspiciousParamNames:
1668
+ - options
1669
+ - opts
1670
+ - args
1671
+ - params
1672
+ - parameters
1673
+ Allowlist: [ ]
1674
+
1675
+ Style/OptionalArguments:
1676
+ Description: >-
1677
+ Checks for optional arguments that do not appear at the end
1678
+ of the argument list.
1679
+ StyleGuide: '#optional-arguments'
1680
+ Enabled: true
1681
+ Safe: false
1682
+ VersionAdded: '0.33'
1683
+ VersionChanged: '0.83'
1684
+
1685
+ Style/OptionalBooleanParameter:
1686
+ Description: 'Use keyword arguments when defining method with boolean argument.'
1687
+ StyleGuide: '#boolean-keyword-arguments'
1688
+ Enabled: false
1689
+ Safe: false
1690
+ VersionAdded: '0.89'
1691
+ AllowedMethods:
1692
+ - respond_to_missing?
1693
+
1694
+ Style/OrAssignment:
1695
+ Description: 'Recommend usage of double pipe equals (||=) where applicable.'
1696
+ StyleGuide: '#double-pipe-for-uninit'
1697
+ Enabled: true
1698
+ VersionAdded: '0.50'
1699
+
1700
+ Style/ParallelAssignment:
1701
+ Description: >-
1702
+ Check for simple usages of parallel assignment.
1703
+ It will only warn when the number of variables
1704
+ matches on both sides of the assignment.
1705
+ StyleGuide: '#parallel-assignment'
1706
+ Enabled: true
1707
+ VersionAdded: '0.32'
1708
+
1709
+ Style/ParenthesesAroundCondition:
1710
+ Description: >-
1711
+ Don't use parentheses around the condition of an
1712
+ if/unless/while.
1713
+ StyleGuide: '#no-parens-around-condition'
1714
+ Enabled: true
1715
+ VersionAdded: '0.9'
1716
+ VersionChanged: '0.56'
1717
+ AllowSafeAssignment: true
1718
+ AllowInMultilineConditions: false
1719
+
1720
+ Style/PercentLiteralDelimiters:
1721
+ Description: 'Use `%`-literal delimiters consistently.'
1722
+ StyleGuide: '#percent-literal-braces'
1723
+ Enabled: true
1724
+ VersionAdded: '0.19'
1725
+ # Specify the default preferred delimiter for all types with the 'default' key
1726
+ # Override individual delimiters (even with default specified) by specifying
1727
+ # an individual key
1728
+ PreferredDelimiters:
1729
+ default: '[]'
1730
+ VersionChanged: '0.48'
1731
+
1732
+ Style/PercentQLiterals:
1733
+ Description: 'Checks if uses of %Q/%q match the configured preference.'
1734
+ Enabled: true
1735
+ VersionAdded: '0.25'
1736
+ EnforcedStyle: lower_case_q
1737
+ SupportedStyles:
1738
+ - lower_case_q # Use `%q` when possible, `%Q` when necessary
1739
+ - upper_case_q # Always use `%Q`
1740
+
1741
+ Style/PerlBackrefs:
1742
+ Description: 'Avoid Perl-style regex back references.'
1743
+ StyleGuide: '#no-perl-regexp-last-matchers'
1744
+ Enabled: true
1745
+ VersionAdded: '0.13'
1746
+
1747
+ Style/PreferredHashMethods:
1748
+ Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
1749
+ StyleGuide: '#hash-key'
1750
+ Enabled: false
1751
+ Safe: false
1752
+ VersionAdded: '0.41'
1753
+ VersionChanged: '0.70'
1754
+ EnforcedStyle: short
1755
+ SupportedStyles:
1756
+ - short
1757
+ - verbose
1758
+
1759
+ Style/Proc:
1760
+ Description: 'Use proc instead of Proc.new.'
1761
+ StyleGuide: '#proc'
1762
+ Enabled: true
1763
+ VersionAdded: '0.9'
1764
+ VersionChanged: '0.18'
1765
+
1766
+ Style/QuotedSymbols:
1767
+ Description: 'Use a consistent style for quoted symbols.'
1768
+ Enabled: true
1769
+ VersionAdded: '1.16'
1770
+ EnforcedStyle: same_as_string_literals
1771
+ SupportedStyles:
1772
+ - same_as_string_literals
1773
+ - single_quotes
1774
+ - double_quotes
1775
+
1776
+ Style/RaiseArgs:
1777
+ Description: 'Checks the arguments passed to raise/fail.'
1778
+ StyleGuide: '#exception-class-messages'
1779
+ Enabled: true
1780
+ VersionAdded: '0.14'
1781
+ VersionChanged: '1.2'
1782
+ EnforcedStyle: exploded
1783
+ SupportedStyles:
1784
+ - compact # raise Exception.new(msg)
1785
+ - exploded # raise Exception, msg
1786
+ AllowedCompactTypes: [ ]
1787
+
1788
+ Style/RandomWithOffset:
1789
+ Description: >-
1790
+ Prefer to use ranges when generating random numbers instead of
1791
+ integers with offsets.
1792
+ StyleGuide: '#random-numbers'
1793
+ Enabled: true
1794
+ VersionAdded: '0.52'
1795
+
1796
+ Style/RedundantArgument:
1797
+ Description: 'Check for a redundant argument passed to certain methods.'
1798
+ Enabled: true
1799
+ Safe: false
1800
+ VersionAdded: '1.4'
1801
+ VersionChanged: '1.40'
1802
+ Methods:
1803
+ # Array#sum
1804
+ sum: 0
1805
+ join:
1806
+ split:
1807
+ chomp:
1808
+ chomp!:
1809
+
1810
+ Style/RedundantAssignment:
1811
+ Description: 'Checks for redundant assignment before returning.'
1812
+ Enabled: true
1813
+ VersionAdded: '0.87'
1814
+
1815
+ Style/RedundantBegin:
1816
+ Description: "Don't use begin blocks when they are not needed."
1817
+ StyleGuide: '#begin-implicit'
1818
+ Enabled: true
1819
+ VersionAdded: '0.10'
1820
+ VersionChanged: '0.21'
1821
+
1822
+ Style/RedundantCapitalW:
1823
+ Description: 'Checks for %W when interpolation is not needed.'
1824
+ Enabled: true
1825
+ VersionAdded: '0.76'
1826
+
1827
+ Style/RedundantCondition:
1828
+ Description: 'Checks for unnecessary conditional expressions.'
1829
+ Enabled: true
1830
+ VersionAdded: '0.76'
1831
+
1832
+ Style/RedundantConditional:
1833
+ Description: "Don't return true/false from a conditional."
1834
+ Enabled: true
1835
+ VersionAdded: '0.50'
1836
+
1837
+ <% if RuboCop::Version.document_version.to_f >= 1.40 %>
1838
+ Style/RedundantConstantBase:
1839
+ Description: Avoid redundant `::` prefix on constant.
1840
+ Enabled: true
1841
+ VersionAdded: '1.40'
1842
+ <% end %>
1843
+
1844
+ <% if RuboCop::Version.document_version.to_f >= 1.41 %>
1845
+ Style/RedundantDoubleSplatHashBraces:
1846
+ Description: 'Checks for redundant uses of double splat hash braces.'
1847
+ Enabled: true
1848
+ VersionAdded: '1.41'
1849
+ <% end %>
1850
+
1851
+ Style/RedundantEach:
1852
+ Description: 'Checks for redundant `each`.'
1853
+ Enabled: true
1854
+ Safe: false
1855
+ VersionAdded: '1.38'
1856
+
1857
+ Style/RedundantException:
1858
+ Description: "Checks for an obsolete RuntimeException argument in raise/fail."
1859
+ StyleGuide: '#no-explicit-runtimeerror'
1860
+ Enabled: true
1861
+ VersionAdded: '0.14'
1862
+ VersionChanged: '0.29'
1863
+
1864
+ Style/RedundantFetchBlock:
1865
+ Description: >-
1866
+ Use `fetch(key, value)` instead of `fetch(key) { value }`
1867
+ when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
1868
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
1869
+ Enabled: true
1870
+ Safe: false
1871
+ # If enabled, this cop will autocorrect usages of
1872
+ # `fetch` being called with block returning a constant.
1873
+ # This can be dangerous since constants will not be defined at that moment.
1874
+ SafeForConstants: false
1875
+ VersionAdded: '0.86'
1876
+
1877
+ Style/RedundantFileExtensionInRequire:
1878
+ Description: >-
1879
+ Checks for the presence of superfluous `.rb` extension in
1880
+ the filename provided to `require` and `require_relative`.
1881
+ StyleGuide: '#no-explicit-rb-to-require'
1882
+ Enabled: true
1883
+ VersionAdded: '0.88'
1884
+
1885
+ Style/RedundantFreeze:
1886
+ Description: "Checks usages of Object#freeze on immutable objects."
1887
+ Enabled: true
1888
+ VersionAdded: '0.34'
1889
+ VersionChanged: '0.66'
1890
+
1891
+ <% if RuboCop::Version.document_version.to_f >= 1.45 %>
1892
+ Style/RedundantHeredocDelimiterQuotes:
1893
+ Description: 'Checks for redundant heredoc delimiter quotes.'
1894
+ Enabled: true
1895
+ VersionAdded: '1.45'
1896
+ <% end %>
1897
+
1898
+ Style/RedundantInitialize:
1899
+ Description: 'Checks for redundant `initialize` methods.'
1900
+ Enabled: true
1901
+ Safe: false
1902
+ AllowComments: true
1903
+ VersionAdded: '1.27'
1904
+ VersionChanged: '1.28'
1905
+
1906
+ Style/RedundantInterpolation:
1907
+ Description: 'Checks for strings that are just an interpolated expression.'
1908
+ Enabled: true
1909
+ SafeAutoCorrect: false
1910
+ VersionAdded: '0.76'
1911
+ VersionChanged: '1.30'
1912
+
1913
+ Style/RedundantLineContinuation:
1914
+ Description: Check for redundant line continuation.
1915
+ Enabled: true
1916
+ VersionAdded: '1.49'
1917
+
1918
+ Style/RedundantParentheses:
1919
+ Description: "Checks for parentheses that seem not to serve any purpose."
1920
+ Enabled: true
1921
+ VersionAdded: '0.36'
1922
+
1923
+ Style/RedundantPercentQ:
1924
+ Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
1925
+ StyleGuide: '#percent-q'
1926
+ Enabled: true
1927
+ VersionAdded: '0.76'
1928
+
1929
+ Style/RedundantRegexpCharacterClass:
1930
+ Description: 'Checks for unnecessary single-element Regexp character classes.'
1931
+ Enabled: true
1932
+ VersionAdded: '0.85'
1933
+
1934
+ Style/RedundantRegexpEscape:
1935
+ Description: 'Checks for redundant escapes in Regexps.'
1936
+ Enabled: true
1937
+ VersionAdded: '0.85'
1938
+
1939
+ Style/RedundantReturn:
1940
+ Description: "Don't use return where it's not required."
1941
+ StyleGuide: '#no-explicit-return'
1942
+ Enabled: false
1943
+ VersionAdded: '0.10'
1944
+ VersionChanged: '0.14'
1945
+ # When `true` allows code like `return x, y`.
1946
+ AllowMultipleReturnValues: false
1947
+
1948
+ Style/RedundantSelf:
1949
+ Description: "Don't use self where it's not needed."
1950
+ StyleGuide: '#no-self-unless-required'
1951
+ Enabled: true
1952
+ VersionAdded: '0.10'
1953
+ VersionChanged: '0.13'
1954
+
1955
+ Style/RedundantSelfAssignment:
1956
+ Description: 'Checks for places where redundant assignments are made for in place modification methods.'
1957
+ Enabled: true
1958
+ Safe: false
1959
+ VersionAdded: '0.90'
1960
+
1961
+ Style/RedundantSelfAssignmentBranch:
1962
+ Description: 'Checks for places where conditional branch makes redundant self-assignment.'
1963
+ Enabled: true
1964
+ VersionAdded: '1.19'
1965
+
1966
+ Style/RedundantSort:
1967
+ Description: >-
1968
+ Use `min` instead of `sort.first`,
1969
+ `max_by` instead of `sort_by...last`, etc.
1970
+ Enabled: true
1971
+ VersionAdded: '0.76'
1972
+ VersionChanged: '1.22'
1973
+ Safe: false
1974
+
1975
+ Style/RedundantSortBy:
1976
+ Description: 'Use `sort` instead of `sort_by { |x| x }`.'
1977
+ Enabled: true
1978
+ VersionAdded: '0.36'
1979
+
1980
+ Style/RedundantStringEscape:
1981
+ Description: 'Checks for redundant escapes in string literals.'
1982
+ Enabled: true
1983
+ VersionAdded: '1.37'
1984
+
1985
+ Style/RegexpLiteral:
1986
+ Description: 'Use / or %r around regular expressions.'
1987
+ StyleGuide: '#percent-r'
1988
+ Enabled: true
1989
+ VersionAdded: '0.9'
1990
+ VersionChanged: '0.30'
1991
+ EnforcedStyle: slashes
1992
+ # slashes: Always use slashes.
1993
+ # percent_r: Always use `%r`.
1994
+ # mixed: Use slashes on single-line regexes, and `%r` on multi-line regexes.
1995
+ SupportedStyles:
1996
+ - slashes
1997
+ - percent_r
1998
+ - mixed
1999
+ # If `false`, the cop will always recommend using `%r` if one or more slashes
2000
+ # are found in the regexp string.
2001
+ AllowInnerSlashes: false
2002
+
2003
+ <% if RuboCop::Version.document_version.to_f >= 1.40 %>
2004
+ Style/RequireOrder:
2005
+ Description: Sort `require` and `require_relative` in alphabetical order.
2006
+ Enabled: true
2007
+ SafeAutoCorrect: false
2008
+ VersionAdded: '1.40'
2009
+ <% end %>
2010
+
2011
+ Style/RescueModifier:
2012
+ Description: 'Avoid using rescue in its modifier form.'
2013
+ StyleGuide: '#no-rescue-modifiers'
2014
+ Enabled: true
2015
+ VersionAdded: '0.9'
2016
+ VersionChanged: '0.34'
2017
+
2018
+ Style/RescueStandardError:
2019
+ Description: 'Avoid rescuing without specifying an error class.'
2020
+ Enabled: true
2021
+ VersionAdded: '0.52'
2022
+ EnforcedStyle: implicit
2023
+ # implicit: Do not include the error class, `rescue`
2024
+ # explicit: Require an error class `rescue StandardError`
2025
+ SupportedStyles:
2026
+ - implicit
2027
+ - explicit
2028
+
2029
+ Style/ReturnNil:
2030
+ Description: 'Use return instead of return nil.'
2031
+ Enabled: false
2032
+ EnforcedStyle: return
2033
+ SupportedStyles:
2034
+ - return
2035
+ - return_nil
2036
+ VersionAdded: '0.50'
2037
+
2038
+ Style/SafeNavigation:
2039
+ Description: >-
2040
+ Transforms usages of a method call safeguarded by
2041
+ a check for the existence of the object to
2042
+ safe navigation (`&.`).
2043
+ Autocorrection is unsafe as it assumes the object will
2044
+ be `nil` or truthy, but never `false`.
2045
+ Enabled: true
2046
+ VersionAdded: '0.43'
2047
+ VersionChanged: '1.27'
2048
+ # Safe navigation may cause a statement to start returning `nil` in addition
2049
+ # to whatever it used to return.
2050
+ ConvertCodeThatCanStartToReturnNil: false
2051
+ AllowedMethods:
2052
+ - present?
2053
+ - blank?
2054
+ - presence
2055
+ - try
2056
+ - try!
2057
+ SafeAutoCorrect: false
2058
+ # Maximum length of method chains for register an offense.
2059
+ MaxChainLength: 2
2060
+
2061
+ Style/Sample:
2062
+ Description: >-
2063
+ Use `sample` instead of `shuffle.first`,
2064
+ `shuffle.last`, and `shuffle[Integer]`.
2065
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
2066
+ Enabled: true
2067
+ VersionAdded: '0.30'
2068
+
2069
+ Style/SelectByRegexp:
2070
+ Description: 'Prefer grep/grep_v to select/reject with a regexp match.'
2071
+ Enabled: true
2072
+ SafeAutoCorrect: false
2073
+ VersionAdded: '1.22'
2074
+
2075
+ Style/SelfAssignment:
2076
+ Description: >-
2077
+ Checks for places where self-assignment shorthand should have
2078
+ been used.
2079
+ StyleGuide: '#self-assignment'
2080
+ Enabled: true
2081
+ VersionAdded: '0.19'
2082
+ VersionChanged: '0.29'
2083
+
2084
+ Style/Semicolon:
2085
+ Description: "Don't use semicolons to terminate expressions."
2086
+ StyleGuide: '#no-semicolon'
2087
+ Enabled: true
2088
+ VersionAdded: '0.9'
2089
+ VersionChanged: '0.19'
2090
+ # Allow `;` to separate several expressions on the same line.
2091
+ AllowAsExpressionSeparator: false
2092
+
2093
+ Style/Send:
2094
+ Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
2095
+ StyleGuide: '#prefer-public-send'
2096
+ Enabled: true
2097
+ VersionAdded: '0.33'
2098
+
2099
+ Style/SignalException:
2100
+ Description: 'Checks for proper usage of fail and raise.'
2101
+ StyleGuide: '#prefer-raise-over-fail'
2102
+ Enabled: true
2103
+ VersionAdded: '0.11'
2104
+ VersionChanged: '0.37'
2105
+ EnforcedStyle: only_raise
2106
+ SupportedStyles:
2107
+ - only_raise
2108
+ - only_fail
2109
+ - semantic
2110
+
2111
+ Style/SingleArgumentDig:
2112
+ Description: 'Avoid using single argument dig method.'
2113
+ Enabled: false
2114
+ VersionAdded: '0.89'
2115
+ Safe: false
2116
+
2117
+ Style/SingleLineBlockParams:
2118
+ Description: 'Enforces the names of some block params.'
2119
+ Enabled: false
2120
+ VersionAdded: '0.16'
2121
+ VersionChanged: '1.6'
2122
+ Methods:
2123
+ - reduce:
2124
+ - acc
2125
+ - elem
2126
+ - inject:
2127
+ - acc
2128
+ - elem
2129
+
2130
+ Style/SingleLineMethods:
2131
+ Description: 'Avoid single-line methods.'
2132
+ StyleGuide: '#no-single-line-methods'
2133
+ Enabled: true
2134
+ VersionAdded: '0.9'
2135
+ VersionChanged: '1.8'
2136
+ AllowIfMethodIsEmpty: true
2137
+
2138
+ Style/SlicingWithRange:
2139
+ Description: 'Checks array slicing is done with endless ranges when suitable.'
2140
+ Enabled: true
2141
+ VersionAdded: '0.83'
2142
+ Safe: false
2143
+
2144
+ Style/SoleNestedConditional:
2145
+ Description: >-
2146
+ Finds sole nested conditional nodes
2147
+ which can be merged into outer conditional node.
2148
+ Enabled: true
2149
+ VersionAdded: '0.89'
2150
+ VersionChanged: '1.5'
2151
+ AllowModifier: true
2152
+
2153
+ Style/SpecialGlobalVars:
2154
+ Description: 'Avoid Perl-style global variables.'
2155
+ StyleGuide: '#no-cryptic-perlisms'
2156
+ Enabled: true
2157
+ VersionAdded: '0.13'
2158
+ VersionChanged: '0.36'
2159
+ SafeAutoCorrect: false
2160
+ RequireEnglish: true
2161
+ EnforcedStyle: use_english_names
2162
+ SupportedStyles:
2163
+ - use_perl_names
2164
+ - use_english_names
2165
+ - use_builtin_english_names
2166
+
2167
+ Style/StabbyLambdaParentheses:
2168
+ Description: 'Check for the usage of parentheses around stabby lambda arguments.'
2169
+ StyleGuide: '#stabby-lambda-with-args'
2170
+ Enabled: true
2171
+ VersionAdded: '0.35'
2172
+ EnforcedStyle: require_parentheses
2173
+ SupportedStyles:
2174
+ - require_parentheses
2175
+ - require_no_parentheses
2176
+
2177
+ Style/StaticClass:
2178
+ Description: 'Prefer modules to classes with only class methods.'
2179
+ StyleGuide: '#modules-vs-classes'
2180
+ Enabled: true
2181
+ Safe: false
2182
+ VersionAdded: '1.3'
2183
+
2184
+ Style/StderrPuts:
2185
+ Description: 'Use `warn` instead of `$stderr.puts`.'
2186
+ StyleGuide: '#warn'
2187
+ Enabled: true
2188
+ VersionAdded: '0.51'
2189
+
2190
+ Style/StringChars:
2191
+ Description: 'Checks for uses of `String#split` with empty string or regexp literal argument.'
2192
+ StyleGuide: '#string-chars'
2193
+ Enabled: true
2194
+ Safe: false
2195
+ VersionAdded: '1.12'
2196
+
2197
+ Style/StringConcatenation:
2198
+ Description: 'Checks for places where string concatenation can be replaced with string interpolation.'
2199
+ StyleGuide: '#string-interpolation'
2200
+ Enabled: true
2201
+ Safe: false
2202
+ VersionAdded: '0.89'
2203
+ VersionChanged: '1.18'
2204
+ Mode: aggressive
2205
+
2206
+ Style/StringHashKeys:
2207
+ Description: 'Prefer symbols instead of strings as hash keys.'
2208
+ StyleGuide: '#symbols-as-keys'
2209
+ Enabled: false
2210
+ VersionAdded: '0.52'
2211
+ VersionChanged: '0.75'
2212
+ Safe: false
2213
+
2214
+ Style/StringLiterals:
2215
+ Description: 'Checks if uses of quotes match the configured preference.'
2216
+ StyleGuide: '#consistent-string-literals'
2217
+ Enabled: true
2218
+ VersionAdded: '0.9'
2219
+ VersionChanged: '0.36'
2220
+ EnforcedStyle: single_quotes
2221
+ SupportedStyles:
2222
+ - single_quotes
2223
+ - double_quotes
2224
+ # If `true`, strings which span multiple lines using `\` for continuation must
2225
+ # use the same type of quotes on each line.
2226
+ ConsistentQuotesInMultiline: false
2227
+
2228
+ Style/StringLiteralsInInterpolation:
2229
+ Description: >-
2230
+ Checks if uses of quotes inside expressions in interpolated
2231
+ strings match the configured preference.
2232
+ Enabled: true
2233
+ VersionAdded: '0.27'
2234
+ EnforcedStyle: single_quotes
2235
+ SupportedStyles:
2236
+ - single_quotes
2237
+ - double_quotes
2238
+
2239
+ Style/StringMethods:
2240
+ Description: 'Checks if configured preferred methods are used over non-preferred.'
2241
+ Enabled: true
2242
+ VersionAdded: '0.34'
2243
+ VersionChanged: '0.34'
2244
+ # Mapping from undesired method to desired_method
2245
+ # e.g. to use `to_sym` over `intern`:
2246
+ #
2247
+ # StringMethods:
2248
+ # PreferredMethods:
2249
+ # intern: to_sym
2250
+ PreferredMethods:
2251
+ intern: to_sym
2252
+
2253
+ Style/Strip:
2254
+ Description: 'Use `strip` instead of `lstrip.rstrip`.'
2255
+ Enabled: true
2256
+ VersionAdded: '0.36'
2257
+
2258
+ Style/StructInheritance:
2259
+ Description: 'Checks for inheritance from Struct.new.'
2260
+ StyleGuide: '#no-extend-struct-new'
2261
+ Enabled: true
2262
+ SafeAutoCorrect: false
2263
+ VersionAdded: '0.29'
2264
+ VersionChanged: '1.20'
2265
+
2266
+ Style/SwapValues:
2267
+ Description: 'Enforces the use of shorthand-style swapping of 2 variables.'
2268
+ StyleGuide: '#values-swapping'
2269
+ Enabled: true
2270
+ VersionAdded: '1.1'
2271
+ SafeAutoCorrect: false
2272
+
2273
+ Style/SymbolArray:
2274
+ Description: 'Use %i or %I for arrays of symbols.'
2275
+ StyleGuide: '#percent-i'
2276
+ Enabled: true
2277
+ VersionAdded: '0.9'
2278
+ VersionChanged: '0.49'
2279
+ EnforcedStyle: percent
2280
+ MinSize: 2
2281
+ SupportedStyles:
2282
+ - percent
2283
+ - brackets
2284
+
2285
+ Style/SymbolLiteral:
2286
+ Description: 'Use plain symbols instead of string symbols when possible.'
2287
+ Enabled: true
2288
+ VersionAdded: '0.30'
2289
+
2290
+ Style/SymbolProc:
2291
+ Description: 'Use symbols as procs instead of blocks when possible.'
2292
+ Enabled: true
2293
+ Safe: false
2294
+ VersionAdded: '0.26'
2295
+ VersionChanged: '1.40'
2296
+ AllowMethodsWithArguments: false
2297
+ # A list of method names to be always allowed by the check.
2298
+ # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
2299
+ AllowedMethods:
2300
+ - define_method
2301
+ AllowedPatterns: [ ]
2302
+ AllowComments: false
2303
+
2304
+ Style/TernaryParentheses:
2305
+ Description: 'Checks for use of parentheses around ternary conditions.'
2306
+ Enabled: true
2307
+ VersionAdded: '0.42'
2308
+ VersionChanged: '0.46'
2309
+ EnforcedStyle: require_parentheses_when_complex
2310
+ SupportedStyles:
2311
+ - require_parentheses
2312
+ - require_no_parentheses
2313
+ - require_parentheses_when_complex
2314
+ AllowSafeAssignment: false
2315
+
2316
+ Style/TopLevelMethodDefinition:
2317
+ Description: 'Looks for top-level method definitions.'
2318
+ StyleGuide: '#top-level-methods'
2319
+ Enabled: false
2320
+ VersionAdded: '1.15'
2321
+
2322
+ Style/TrailingBodyOnClass:
2323
+ Description: 'Class body goes below class statement.'
2324
+ Enabled: true
2325
+ VersionAdded: '0.53'
2326
+
2327
+ Style/TrailingBodyOnMethodDefinition:
2328
+ Description: 'Method body goes below definition.'
2329
+ Enabled: true
2330
+ VersionAdded: '0.52'
2331
+
2332
+ Style/TrailingBodyOnModule:
2333
+ Description: 'Module body goes below module statement.'
2334
+ Enabled: true
2335
+ VersionAdded: '0.53'
2336
+
2337
+ Style/TrailingCommaInArguments:
2338
+ Description: 'Checks for trailing comma in argument lists.'
2339
+ StyleGuide: '#no-trailing-params-comma'
2340
+ Enabled: true
2341
+ VersionAdded: '0.36'
2342
+ # If `comma`, the cop requires a comma after the last argument, but only for
2343
+ # parenthesized method calls where each argument is on its own line.
2344
+ # If `consistent_comma`, the cop requires a comma after the last argument,
2345
+ # for all parenthesized method calls with arguments.
2346
+ EnforcedStyleForMultiline: no_comma
2347
+ SupportedStylesForMultiline:
2348
+ - comma
2349
+ - consistent_comma
2350
+ - no_comma
2351
+
2352
+ Style/TrailingCommaInArrayLiteral:
2353
+ Description: 'Checks for trailing comma in array literals.'
2354
+ StyleGuide: '#no-trailing-array-commas'
2355
+ Enabled: true
2356
+ VersionAdded: '0.53'
2357
+ # If `comma`, the cop requires a comma after the last item in an array,
2358
+ # but only when each item is on its own line.
2359
+ # If `consistent_comma`, the cop requires a comma after the last item of all
2360
+ # non-empty, multiline array literals.
2361
+ EnforcedStyleForMultiline: no_comma
2362
+ SupportedStylesForMultiline:
2363
+ - comma
2364
+ - consistent_comma
2365
+ - no_comma
2366
+
2367
+ Style/TrailingCommaInBlockArgs:
2368
+ Description: 'Checks for useless trailing commas in block arguments.'
2369
+ Enabled: true
2370
+ Safe: false
2371
+ VersionAdded: '0.81'
2372
+
2373
+ Style/TrailingCommaInHashLiteral:
2374
+ Description: 'Checks for trailing comma in hash literals.'
2375
+ Enabled: true
2376
+ # If `comma`, the cop requires a comma after the last item in a hash,
2377
+ # but only when each item is on its own line.
2378
+ # If `consistent_comma`, the cop requires a comma after the last item of all
2379
+ # non-empty, multiline hash literals.
2380
+ EnforcedStyleForMultiline: no_comma
2381
+ SupportedStylesForMultiline:
2382
+ - comma
2383
+ - consistent_comma
2384
+ - no_comma
2385
+ VersionAdded: '0.53'
2386
+
2387
+ Style/TrailingMethodEndStatement:
2388
+ Description: 'Checks for trailing end statement on line of method body.'
2389
+ Enabled: true
2390
+ VersionAdded: '0.52'
2391
+
2392
+ Style/TrailingUnderscoreVariable:
2393
+ Description: >-
2394
+ Checks for the usage of unneeded trailing underscores at the
2395
+ end of parallel variable assignment.
2396
+ AllowNamedUnderscoreVariables: true
2397
+ Enabled: true
2398
+ VersionAdded: '0.31'
2399
+ VersionChanged: '0.35'
2400
+
2401
+ # `TrivialAccessors` requires exact name matches and doesn't allow
2402
+ # predicated methods by default.
2403
+ Style/TrivialAccessors:
2404
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
2405
+ StyleGuide: '#attr_family'
2406
+ Enabled: true
2407
+ VersionAdded: '0.9'
2408
+ VersionChanged: '1.15'
2409
+ # When set to `false` the cop will suggest the use of accessor methods
2410
+ # in situations like:
2411
+ #
2412
+ # def name
2413
+ # @other_name
2414
+ # end
2415
+ #
2416
+ # This way you can uncover "hidden" attributes in your code.
2417
+ ExactNameMatch: true
2418
+ AllowPredicates: true
2419
+ # Allows trivial writers that don't end in an equal sign. e.g.
2420
+ #
2421
+ # def on_exception(action)
2422
+ # @on_exception=action
2423
+ # end
2424
+ # on_exception :restart
2425
+ #
2426
+ # Commonly used in DSLs
2427
+ AllowDSLWriters: true
2428
+ IgnoreClassMethods: false
2429
+ AllowedMethods:
2430
+ - to_ary
2431
+ - to_a
2432
+ - to_c
2433
+ - to_enum
2434
+ - to_h
2435
+ - to_hash
2436
+ - to_i
2437
+ - to_int
2438
+ - to_io
2439
+ - to_open
2440
+ - to_path
2441
+ - to_proc
2442
+ - to_r
2443
+ - to_regexp
2444
+ - to_str
2445
+ - to_s
2446
+ - to_sym
2447
+
2448
+ Style/UnlessElse:
2449
+ Description: >-
2450
+ Do not use unless with else. Rewrite these with the positive
2451
+ case first.
2452
+ StyleGuide: '#no-else-with-unless'
2453
+ Enabled: true
2454
+ VersionAdded: '0.9'
2455
+
2456
+ Style/UnlessLogicalOperators:
2457
+ Description: >-
2458
+ Checks for use of logical operators in an unless condition.
2459
+ Enabled: true
2460
+ VersionAdded: '1.11'
2461
+ EnforcedStyle: forbid_logical_operators
2462
+ SupportedStyles:
2463
+ - forbid_mixed_logical_operators
2464
+ - forbid_logical_operators
2465
+
2466
+ Style/UnpackFirst:
2467
+ Description: >-
2468
+ Checks for accessing the first element of `String#unpack`
2469
+ instead of using `unpack1`.
2470
+ Enabled: true
2471
+ VersionAdded: '0.54'
2472
+
2473
+ Style/VariableInterpolation:
2474
+ Description: >-
2475
+ Don't interpolate global, instance and class variables
2476
+ directly in strings.
2477
+ StyleGuide: '#curlies-interpolate'
2478
+ Enabled: true
2479
+ VersionAdded: '0.9'
2480
+ VersionChanged: '0.20'
2481
+
2482
+ Style/WhenThen:
2483
+ Description: 'Use when x then ... for one-line cases.'
2484
+ StyleGuide: '#no-when-semicolons'
2485
+ Enabled: true
2486
+ VersionAdded: '0.9'
2487
+
2488
+ Style/WhileUntilDo:
2489
+ Description: 'Checks for redundant do after while or until.'
2490
+ StyleGuide: '#no-multiline-while-do'
2491
+ Enabled: true
2492
+ VersionAdded: '0.9'
2493
+
2494
+ Style/WhileUntilModifier:
2495
+ Description: >-
2496
+ Favor modifier while/until usage when you have a
2497
+ single-line body.
2498
+ StyleGuide: '#while-as-a-modifier'
2499
+ Enabled: false
2500
+ VersionAdded: '0.9'
2501
+ VersionChanged: '0.30'
2502
+
2503
+ Style/WordArray:
2504
+ Description: 'Use %w or %W for arrays of words.'
2505
+ StyleGuide: '#percent-w'
2506
+ Enabled: true
2507
+ VersionAdded: '0.9'
2508
+ VersionChanged: '1.19'
2509
+ EnforcedStyle: percent
2510
+ SupportedStyles:
2511
+ # percent style: %w(word1 word2)
2512
+ - percent
2513
+ # bracket style: ['word1', 'word2']
2514
+ - brackets
2515
+ # The `MinSize` option causes the `WordArray` rule to be ignored for arrays
2516
+ # smaller than a certain size. The rule is only applied to arrays
2517
+ # whose element count is greater than or equal to `MinSize`.
2518
+ MinSize: 2
2519
+ # The regular expression `WordRegex` decides what is considered a word.
2520
+ WordRegex: !ruby/regexp '/\A(?:\p{Word}|\p{Word}-\p{Word}|\n|\t)+\z/'
2521
+
2522
+ Style/YodaCondition:
2523
+ Description: 'Forbid or enforce yoda conditions.'
2524
+ Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
2525
+ Enabled: false
2526
+ EnforcedStyle: forbid_for_all_comparison_operators
2527
+ SupportedStyles:
2528
+ # check all comparison operators
2529
+ - forbid_for_all_comparison_operators
2530
+ # check only equality operators: `!=` and `==`
2531
+ - forbid_for_equality_operators_only
2532
+ # enforce yoda for all comparison operators
2533
+ - require_for_all_comparison_operators
2534
+ # enforce yoda only for equality operators: `!=` and `==`
2535
+ - require_for_equality_operators_only
2536
+ Safe: false
2537
+ VersionAdded: '0.49'
2538
+ VersionChanged: '0.75'
2539
+
2540
+ Style/ZeroLengthPredicate:
2541
+ Description: 'Use #empty? when testing for objects of length 0.'
2542
+ Enabled: true
2543
+ Safe: false
2544
+ VersionAdded: '0.37'
2545
+ VersionChanged: '0.39'