chefstyle 0.11.2 → 0.12.0

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