rubocop 0.59.2 → 0.60.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +3 -2
  3. data/config/default.yml +2960 -552
  4. data/lib/rubocop.rb +1 -0
  5. data/lib/rubocop/ast/builder.rb +29 -29
  6. data/lib/rubocop/ast/node.rb +29 -25
  7. data/lib/rubocop/ast/node/args_node.rb +1 -1
  8. data/lib/rubocop/ast/node/mixin/binary_operator_node.rb +1 -1
  9. data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +26 -0
  10. data/lib/rubocop/ast/node/mixin/method_identifier_predicates.rb +5 -1
  11. data/lib/rubocop/ast/node/pair_node.rb +8 -1
  12. data/lib/rubocop/ast/node/str_node.rb +1 -1
  13. data/lib/rubocop/cached_data.rb +2 -2
  14. data/lib/rubocop/config.rb +1 -1
  15. data/lib/rubocop/config_loader.rb +8 -0
  16. data/lib/rubocop/cop/autocorrect_logic.rb +7 -1
  17. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
  18. data/lib/rubocop/cop/correctors/alignment_corrector.rb +2 -1
  19. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +1 -1
  20. data/lib/rubocop/cop/generator.rb +10 -3
  21. data/lib/rubocop/cop/generator/require_file_injector.rb +1 -1
  22. data/lib/rubocop/cop/internal_affairs/node_destructuring.rb +1 -1
  23. data/lib/rubocop/cop/layout/align_hash.rb +9 -1
  24. data/lib/rubocop/cop/layout/block_end_newline.rb +2 -4
  25. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +7 -7
  26. data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
  27. data/lib/rubocop/cop/layout/dot_position.rb +2 -2
  28. data/lib/rubocop/cop/layout/else_alignment.rb +1 -1
  29. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +1 -2
  30. data/lib/rubocop/cop/layout/empty_lines.rb +1 -1
  31. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +25 -25
  32. data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +1 -1
  33. data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +1 -1
  34. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -1
  35. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +1 -1
  36. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +1 -1
  37. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +1 -1
  38. data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +1 -1
  39. data/lib/rubocop/cop/layout/end_alignment.rb +1 -1
  40. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
  41. data/lib/rubocop/cop/layout/indent_hash.rb +1 -1
  42. data/lib/rubocop/cop/layout/indent_heredoc.rb +2 -2
  43. data/lib/rubocop/cop/layout/indentation_consistency.rb +1 -1
  44. data/lib/rubocop/cop/layout/indentation_width.rb +1 -1
  45. data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
  46. data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +1 -1
  47. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +1 -1
  48. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +84 -43
  49. data/lib/rubocop/cop/layout/space_after_method_name.rb +1 -1
  50. data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
  51. data/lib/rubocop/cop/layout/space_around_operators.rb +3 -2
  52. data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +1 -1
  53. data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +2 -2
  54. data/lib/rubocop/cop/lint/ambiguous_operator.rb +5 -5
  55. data/lib/rubocop/cop/lint/assignment_in_condition.rb +10 -20
  56. data/lib/rubocop/cop/lint/ensure_return.rb +3 -0
  57. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +3 -3
  58. data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -1
  59. data/lib/rubocop/cop/lint/percent_string_array.rb +2 -2
  60. data/lib/rubocop/cop/lint/percent_symbol_array.rb +10 -7
  61. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +3 -4
  62. data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -2
  63. data/lib/rubocop/cop/lint/syntax.rb +3 -2
  64. data/lib/rubocop/cop/lint/uri_escape_unescape.rb +3 -3
  65. data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -7
  66. data/lib/rubocop/cop/metrics/abc_size.rb +1 -17
  67. data/lib/rubocop/cop/metrics/line_length.rb +14 -10
  68. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +45 -0
  69. data/lib/rubocop/cop/mixin/check_assignment.rb +12 -6
  70. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -1
  71. data/lib/rubocop/cop/mixin/configurable_formatting.rb +0 -2
  72. data/lib/rubocop/cop/mixin/configurable_max.rb +4 -2
  73. data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
  74. data/lib/rubocop/cop/mixin/configurable_numbering.rb +2 -2
  75. data/lib/rubocop/cop/mixin/hash_alignment.rb +32 -5
  76. data/lib/rubocop/cop/mixin/heredoc.rb +1 -1
  77. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +3 -4
  78. data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +1 -1
  79. data/lib/rubocop/cop/mixin/statement_modifier.rb +4 -0
  80. data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
  81. data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +1 -1
  82. data/lib/rubocop/cop/naming/constant_name.rb +1 -1
  83. data/lib/rubocop/cop/naming/file_name.rb +1 -1
  84. data/lib/rubocop/cop/naming/method_name.rb +2 -0
  85. data/lib/rubocop/cop/naming/variable_number.rb +1 -1
  86. data/lib/rubocop/cop/offense.rb +1 -1
  87. data/lib/rubocop/cop/performance/regexp_match.rb +1 -1
  88. data/lib/rubocop/cop/performance/sample.rb +3 -2
  89. data/lib/rubocop/cop/performance/start_with.rb +1 -1
  90. data/lib/rubocop/cop/performance/string_replacement.rb +1 -1
  91. data/lib/rubocop/cop/rails/date.rb +8 -8
  92. data/lib/rubocop/cop/rails/dynamic_find_by.rb +1 -1
  93. data/lib/rubocop/cop/rails/exit.rb +8 -9
  94. data/lib/rubocop/cop/rails/output_safety.rb +3 -3
  95. data/lib/rubocop/cop/rails/read_write_attribute.rb +5 -4
  96. data/lib/rubocop/cop/rails/refute_methods.rb +13 -13
  97. data/lib/rubocop/cop/rails/reversible_migration.rb +2 -1
  98. data/lib/rubocop/cop/rails/skips_model_validations.rb +17 -0
  99. data/lib/rubocop/cop/registry.rb +11 -2
  100. data/lib/rubocop/cop/style/and_or.rb +3 -3
  101. data/lib/rubocop/cop/style/collection_methods.rb +26 -0
  102. data/lib/rubocop/cop/style/empty_literal.rb +1 -1
  103. data/lib/rubocop/cop/style/encoding.rb +1 -1
  104. data/lib/rubocop/cop/style/even_odd.rb +2 -2
  105. data/lib/rubocop/cop/style/for.rb +3 -3
  106. data/lib/rubocop/cop/style/global_vars.rb +1 -1
  107. data/lib/rubocop/cop/style/identical_conditional_branches.rb +1 -1
  108. data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -13
  109. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  110. data/lib/rubocop/cop/style/inverse_methods.rb +1 -1
  111. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +4 -7
  112. data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
  113. data/lib/rubocop/cop/style/module_function.rb +1 -1
  114. data/lib/rubocop/cop/style/multiline_if_then.rb +1 -1
  115. data/lib/rubocop/cop/style/mutable_constant.rb +15 -1
  116. data/lib/rubocop/cop/style/nested_modifier.rb +1 -1
  117. data/lib/rubocop/cop/style/not.rb +2 -1
  118. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +6 -6
  119. data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
  120. data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
  121. data/lib/rubocop/cop/style/one_line_conditional.rb +2 -2
  122. data/lib/rubocop/cop/style/parentheses_around_condition.rb +1 -1
  123. data/lib/rubocop/cop/style/proc.rb +1 -1
  124. data/lib/rubocop/cop/style/redundant_freeze.rb +10 -0
  125. data/lib/rubocop/cop/style/redundant_parentheses.rb +6 -2
  126. data/lib/rubocop/cop/style/redundant_self.rb +1 -1
  127. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  128. data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
  129. data/lib/rubocop/cop/style/ternary_parentheses.rb +4 -3
  130. data/lib/rubocop/cop/style/unneeded_condition.rb +2 -2
  131. data/lib/rubocop/cop/style/unneeded_percent_q.rb +2 -2
  132. data/lib/rubocop/cop/style/unpack_first.rb +1 -1
  133. data/lib/rubocop/cop/team.rb +3 -2
  134. data/lib/rubocop/cop/util.rb +2 -22
  135. data/lib/rubocop/cop/variable_force/scope.rb +3 -3
  136. data/lib/rubocop/cop/variable_force/variable.rb +3 -4
  137. data/lib/rubocop/cop/variable_force/variable_table.rb +2 -2
  138. data/lib/rubocop/formatter/base_formatter.rb +3 -3
  139. data/lib/rubocop/formatter/disabled_config_formatter.rb +16 -1
  140. data/lib/rubocop/formatter/formatter_set.rb +14 -14
  141. data/lib/rubocop/formatter/html_formatter.rb +4 -4
  142. data/lib/rubocop/formatter/json_formatter.rb +13 -13
  143. data/lib/rubocop/formatter/simple_text_formatter.rb +4 -4
  144. data/lib/rubocop/magic_comment.rb +4 -4
  145. data/lib/rubocop/node_pattern.rb +17 -17
  146. data/lib/rubocop/options.rb +93 -82
  147. data/lib/rubocop/result_cache.rb +9 -1
  148. data/lib/rubocop/rspec/expect_offense.rb +2 -2
  149. data/lib/rubocop/rspec/shared_contexts.rb +11 -11
  150. data/lib/rubocop/rspec/shared_examples.rb +4 -4
  151. data/lib/rubocop/string_interpreter.rb +1 -1
  152. data/lib/rubocop/version.rb +1 -1
  153. metadata +6 -13
  154. data/config/disabled.yml +0 -161
  155. data/config/enabled.yml +0 -2092
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 28eeb813f59ba82f401cfac05daa5a118a1014af
4
- data.tar.gz: 63b3201d008b9f790f93cc5a724c1a596bd75dd4
2
+ SHA256:
3
+ metadata.gz: ee5ff0ea8f14348a06f12d9821d3d53fe6bae43f494d9963c474acf1f09d8926
4
+ data.tar.gz: 30955fdcca4ed2acb2b4ebfece201cab06dcaa61b354f7d7d1b54e796a41e6aa
5
5
  SHA512:
6
- metadata.gz: c79b61631cdc0e7fd9f0a8b17b0d04956827286239a7f65948e5a9cfec8f4a286dc1e6f062d9d0f5f2bdeaab06ff6dd2d2e10ddcd962dc6446f46ddd64bdbb5a
7
- data.tar.gz: b348fe1df3db7a302023b32fd4fafa3ab2a4b09edd99efdfc55f3d8dba27ac18dd118eeeb008702467cd188c96104309b99800a428224de17758a6cd4d95c3eb
6
+ metadata.gz: c418da4113b32159d9782d6495f00df32aef733b350d11dc7764b724b8809a1ecd11a4cb866503921cefc1532ffea91fe029922bae2906044044cf09c09e92b1
7
+ data.tar.gz: ecb81bf9cf67febbeddb027cab43b1ba0d77fcdcbed7db1ee836ad51267d29f1ab753ca2d49e2b213e58ec0514c764a3b0556fe7a7c25a53f0ec873b8a397e8e
data/README.md CHANGED
@@ -53,7 +53,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
53
53
  might want to use a conservative version locking in your `Gemfile`:
54
54
 
55
55
  ```rb
56
- gem 'rubocop', '~> 0.59.2', require: false
56
+ gem 'rubocop', '~> 0.60.0', require: false
57
57
  ```
58
58
 
59
59
  ## Quickstart
@@ -86,11 +86,12 @@ Here's a list of RuboCop's core developers:
86
86
 
87
87
  * [Bozhidar Batsov](https://github.com/bbatsov) (author & head maintainer)
88
88
  * [Jonas Arvidsson](https://github.com/jonas054)
89
- * [Yuji Nakayama](https://github.com/yujinakayama)
89
+ * [Yuji Nakayama](https://github.com/yujinakayama) (retired)
90
90
  * [Evgeni Dzhelyov](https://github.com/edzhelyov) (retired)
91
91
  * [Ted Johansson](https://github.com/drenmi)
92
92
  * [Masataka Kuwabara](https://github.com/pocke)
93
93
  * [Koichi Ito](https://github.com/koic)
94
+ * [Maxim Krizhanovski](https://github.com/darhazer)
94
95
 
95
96
  ## Logo
96
97
 
@@ -1,11 +1,5 @@
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:
10
4
  RubyInterpreters:
11
5
  - ruby
@@ -88,15 +82,15 @@ AllCops:
88
82
  # default. Change behavior by overriding `StyleGuideCopsOnly`, or by giving
89
83
  # the `--only-guide-cops` option.
90
84
  StyleGuideCopsOnly: false
91
- # All cops except the ones in disabled.yml are enabled by default. Change
92
- # 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`.
93
87
  # When `DisabledByDefault` is `true`, all cops in the default configuration
94
88
  # are disabled, and only cops in user configuration are enabled. This makes
95
89
  # cops opt-in instead of opt-out. Note that when `DisabledByDefault` is `true`,
96
90
  # cops in user configuration will be enabled even if they don't set the
97
91
  # Enabled parameter.
98
- # When `EnabledByDefault` is `true`, all cops, even those in disabled.yml,
99
- # 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.
100
94
  # Note that it is invalid to set both EnabledByDefault and DisabledByDefault
101
95
  # to true in the same configuration.
102
96
  EnabledByDefault: false
@@ -140,10 +134,83 @@ AllCops:
140
134
  # as the default.
141
135
  TargetRailsVersion: ~
142
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
+
143
207
  #################### Layout ###########################
144
208
 
145
- # Indent private/protected/public as deep as method definitions
146
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
147
214
  EnforcedStyle: indent
148
215
  SupportedStyles:
149
216
  - outdent
@@ -152,8 +219,20 @@ Layout/AccessModifierIndentation:
152
219
  # But it can be overridden by setting this parameter
153
220
  IndentationWidth: ~
154
221
 
155
- # 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
+
156
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
157
236
  # Alignment of entries using hash rocket as separator. Valid values are:
158
237
  #
159
238
  # key - left alignment of keys
@@ -225,6 +304,12 @@ Layout/AlignHash:
225
304
  - ignore_explicit
226
305
 
227
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
228
313
  # Alignment of parameters in multi-line method calls.
229
314
  #
230
315
  # The `with_first_parameter` style aligns the following lines along the same
@@ -246,8 +331,10 @@ Layout/AlignParameters:
246
331
  # But it can be overridden by setting this parameter
247
332
  IndentationWidth: ~
248
333
 
249
- # checks whether the end keywords are aligned properly for `do` `end` blocks.
250
334
  Layout/BlockAlignment:
335
+ Description: 'Align block ends correctly.'
336
+ Enabled: true
337
+ VersionAdded: 0.53
251
338
  # The value `start_of_block` means that the `end` should be aligned with line
252
339
  # where the `do` keyword appears.
253
340
  # The value `start_of_line` means it should be aligned with the whole
@@ -259,8 +346,16 @@ Layout/BlockAlignment:
259
346
  - start_of_block
260
347
  - start_of_line
261
348
 
262
- # 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
+
263
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
264
359
  EnforcedStyle: case
265
360
  SupportedStyles:
266
361
  - case
@@ -271,7 +366,52 @@ Layout/CaseIndentation:
271
366
  # This only matters if `IndentOneStep` is `true`
272
367
  IndentationWidth: ~
273
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
+
274
411
  Layout/DefEndAlignment:
412
+ Description: 'Align ends corresponding to defs correctly.'
413
+ Enabled: true
414
+ VersionAdded: 0.53
275
415
  # The value `def` means that `end` should be aligned with the def keyword.
276
416
  # The value `start_of_line` means that `end` should be aligned with method
277
417
  # calls like `private`, `public`, etc, if present in front of the `def`
@@ -283,32 +423,90 @@ Layout/DefEndAlignment:
283
423
  AutoCorrect: false
284
424
  Severity: warning
285
425
 
286
- # Multi-line method chaining should be done with leading dots.
287
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
288
431
  EnforcedStyle: leading
289
432
  SupportedStyles:
290
433
  - leading
291
434
  - trailing
292
435
 
436
+ Layout/ElseAlignment:
437
+ Description: 'Align elses and elsifs correctly.'
438
+ Enabled: true
439
+ VersionAdded: 0.49
440
+
293
441
  Layout/EmptyComment:
442
+ Description: 'Checks empty comment.'
443
+ Enabled: true
444
+ VersionAdded: 0.53
294
445
  AllowBorderComment: true
295
446
  AllowMarginComment: true
296
447
 
297
- # 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
+
298
460
  Layout/EmptyLineBetweenDefs:
461
+ Description: 'Use empty lines between defs.'
462
+ StyleGuide: '#empty-lines-between-methods'
463
+ Enabled: true
464
+ VersionAdded: 0.49
299
465
  # If `true`, this parameter means that single line method definitions don't
300
466
  # need an empty line between them.
301
467
  AllowAdjacentOneLineDefs: false
302
468
  # Can be array to specify minimum and maximum number of empty lines, e.g. [1, 2]
303
469
  NumberOfEmptyLines: 1
304
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
+
305
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
306
499
  EnforcedStyle: no_empty_lines
307
500
  SupportedStyles:
308
501
  - empty_lines
309
502
  - no_empty_lines
310
503
 
311
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
312
510
  EnforcedStyle: no_empty_lines
313
511
  SupportedStyles:
314
512
  - empty_lines
@@ -318,7 +516,23 @@ Layout/EmptyLinesAroundClassBody:
318
516
  - beginning_only
319
517
  - ending_only
320
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
+
321
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
322
536
  EnforcedStyle: no_empty_lines
323
537
  SupportedStyles:
324
538
  - empty_lines
@@ -326,8 +540,10 @@ Layout/EmptyLinesAroundModuleBody:
326
540
  - empty_lines_special
327
541
  - no_empty_lines
328
542
 
329
- # Align ends correctly.
330
543
  Layout/EndAlignment:
544
+ Description: 'Align ends correctly.'
545
+ Enabled: true
546
+ VersionAdded: 0.53
331
547
  # The value `keyword` means that `end` should be aligned with the matching
332
548
  # keyword (`if`, `while`, etc.).
333
549
  # The value `variable` means that in assignments, `end` should be aligned
@@ -344,6 +560,10 @@ Layout/EndAlignment:
344
560
  Severity: warning
345
561
 
346
562
  Layout/EndOfLine:
563
+ Description: 'Use Unix-style line endings.'
564
+ StyleGuide: '#crlf'
565
+ Enabled: true
566
+ VersionAdded: 0.49
347
567
  # The `native` style means that CR+LF (Carriage Return + Line Feed) is
348
568
  # enforced on Windows, and LF is enforced on other platforms. The other styles
349
569
  # mean LF and CR+LF, respectively.
@@ -354,6 +574,9 @@ Layout/EndOfLine:
354
574
  - crlf
355
575
 
356
576
  Layout/ExtraSpacing:
577
+ Description: 'Do not use unnecessary spacing.'
578
+ Enabled: true
579
+ VersionAdded: 0.49
357
580
  # When true, allows most uses of extra spacing if the intent is to align
358
581
  # things with the previous or next line, not counting empty lines or comment
359
582
  # lines.
@@ -361,7 +584,39 @@ Layout/ExtraSpacing:
361
584
  # When true, forces the alignment of `=` in assignments on consecutive lines.
362
585
  ForceEqualSignAlignment: false
363
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
+
364
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
365
620
  EnforcedStyle: special_for_inner_method_call_in_parentheses
366
621
  SupportedStyles:
367
622
  # The first parameter should always be indented one step more than the
@@ -382,25 +637,12 @@ Layout/FirstParameterIndentation:
382
637
  # But it can be overridden by setting this parameter
383
638
  IndentationWidth: ~
384
639
 
385
- Layout/IndentationConsistency:
386
- # The difference between `rails` and `normal` is that the `rails` style
387
- # prescribes that in classes and modules the `protected` and `private`
388
- # modifier keywords shall be indented the same as public methods and that
389
- # protected and private members shall be indented one step more than the
390
- # modifiers. Other than that, both styles mean that entities on the same
391
- # logical depth shall have the same indentation.
392
- EnforcedStyle: normal
393
- SupportedStyles:
394
- - normal
395
- - rails
396
-
397
- Layout/IndentationWidth:
398
- # Number of spaces for each indentation level.
399
- Width: 2
400
- IgnoredPatterns: []
401
-
402
- # Checks the indentation of the first element in an array literal.
403
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
404
646
  # The value `special_inside_parentheses` means that array literals with
405
647
  # brackets that have their opening bracket on the same line as a surrounding
406
648
  # opening round parenthesis, shall have their first element indented relative
@@ -421,14 +663,20 @@ Layout/IndentArray:
421
663
  # But it can be overridden by setting this parameter
422
664
  IndentationWidth: ~
423
665
 
424
- # Checks the indentation of assignment RHS, when on a different line from LHS
425
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
426
672
  # By default, the indentation width from `Layout/IndentationWidth` is used
427
673
  # But it can be overridden by setting this parameter
428
674
  IndentationWidth: ~
429
675
 
430
- # Checks the indentation of the first key in a hash literal.
431
676
  Layout/IndentHash:
677
+ Description: 'Checks the indentation of the first key in a hash literal.'
678
+ Enabled: true
679
+ VersionAdded: 0.49
432
680
  # The value `special_inside_parentheses` means that hash literals with braces
433
681
  # that have their opening brace on the same line as a surrounding opening
434
682
  # round parenthesis, shall have their first key indented relative to the
@@ -450,6 +698,10 @@ Layout/IndentHash:
450
698
  IndentationWidth: ~
451
699
 
452
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
453
705
  EnforcedStyle: auto_detection
454
706
  SupportedStyles:
455
707
  - auto_detection
@@ -458,13 +710,55 @@ Layout/IndentHeredoc:
458
710
  - powerpack
459
711
  - unindent
460
712
 
461
- Layout/SpaceInLambdaLiteral:
462
- 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
463
725
  SupportedStyles:
464
- - require_no_space
465
- - 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
466
754
 
467
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
468
762
  EnforcedStyle: symmetrical
469
763
  SupportedStyles:
470
764
  # symmetrical: closing brace is positioned in same way as opening brace
@@ -475,6 +769,10 @@ Layout/MultilineArrayBraceLayout:
475
769
  - same_line
476
770
 
477
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
478
776
  # The types of assignments which are subject to this rule.
479
777
  SupportedTypes:
480
778
  - block
@@ -492,7 +790,18 @@ Layout/MultilineAssignmentLayout:
492
790
  # for the set of supported types.
493
791
  - new_line
494
792
 
793
+ Layout/MultilineBlockLayout:
794
+ Description: 'Ensures newlines after multiline block do statements.'
795
+ Enabled: true
796
+ VersionAdded: 0.49
797
+
495
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
496
805
  EnforcedStyle: symmetrical
497
806
  SupportedStyles:
498
807
  # symmetrical: closing brace is positioned in same way as opening brace
@@ -503,6 +812,12 @@ Layout/MultilineHashBraceLayout:
503
812
  - same_line
504
813
 
505
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
506
821
  EnforcedStyle: symmetrical
507
822
  SupportedStyles:
508
823
  # symmetrical: closing brace is positioned in same way as opening brace
@@ -513,6 +828,11 @@ Layout/MultilineMethodCallBraceLayout:
513
828
  - same_line
514
829
 
515
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
516
836
  EnforcedStyle: aligned
517
837
  SupportedStyles:
518
838
  - aligned
@@ -523,6 +843,12 @@ Layout/MultilineMethodCallIndentation:
523
843
  IndentationWidth: ~
524
844
 
525
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
526
852
  EnforcedStyle: symmetrical
527
853
  SupportedStyles:
528
854
  # symmetrical: closing brace is positioned in same way as opening brace
@@ -533,6 +859,11 @@ Layout/MultilineMethodDefinitionBraceLayout:
533
859
  - same_line
534
860
 
535
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
536
867
  EnforcedStyle: aligned
537
868
  SupportedStyles:
538
869
  - aligned
@@ -541,25 +872,86 @@ Layout/MultilineOperationIndentation:
541
872
  # But it can be overridden by setting this parameter
542
873
  IndentationWidth: ~
543
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
+
544
912
  Layout/SpaceAroundBlockParameters:
913
+ Description: 'Checks the spacing inside and after block parameters pipes.'
914
+ Enabled: true
915
+ VersionAdded: 0.49
545
916
  EnforcedStyleInsidePipes: no_space
546
917
  SupportedStylesInsidePipes:
547
918
  - space
548
919
  - no_space
549
920
 
550
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
551
929
  EnforcedStyle: space
552
930
  SupportedStyles:
553
931
  - space
554
932
  - no_space
555
933
 
934
+ Layout/SpaceAroundKeyword:
935
+ Description: 'Use a space around keywords if appropriate.'
936
+ Enabled: true
937
+ VersionAdded: 0.49
938
+
556
939
  Layout/SpaceAroundOperators:
940
+ Description: 'Use a single space around operators.'
941
+ StyleGuide: '#spaces-operators'
942
+ Enabled: true
943
+ VersionAdded: 0.49
557
944
  # When `true`, allows most uses of extra spacing if the intent is to align
558
945
  # with an operator on the previous or next line, not counting empty lines
559
946
  # or comment lines.
560
947
  AllowForAlignment: true
561
948
 
562
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
563
955
  EnforcedStyle: space
564
956
  SupportedStyles:
565
957
  - space
@@ -568,14 +960,49 @@ Layout/SpaceBeforeBlockBraces:
568
960
  SupportedStylesForEmptyBraces:
569
961
  - space
570
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
571
976
 
572
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
573
983
  # When `true`, allows most uses of extra spacing if the intent is to align
574
984
  # things with the previous or next line, not counting empty lines or comment
575
985
  # lines.
576
986
  AllowForAlignment: true
577
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
+
578
1002
  Layout/SpaceInsideArrayLiteralBrackets:
1003
+ Description: 'Checks the spacing inside array literal brackets.'
1004
+ Enabled: true
1005
+ VersionAdded: 0.52
579
1006
  EnforcedStyle: no_space
580
1007
  SupportedStyles:
581
1008
  - space
@@ -588,7 +1015,18 @@ Layout/SpaceInsideArrayLiteralBrackets:
588
1015
  - space
589
1016
  - no_space
590
1017
 
1018
+ Layout/SpaceInsideArrayPercentLiteral:
1019
+ Description: 'No unnecessary additional spaces between elements in %i/%w literals.'
1020
+ Enabled: true
1021
+ VersionAdded: 0.49
1022
+
591
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
592
1030
  EnforcedStyle: space
593
1031
  SupportedStyles:
594
1032
  - space
@@ -601,6 +1039,10 @@ Layout/SpaceInsideBlockBraces:
601
1039
  SpaceBeforeBlockParameters: true
602
1040
 
603
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
604
1046
  EnforcedStyle: space
605
1047
  SupportedStyles:
606
1048
  - space
@@ -613,13 +1055,34 @@ Layout/SpaceInsideHashLiteralBraces:
613
1055
  - space
614
1056
  - no_space
615
1057
 
1058
+
616
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
617
1065
  EnforcedStyle: no_space
618
1066
  SupportedStyles:
619
1067
  - space
620
1068
  - no_space
621
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
+
622
1081
  Layout/SpaceInsideReferenceBrackets:
1082
+ Description: 'Checks the spacing inside referential brackets.'
1083
+ Enabled: true
1084
+ VersionAdded: 0.52
1085
+ VersionChanged: 0.53
623
1086
  EnforcedStyle: no_space
624
1087
  SupportedStyles:
625
1088
  - space
@@ -630,27 +1093,21 @@ Layout/SpaceInsideReferenceBrackets:
630
1093
  - no_space
631
1094
 
632
1095
  Layout/SpaceInsideStringInterpolation:
1096
+ Description: 'Checks for padding/surrounding spaces inside string interpolation.'
1097
+ StyleGuide: '#string-interpolation'
1098
+ Enabled: true
1099
+ VersionAdded: 0.49
633
1100
  EnforcedStyle: no_space
634
1101
  SupportedStyles:
635
1102
  - space
636
1103
  - no_space
637
1104
 
638
- Layout/ClassStructure:
639
- Categories:
640
- module_inclusion:
641
- - include
642
- - prepend
643
- - extend
644
- ExpectedOrder:
645
- - module_inclusion
646
- - constants
647
- - public_class_methods
648
- - initializer
649
- - public_methods
650
- - protected_methods
651
- - private_methods
652
-
653
1105
  Layout/Tab:
1106
+ Description: 'No hard tabs.'
1107
+ StyleGuide: '#spaces-indentation'
1108
+ Enabled: true
1109
+ VersionAdded: 0.49
1110
+ VersionChanged: 0.51
654
1111
  # By default, the indentation width from Layout/IndentationWidth is used
655
1112
  # But it can be overridden by setting this parameter
656
1113
  # It is used during auto-correction to determine how many spaces should
@@ -658,133 +1115,796 @@ Layout/Tab:
658
1115
  IndentationWidth: ~
659
1116
 
660
1117
  Layout/TrailingBlankLines:
1118
+ Description: 'Checks trailing blank lines and final newline.'
1119
+ StyleGuide: '#newline-eof'
1120
+ Enabled: true
1121
+ VersionAdded: 0.49
661
1122
  EnforcedStyle: final_newline
662
1123
  SupportedStyles:
663
1124
  - final_newline
664
1125
  - final_blank_line
665
1126
 
666
1127
  Layout/TrailingWhitespace:
1128
+ Description: 'Avoid trailing whitespace.'
1129
+ StyleGuide: '#no-trailing-whitespace'
1130
+ Enabled: true
1131
+ VersionAdded: 0.49
1132
+ VersionChanged: 0.55
667
1133
  AllowInHeredoc: false
668
1134
 
669
- #################### Naming ##########################
670
-
671
- Naming/FileName:
672
- # Camel case file names listed in `AllCops:Include` and all file names listed
673
- # in `AllCops:Exclude` are excluded by default. Add extra excludes here.
674
- Exclude: []
675
- # When `true`, requires that each source file should define a class or module
676
- # with a name which matches the file name (converted to ... case).
677
- # It further expects it to be nested inside modules which match the names
678
- # of subdirectories in its path.
679
- ExpectMatchingDefinition: false
680
- # If non-`nil`, expect all source file names to match the following regex.
681
- # Only the file name itself is matched, not the entire file path.
682
- # Use anchors as necessary if you want to match the entire name rather than
683
- # just a part of it.
684
- Regex: ~
685
- # With `IgnoreExecutableScripts` set to `true`, this cop does not
686
- # report offending filenames for executable scripts (i.e. source
687
- # files with a shebang in the first line).
688
- IgnoreExecutableScripts: true
689
- AllowedAcronyms:
690
- - CLI
691
- - DSL
692
- - ACL
693
- - API
694
- - ASCII
695
- - CPU
696
- - CSS
697
- - DNS
698
- - EOF
699
- - GUID
700
- - HTML
701
- - HTTP
702
- - HTTPS
703
- - ID
704
- - IP
705
- - JSON
706
- - LHS
707
- - QPS
708
- - RAM
709
- - RHS
710
- - RPC
711
- - SLA
712
- - SMTP
713
- - SQL
714
- - SSH
715
- - TCP
716
- - TLS
717
- - TTL
718
- - UDP
719
- - UI
720
- - UID
721
- - UUID
722
- - URI
723
- - URL
724
- - UTF8
725
- - VM
726
- - XML
727
- - XMPP
728
- - XSRF
729
- - XSS
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
730
1160
 
731
- Naming/HeredocDelimiterNaming:
732
- Blacklist:
733
- - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/'
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
734
1167
 
735
- Naming/HeredocDelimiterCase:
736
- EnforcedStyle: uppercase
737
- SupportedStyles:
738
- - lowercase
739
- - uppercase
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
740
1225
 
741
- Naming/MemoizedInstanceVariableName:
742
- EnforcedStyleForLeadingUnderscores: disallowed
743
- SupportedStylesForLeadingUnderscores:
744
- - disallowed
745
- - required
746
- - optional
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
747
1289
 
748
- Naming/MethodName:
749
- EnforcedStyle: snake_case
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
750
1296
  SupportedStyles:
751
- - snake_case
752
- - camelCase
1297
+ - runtime_error
1298
+ - standard_error
753
1299
 
754
- Naming/PredicateName:
755
- # Predicate name prefixes.
756
- NamePrefix:
757
- - is_
758
- - has_
759
- - have_
760
- # Predicate name prefixes that should be removed.
761
- NamePrefixBlacklist:
762
- - is_
763
- - has_
764
- - have_
765
- # Predicate names which, despite having a blacklisted prefix, or no `?`,
766
- # should still be accepted
767
- NameWhitelist:
768
- - is_a?
769
- # Method definition macros for dynamically generated methods.
770
- MethodDefinitionMacros:
771
- - define_method
772
- - define_singleton_method
773
- # Exclude Rspec specs because there is a strong convention to write spec
774
- # helpers in the form of `have_something` or `be_something`.
775
- Exclude:
776
- - 'spec/**/*'
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
777
1323
 
778
- Naming/UncommunicativeBlockParamName:
779
- # Parameter names may be equal to or greater than this value
780
- MinNameLength: 1
781
- AllowNamesEndingInNumbers: true
782
- # Whitelisted names that will not register an offense
783
- AllowedNames: []
784
- # Blacklisted names that will register an offense
785
- ForbiddenNames: []
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
786
1336
 
787
- Naming/UncommunicativeMethodParamName:
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
1753
+
1754
+ Naming/FileName:
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.
1761
+ Exclude: []
1762
+ # When `true`, requires that each source file should define a class or module
1763
+ # with a name which matches the file name (converted to ... case).
1764
+ # It further expects it to be nested inside modules which match the names
1765
+ # of subdirectories in its path.
1766
+ ExpectMatchingDefinition: false
1767
+ # If non-`nil`, expect all source file names to match the following regex.
1768
+ # Only the file name itself is matched, not the entire file path.
1769
+ # Use anchors as necessary if you want to match the entire name rather than
1770
+ # just a part of it.
1771
+ Regex: ~
1772
+ # With `IgnoreExecutableScripts` set to `true`, this cop does not
1773
+ # report offending filenames for executable scripts (i.e. source
1774
+ # files with a shebang in the first line).
1775
+ IgnoreExecutableScripts: true
1776
+ AllowedAcronyms:
1777
+ - CLI
1778
+ - DSL
1779
+ - ACL
1780
+ - API
1781
+ - ASCII
1782
+ - CPU
1783
+ - CSS
1784
+ - DNS
1785
+ - EOF
1786
+ - GUID
1787
+ - HTML
1788
+ - HTTP
1789
+ - HTTPS
1790
+ - ID
1791
+ - IP
1792
+ - JSON
1793
+ - LHS
1794
+ - QPS
1795
+ - RAM
1796
+ - RHS
1797
+ - RPC
1798
+ - SLA
1799
+ - SMTP
1800
+ - SQL
1801
+ - SSH
1802
+ - TCP
1803
+ - TLS
1804
+ - TTL
1805
+ - UDP
1806
+ - UI
1807
+ - UID
1808
+ - UUID
1809
+ - URI
1810
+ - URL
1811
+ - UTF8
1812
+ - VM
1813
+ - XML
1814
+ - XMPP
1815
+ - XSRF
1816
+ - XSS
1817
+
1818
+ Naming/HeredocDelimiterCase:
1819
+ Description: 'Use configured case for heredoc delimiters.'
1820
+ StyleGuide: '#heredoc-delimiters'
1821
+ Enabled: true
1822
+ VersionAdded: 0.50
1823
+ EnforcedStyle: uppercase
1824
+ SupportedStyles:
1825
+ - lowercase
1826
+ - uppercase
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
+
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
1853
+ EnforcedStyle: snake_case
1854
+ SupportedStyles:
1855
+ - snake_case
1856
+ - camelCase
1857
+
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
1864
+ # Predicate name prefixes.
1865
+ NamePrefix:
1866
+ - is_
1867
+ - has_
1868
+ - have_
1869
+ # Predicate name prefixes that should be removed.
1870
+ NamePrefixBlacklist:
1871
+ - is_
1872
+ - has_
1873
+ - have_
1874
+ # Predicate names which, despite having a blacklisted prefix, or no `?`,
1875
+ # should still be accepted
1876
+ NameWhitelist:
1877
+ - is_a?
1878
+ # Method definition macros for dynamically generated methods.
1879
+ MethodDefinitionMacros:
1880
+ - define_method
1881
+ - define_singleton_method
1882
+ # Exclude Rspec specs because there is a strong convention to write spec
1883
+ # helpers in the form of `have_something` or `be_something`.
1884
+ Exclude:
1885
+ - 'spec/**/*'
1886
+
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
1893
+ # Parameter names may be equal to or greater than this value
1894
+ MinNameLength: 1
1895
+ AllowNamesEndingInNumbers: true
1896
+ # Whitelisted names that will not register an offense
1897
+ AllowedNames: []
1898
+ # Blacklisted names that will register an offense
1899
+ ForbiddenNames: []
1900
+
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
788
1908
  # Parameter names may be equal to or greater than this value
789
1909
  MinNameLength: 3
790
1910
  AllowNamesEndingInNumbers: true
@@ -802,52 +1922,796 @@ Naming/UncommunicativeMethodParamName:
802
1922
  # Blacklisted names that will register an offense
803
1923
  ForbiddenNames: []
804
1924
 
1925
+
805
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
806
1931
  EnforcedStyle: snake_case
807
1932
  SupportedStyles:
808
1933
  - snake_case
809
1934
  - camelCase
810
1935
 
811
1936
  Naming/VariableNumber:
1937
+ Description: 'Use the configured style when numbering variables.'
1938
+ Enabled: true
1939
+ VersionAdded: 0.50
812
1940
  EnforcedStyle: normalcase
813
1941
  SupportedStyles:
814
1942
  - snake_case
815
1943
  - normalcase
816
1944
  - non_integer
817
1945
 
818
- #################### Style ###########################
1946
+ #################### Performance ###########################
819
1947
 
820
- Style/AccessModifierDeclarations:
821
- EnforcedStyle: group
822
- SupportedStyles:
823
- - inline
824
- - group
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
825
2011
 
826
- Style/Alias:
827
- EnforcedStyle: prefer_alias
828
- SupportedStyles:
829
- - prefer_alias
830
- - prefer_alias_method
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
831
2022
 
832
- Style/AndOr:
833
- # Whether `and` and `or` are banned only in conditionals (conditionals)
834
- # or completely (always).
835
- EnforcedStyle: always
836
- SupportedStyles:
837
- - always
838
- - conditionals
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/RangeInclude:
2067
+ Description: 'Use `Range#cover?` instead of `Range#include?`.'
2068
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#cover-vs-include-code'
2069
+ Enabled: true
2070
+ VersionAdded: 0.36
2071
+
2072
+ Performance/RedundantBlockCall:
2073
+ Description: 'Use `yield` instead of `block.call`.'
2074
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#proccall-and-block-arguments-vs-yieldcode'
2075
+ Enabled: true
2076
+ VersionAdded: 0.36
2077
+
2078
+ Performance/RedundantMatch:
2079
+ Description: >-
2080
+ Use `=~` instead of `String#match` or `Regexp#match` in a context where the
2081
+ returned `MatchData` is not needed.
2082
+ Enabled: true
2083
+ VersionAdded: 0.36
839
2084
 
840
- Style/AsciiComments:
841
- AllowedChars: []
2085
+ Performance/RedundantMerge:
2086
+ Description: 'Use Hash#[]=, rather than Hash#merge! with a single key-value pair.'
2087
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashmerge-vs-hash-code'
2088
+ Enabled: true
2089
+ VersionAdded: 0.36
2090
+ # Max number of key-value pairs to consider an offense
2091
+ MaxKeyValuePairs: 2
842
2092
 
843
- # Checks if usage of `%()` or `%Q()` matches configuration.
844
- Style/BarePercentLiterals:
845
- EnforcedStyle: bare_percent
846
- SupportedStyles:
847
- - percent_q
2093
+ Performance/RedundantSortBy:
2094
+ Description: 'Use `sort` instead of `sort_by { |x| x }`.'
2095
+ Enabled: true
2096
+ VersionAdded: 0.36
2097
+
2098
+ Performance/RegexpMatch:
2099
+ Description: >-
2100
+ Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`,
2101
+ `Regexp#===`, or `=~` when `MatchData` is not used.
2102
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#regexp-vs-stringmatch-vs-string-vs-stringmatch-code-'
2103
+ Enabled: true
2104
+ VersionAdded: 0.47
2105
+
2106
+ Performance/ReverseEach:
2107
+ Description: 'Use `reverse_each` instead of `reverse.each`.'
2108
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
2109
+ Enabled: true
2110
+ VersionAdded: 0.30
2111
+
2112
+ Performance/Sample:
2113
+ Description: >-
2114
+ Use `sample` instead of `shuffle.first`,
2115
+ `shuffle.last`, and `shuffle[Integer]`.
2116
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
2117
+ Enabled: true
2118
+ VersionAdded: 0.30
2119
+
2120
+ Performance/Size:
2121
+ Description: >-
2122
+ Use `size` instead of `count` for counting
2123
+ the number of elements in `Array` and `Hash`.
2124
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraylength-vs-arraysize-vs-arraycount-code'
2125
+ Enabled: true
2126
+ VersionAdded: 0.30
2127
+
2128
+ Performance/StartWith:
2129
+ Description: 'Use `start_with?` instead of a regex match anchored to the beginning of a string.'
2130
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
2131
+ # This will change to a new method call which isn't guaranteed to be on the
2132
+ # object. Switching these methods has to be done with knowledge of the types
2133
+ # of the variables which rubocop doesn't have.
2134
+ SafeAutoCorrect: false
2135
+ AutoCorrect: false
2136
+ Enabled: true
2137
+ VersionAdded: 0.36
2138
+ VersionChanged: 0.44
2139
+
2140
+ Performance/StringReplacement:
2141
+ Description: >-
2142
+ Use `tr` instead of `gsub` when you are replacing the same
2143
+ number of characters. Use `delete` instead of `gsub` when
2144
+ you are deleting characters.
2145
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
2146
+ Enabled: true
2147
+ VersionAdded: 0.33
2148
+
2149
+ Performance/TimesMap:
2150
+ Description: 'Checks for .times.map calls.'
2151
+ AutoCorrect: false
2152
+ Enabled: true
2153
+ VersionAdded: 0.36
2154
+ VersionChanged: 0.50
2155
+ SafeAutoCorrect: false # see https://github.com/rubocop-hq/rubocop/issues/4658
2156
+
2157
+ Performance/UnfreezeString:
2158
+ Description: 'Use unary plus to get an unfrozen string literal.'
2159
+ Enabled: true
2160
+ VersionAdded: 0.50
2161
+
2162
+ Performance/UnneededSort:
2163
+ Description: >-
2164
+ Use `min` instead of `sort.first`,
2165
+ `max_by` instead of `sort_by...last`, etc.
2166
+ Enabled: true
2167
+ VersionAdded: 0.55
2168
+
2169
+ Performance/UriDefaultParser:
2170
+ Description: 'Use `URI::DEFAULT_PARSER` instead of `URI::Parser.new`.'
2171
+ Enabled: true
2172
+ VersionAdded: 0.50
2173
+
2174
+ #################### Rails #################################
2175
+
2176
+ # By default, the rails cops are not run. Override in project or home
2177
+ # directory .rubocop.yml files, or by giving the -R/--rails option.
2178
+ Rails:
2179
+ Enabled: false
2180
+
2181
+ Rails/ActionFilter:
2182
+ Description: 'Enforces consistent use of action filter methods.'
2183
+ Enabled: true
2184
+ VersionAdded: 0.19
2185
+ EnforcedStyle: action
2186
+ SupportedStyles:
2187
+ - action
2188
+ - filter
2189
+ Include:
2190
+ - app/controllers/**/*.rb
2191
+
2192
+ Rails/ActiveRecordAliases:
2193
+ Description: >-
2194
+ Avoid Active Record aliases:
2195
+ Use `update` instead of `update_attributes`.
2196
+ Use `update!` instead of `update_attributes!`.
2197
+ Enabled: true
2198
+ VersionAdded: 0.53
2199
+
2200
+ Rails/ActiveSupportAliases:
2201
+ Description: >-
2202
+ Avoid ActiveSupport aliases of standard ruby methods:
2203
+ `String#starts_with?`, `String#ends_with?`,
2204
+ `Array#append`, `Array#prepend`.
2205
+ Enabled: true
2206
+ VersionAdded: 0.48
2207
+
2208
+ Rails/ApplicationJob:
2209
+ Description: 'Check that jobs subclass ApplicationJob.'
2210
+ Enabled: true
2211
+ VersionAdded: 0.49
2212
+
2213
+ Rails/ApplicationRecord:
2214
+ Description: 'Check that models subclass ApplicationRecord.'
2215
+ Enabled: true
2216
+ VersionAdded: 0.49
2217
+
2218
+ Rails/AssertNot:
2219
+ Description: 'Use `assert_not` instead of `assert !`.'
2220
+ Enabled: true
2221
+ VersionAdded: 0.56
2222
+ Include:
2223
+ - '**/test/**/*'
2224
+
2225
+ Rails/Blank:
2226
+ Description: 'Enforces use of `blank?`.'
2227
+ Enabled: true
2228
+ VersionAdded: 0.48
2229
+ # Convert usages of `nil? || empty?` to `blank?`
2230
+ NilOrEmpty: true
2231
+ # Convert usages of `!present?` to `blank?`
2232
+ NotPresent: true
2233
+ # Convert usages of `unless present?` to `if blank?`
2234
+ UnlessPresent: true
2235
+
2236
+ Rails/BulkChangeTable:
2237
+ Description: 'Check whether alter queries are combinable.'
2238
+ Enabled: true
2239
+ VersionAdded: 0.57
2240
+ Database: null
2241
+ SupportedDatabases:
2242
+ - mysql
2243
+ - postgresql
2244
+ Include:
2245
+ - db/migrate/*.rb
2246
+
2247
+ Rails/CreateTableWithTimestamps:
2248
+ Description: >-
2249
+ Checks the migration for which timestamps are not included
2250
+ when creating a new table.
2251
+ Enabled: true
2252
+ VersionAdded: 0.52
2253
+ Include:
2254
+ - db/migrate/*.rb
2255
+
2256
+ Rails/Date:
2257
+ Description: >-
2258
+ Checks the correct usage of date aware methods,
2259
+ such as Date.today, Date.current etc.
2260
+ Enabled: true
2261
+ VersionAdded: 0.30
2262
+ VersionChanged: 0.33
2263
+ # The value `strict` disallows usage of `Date.today`, `Date.current`,
2264
+ # `Date#to_time` etc.
2265
+ # The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
2266
+ # (but not `Date.today`) which are overridden by ActiveSupport to handle current
2267
+ # time zone.
2268
+ EnforcedStyle: flexible
2269
+ SupportedStyles:
2270
+ - strict
2271
+ - flexible
2272
+
2273
+ Rails/Delegate:
2274
+ Description: 'Prefer delegate method for delegations.'
2275
+ Enabled: true
2276
+ VersionAdded: 0.21
2277
+ VersionChanged: 0.50
2278
+ # When set to true, using the target object as a prefix of the
2279
+ # method name without using the `delegate` method will be a
2280
+ # violation. When set to false, this case is legal.
2281
+ EnforceForPrefixed: true
2282
+
2283
+ Rails/DelegateAllowBlank:
2284
+ Description: 'Do not use allow_blank as an option to delegate.'
2285
+ Enabled: true
2286
+ VersionAdded: 0.44
2287
+
2288
+ Rails/DynamicFindBy:
2289
+ Description: 'Use `find_by` instead of dynamic `find_by_*`.'
2290
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find_by'
2291
+ Enabled: true
2292
+ VersionAdded: 0.44
2293
+ Whitelist:
2294
+ - find_by_sql
2295
+
2296
+ Rails/EnumUniqueness:
2297
+ Description: 'Avoid duplicate integers in hash-syntax `enum` declaration.'
2298
+ Enabled: true
2299
+ VersionAdded: 0.46
2300
+ Include:
2301
+ - app/models/**/*.rb
2302
+
2303
+ Rails/EnvironmentComparison:
2304
+ Description: "Favor `Rails.env.production?` over `Rails.env == 'production'`"
2305
+ Enabled: true
2306
+ VersionAdded: 0.52
2307
+
2308
+ Rails/Exit:
2309
+ Description: >-
2310
+ Favor `fail`, `break`, `return`, etc. over `exit` in
2311
+ application or library code outside of Rake files to avoid
2312
+ exits during unit testing or running in production.
2313
+ Enabled: true
2314
+ VersionAdded: 0.41
2315
+ Include:
2316
+ - app/**/*.rb
2317
+ - config/**/*.rb
2318
+ - lib/**/*.rb
2319
+ Exclude:
2320
+ - lib/**/*.rake
2321
+
2322
+ Rails/FilePath:
2323
+ Description: 'Use `Rails.root.join` for file path joining.'
2324
+ Enabled: true
2325
+ VersionAdded: 0.47
2326
+ VersionChanged: 0.57
2327
+ EnforcedStyle: arguments
2328
+ SupportedStyles:
2329
+ - slashes
2330
+ - arguments
2331
+
2332
+ Rails/FindBy:
2333
+ Description: 'Prefer find_by over where.first.'
2334
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find_by'
2335
+ Enabled: true
2336
+ VersionAdded: 0.30
2337
+ Include:
2338
+ - app/models/**/*.rb
2339
+
2340
+ Rails/FindEach:
2341
+ Description: 'Prefer all.find_each over all.find.'
2342
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#find-each'
2343
+ Enabled: true
2344
+ VersionAdded: 0.30
2345
+ Include:
2346
+ - app/models/**/*.rb
2347
+
2348
+ Rails/HasAndBelongsToMany:
2349
+ Description: 'Prefer has_many :through to has_and_belongs_to_many.'
2350
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#has-many-through'
2351
+ Enabled: true
2352
+ VersionAdded: 0.12
2353
+ Include:
2354
+ - app/models/**/*.rb
2355
+
2356
+ Rails/HasManyOrHasOneDependent:
2357
+ Description: 'Define the dependent option to the has_many and has_one associations.'
2358
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#has_many-has_one-dependent-option'
2359
+ Enabled: true
2360
+ VersionAdded: 0.50
2361
+ Include:
2362
+ - app/models/**/*.rb
2363
+
2364
+ Rails/HttpPositionalArguments:
2365
+ Description: 'Use keyword arguments instead of positional arguments in http method calls.'
2366
+ Enabled: true
2367
+ VersionAdded: 0.44
2368
+ Include:
2369
+ - 'spec/**/*'
2370
+ - 'test/**/*'
2371
+
2372
+ Rails/HttpStatus:
2373
+ Description: 'Enforces use of symbolic or numeric value to define HTTP status.'
2374
+ Enabled: true
2375
+ VersionAdded: 0.54
2376
+ EnforcedStyle: symbolic
2377
+ SupportedStyles:
2378
+ - numeric
2379
+ - symbolic
2380
+
2381
+ Rails/InverseOf:
2382
+ Description: 'Checks for associations where the inverse cannot be determined automatically.'
2383
+ Enabled: true
2384
+ VersionAdded: 0.52
2385
+ Include:
2386
+ - app/models/**/*.rb
2387
+
2388
+ Rails/LexicallyScopedActionFilter:
2389
+ Description: "Checks that methods specified in the filter's `only` or `except` options are explicitly defined in the controller."
2390
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#lexically-scoped-action-filter'
2391
+ Enabled: true
2392
+ VersionAdded: 0.52
2393
+ Include:
2394
+ - app/controllers/**/*.rb
2395
+
2396
+ Rails/NotNullColumn:
2397
+ Description: 'Do not add a NOT NULL column without a default value'
2398
+ Enabled: true
2399
+ VersionAdded: 0.43
2400
+ Include:
2401
+ - db/migrate/*.rb
2402
+
2403
+ Rails/Output:
2404
+ Description: 'Checks for calls to puts, print, etc.'
2405
+ Enabled: true
2406
+ VersionAdded: 0.15
2407
+ VersionChanged: 0.19
2408
+ Include:
2409
+ - app/**/*.rb
2410
+ - config/**/*.rb
2411
+ - db/**/*.rb
2412
+ - lib/**/*.rb
2413
+
2414
+ Rails/OutputSafety:
2415
+ Description: 'The use of `html_safe` or `raw` may be a security risk.'
2416
+ Enabled: true
2417
+ VersionAdded: 0.41
2418
+
2419
+ Rails/PluralizationGrammar:
2420
+ Description: 'Checks for incorrect grammar when using methods like `3.day.ago`.'
2421
+ Enabled: true
2422
+ VersionAdded: 0.35
2423
+
2424
+ Rails/Presence:
2425
+ Description: 'Checks code that can be written more easily using `Object#presence` defined by Active Support.'
2426
+ Enabled: true
2427
+ VersionAdded: 0.52
2428
+
2429
+ Rails/Present:
2430
+ Description: 'Enforces use of `present?`.'
2431
+ Enabled: true
2432
+ VersionAdded: 0.48
2433
+ # Convert usages of `!nil? && !empty?` to `present?`
2434
+ NotNilAndNotEmpty: true
2435
+ # Convert usages of `!blank?` to `present?`
2436
+ NotBlank: true
2437
+ # Convert usages of `unless blank?` to `if present?`
2438
+ UnlessBlank: true
2439
+
2440
+ Rails/ReadWriteAttribute:
2441
+ Description: >-
2442
+ Checks for read_attribute(:attr) and
2443
+ write_attribute(:attr, val).
2444
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#read-attribute'
2445
+ Enabled: true
2446
+ VersionAdded: 0.20
2447
+ VersionChanged: 0.29
2448
+ Include:
2449
+ - app/models/**/*.rb
2450
+
2451
+ Rails/RedundantReceiverInWithOptions:
2452
+ Description: 'Checks for redundant receiver in `with_options`.'
2453
+ Enabled: true
2454
+ VersionAdded: 0.52
2455
+
2456
+ Rails/RefuteMethods:
2457
+ Description: 'Use `assert_not` methods instead of `refute` methods.'
2458
+ Enabled: true
2459
+ VersionAdded: 0.56
2460
+ Include:
2461
+ - '**/test/**/*'
2462
+
2463
+ Rails/RelativeDateConstant:
2464
+ Description: 'Do not assign relative date to constants.'
2465
+ Enabled: true
2466
+ VersionAdded: 0.48
2467
+ VersionChanged: 0.59
2468
+ AutoCorrect: false
2469
+
2470
+ Rails/RequestReferer:
2471
+ Description: 'Use consistent syntax for request.referer.'
2472
+ Enabled: true
2473
+ VersionAdded: 0.41
2474
+ EnforcedStyle: referer
2475
+ SupportedStyles:
2476
+ - referer
2477
+ - referrer
2478
+
2479
+ Rails/ReversibleMigration:
2480
+ Description: 'Checks whether the change method of the migration file is reversible.'
2481
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#reversible-migration'
2482
+ Reference: 'http://api.rubyonrails.org/classes/ActiveRecord/Migration/CommandRecorder.html'
2483
+ Enabled: true
2484
+ VersionAdded: 0.47
2485
+ Include:
2486
+ - db/migrate/*.rb
2487
+
2488
+ Rails/SafeNavigation:
2489
+ Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
2490
+ Enabled: true
2491
+ VersionAdded: 0.43
2492
+ # This will convert usages of `try` to use safe navigation as well as `try!`.
2493
+ # `try` and `try!` work slightly differently. `try!` and safe navigation will
2494
+ # both raise a `NoMethodError` if the receiver of the method call does not
2495
+ # implement the intended method. `try` will not raise an exception for this.
2496
+ ConvertTry: false
2497
+
2498
+ Rails/SaveBang:
2499
+ Description: 'Identifies possible cases where Active Record save! or related should be used.'
2500
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#save-bang'
2501
+ Enabled: false
2502
+ VersionAdded: 0.42
2503
+ VersionChanged: 0.59
2504
+ AllowImplicitReturn: true
2505
+ AllowedReceivers: []
2506
+
2507
+ Rails/ScopeArgs:
2508
+ Description: 'Checks the arguments of ActiveRecord scopes.'
2509
+ Enabled: true
2510
+ VersionAdded: 0.19
2511
+ Include:
2512
+ - app/models/**/*.rb
2513
+
2514
+ Rails/SkipsModelValidations:
2515
+ Description: >-
2516
+ Use methods that skips model validations with caution.
2517
+ See reference for more information.
2518
+ Reference: 'http://guides.rubyonrails.org/active_record_validations.html#skipping-validations'
2519
+ Enabled: true
2520
+ VersionAdded: 0.47
2521
+ VersionChanged: 0.59
2522
+ Blacklist:
2523
+ - decrement!
2524
+ - decrement_counter
2525
+ - increment!
2526
+ - increment_counter
2527
+ - toggle!
2528
+ - touch
2529
+ - update_all
2530
+ - update_attribute
2531
+ - update_column
2532
+ - update_columns
2533
+ - update_counters
2534
+ Whitelist: []
2535
+
2536
+ Rails/TimeZone:
2537
+ Description: 'Checks the correct usage of time zone aware methods.'
2538
+ StyleGuide: 'https://github.com/rubocop-hq/rails-style-guide#time'
2539
+ Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
2540
+ Enabled: true
2541
+ VersionAdded: 0.30
2542
+ VersionChanged: 0.33
2543
+ # The value `strict` means that `Time` should be used with `zone`.
2544
+ # The value `flexible` allows usage of `in_time_zone` instead of `zone`.
2545
+ EnforcedStyle: flexible
2546
+ SupportedStyles:
2547
+ - strict
2548
+ - flexible
2549
+
2550
+ Rails/UniqBeforePluck:
2551
+ Description: 'Prefer the use of uniq or distinct before pluck.'
2552
+ Enabled: true
2553
+ VersionAdded: 0.40
2554
+ VersionChanged: 0.47
2555
+ EnforcedStyle: conservative
2556
+ SupportedStyles:
2557
+ - conservative
2558
+ - aggressive
2559
+ AutoCorrect: false
2560
+
2561
+ Rails/UnknownEnv:
2562
+ Description: 'Use correct environment name.'
2563
+ Enabled: true
2564
+ VersionAdded: 0.51
2565
+ Environments:
2566
+ - development
2567
+ - test
2568
+ - production
2569
+
2570
+ Rails/Validation:
2571
+ Description: 'Use validates :attribute, hash of validations.'
2572
+ Enabled: true
2573
+ VersionAdded: 0.9
2574
+ VersionChanged: 0.41
2575
+ Include:
2576
+ - app/models/**/*.rb
2577
+
2578
+ #################### Security ##############################
2579
+
2580
+ Security/Eval:
2581
+ Description: 'The use of eval represents a serious security risk.'
2582
+ Enabled: true
2583
+ VersionAdded: 0.47
2584
+
2585
+ Security/JSONLoad:
2586
+ Description: >-
2587
+ Prefer usage of `JSON.parse` over `JSON.load` due to potential
2588
+ security issues. See reference for more information.
2589
+ Reference: 'http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load'
2590
+ Enabled: true
2591
+ VersionAdded: 0.43
2592
+ VersionChanged: 0.44
2593
+ # Autocorrect here will change to a method that may cause crashes depending
2594
+ # on the value of the argument.
2595
+ AutoCorrect: false
2596
+ SafeAutoCorrect: false
2597
+
2598
+ Security/MarshalLoad:
2599
+ Description: >-
2600
+ Avoid using of `Marshal.load` or `Marshal.restore` due to potential
2601
+ security issues. See reference for more information.
2602
+ Reference: 'http://ruby-doc.org/core-2.3.3/Marshal.html#module-Marshal-label-Security+considerations'
2603
+ Enabled: true
2604
+ VersionAdded: 0.47
2605
+
2606
+ Security/Open:
2607
+ Description: 'The use of Kernel#open represents a serious security risk.'
2608
+ Enabled: true
2609
+ VersionAdded: 0.53
2610
+ Safe: false
2611
+
2612
+ Security/YAMLLoad:
2613
+ Description: >-
2614
+ Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
2615
+ security issues. See reference for more information.
2616
+ Reference: 'https://ruby-doc.org/stdlib-2.3.3/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
2617
+ Enabled: true
2618
+ VersionAdded: 0.47
2619
+ SafeAutoCorrect: false
2620
+
2621
+ #################### Style ###############################
2622
+
2623
+ Style/AccessModifierDeclarations:
2624
+ Description: 'Checks style of how access modifiers are used.'
2625
+ Enabled: true
2626
+ VersionAdded: 0.57
2627
+ EnforcedStyle: group
2628
+ SupportedStyles:
2629
+ - inline
2630
+ - group
2631
+
2632
+ Style/Alias:
2633
+ Description: 'Use alias instead of alias_method.'
2634
+ StyleGuide: '#alias-method'
2635
+ Enabled: true
2636
+ VersionAdded: 0.9
2637
+ VersionChanged: 0.36
2638
+ EnforcedStyle: prefer_alias
2639
+ SupportedStyles:
2640
+ - prefer_alias
2641
+ - prefer_alias_method
2642
+
2643
+ Style/AndOr:
2644
+ Description: 'Use &&/|| instead of and/or.'
2645
+ StyleGuide: '#no-and-or-or'
2646
+ Enabled: true
2647
+ VersionAdded: 0.9
2648
+ VersionChanged: 0.25
2649
+ # Whether `and` and `or` are banned only in conditionals (conditionals)
2650
+ # or completely (always).
2651
+ EnforcedStyle: always
2652
+ SupportedStyles:
2653
+ - always
2654
+ - conditionals
2655
+
2656
+ Style/ArrayJoin:
2657
+ Description: 'Use Array#join instead of Array#*.'
2658
+ StyleGuide: '#array-join'
2659
+ Enabled: true
2660
+ VersionAdded: 0.20
2661
+ VersionChanged: 0.31
2662
+
2663
+ Style/AsciiComments:
2664
+ Description: 'Use only ascii symbols in comments.'
2665
+ StyleGuide: '#english-comments'
2666
+ Enabled: true
2667
+ VersionAdded: 0.9
2668
+ VersionChanged: 0.52
2669
+ AllowedChars: []
2670
+
2671
+ Style/Attr:
2672
+ Description: 'Checks for uses of Module#attr.'
2673
+ StyleGuide: '#attr'
2674
+ Enabled: true
2675
+ VersionAdded: 0.9
2676
+ VersionChanged: 0.12
2677
+
2678
+ Style/AutoResourceCleanup:
2679
+ Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
2680
+ Enabled: false
2681
+ VersionAdded: 0.30
2682
+
2683
+ Style/BarePercentLiterals:
2684
+ Description: 'Checks if usage of %() or %Q() matches configuration.'
2685
+ StyleGuide: '#percent-q-shorthand'
2686
+ Enabled: true
2687
+ VersionAdded: 0.25
2688
+ EnforcedStyle: bare_percent
2689
+ SupportedStyles:
2690
+ - percent_q
848
2691
  - bare_percent
849
2692
 
2693
+ Style/BeginBlock:
2694
+ Description: 'Avoid the use of BEGIN blocks.'
2695
+ StyleGuide: '#no-BEGIN-blocks'
2696
+ Enabled: true
2697
+ VersionAdded: 0.9
2698
+
2699
+ Style/BlockComments:
2700
+ Description: 'Do not use block comments.'
2701
+ StyleGuide: '#no-block-comments'
2702
+ Enabled: true
2703
+ VersionAdded: 0.9
2704
+ VersionChanged: 0.23
2705
+
850
2706
  Style/BlockDelimiters:
2707
+ Description: >-
2708
+ Avoid using {...} for multi-line blocks (multiline chaining is
2709
+ always ugly).
2710
+ Prefer {...} over do...end for single-line blocks.
2711
+ StyleGuide: '#single-line-blocks'
2712
+ Enabled: true
2713
+ VersionAdded: 0.30
2714
+ VersionChanged: 0.35
851
2715
  EnforcedStyle: line_count_based
852
2716
  SupportedStyles:
853
2717
  # The `line_count_based` style enforces braces around single line blocks and
@@ -919,6 +2783,10 @@ Style/BlockDelimiters:
919
2783
  - it
920
2784
 
921
2785
  Style/BracesAroundHashParameters:
2786
+ Description: 'Enforce braces style around hash parameters.'
2787
+ Enabled: true
2788
+ VersionAdded: 0.14.1
2789
+ VersionChanged: 0.28
922
2790
  EnforcedStyle: no_braces
923
2791
  SupportedStyles:
924
2792
  # The `braces` style enforces braces around all method parameters that are
@@ -932,8 +2800,30 @@ Style/BracesAroundHashParameters:
932
2800
  # also a hash literal.
933
2801
  - context_dependent
934
2802
 
2803
+ Style/CaseEquality:
2804
+ Description: 'Avoid explicit use of the case equality operator(===).'
2805
+ StyleGuide: '#no-case-equality'
2806
+ Enabled: true
2807
+ VersionAdded: 0.9
2808
+
2809
+ Style/CharacterLiteral:
2810
+ Description: 'Checks for uses of character literals.'
2811
+ StyleGuide: '#no-character-literals'
2812
+ Enabled: true
2813
+ VersionAdded: 0.9
2814
+
935
2815
  Style/ClassAndModuleChildren:
936
- # Checks the style of children definitions at classes and modules.
2816
+ Description: 'Checks style of children classes and modules.'
2817
+ StyleGuide: '#namespace-definition'
2818
+ # Moving from compact to nested children requires knowledge of whether the
2819
+ # outer parent is a module or a class. Moving from nested to compact requires
2820
+ # verification that the outer parent is defined elsewhere. Rubocop does not
2821
+ # have the knowledge to perform either operation safely and thus requires
2822
+ # manual oversight.
2823
+ SafeAutoCorrect: false
2824
+ AutoCorrect: false
2825
+ Enabled: true
2826
+ VersionAdded: 0.19
937
2827
  #
938
2828
  # Basically there are two different styles:
939
2829
  #
@@ -954,17 +2844,39 @@ Style/ClassAndModuleChildren:
954
2844
  - compact
955
2845
 
956
2846
  Style/ClassCheck:
2847
+ Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.'
2848
+ Enabled: true
2849
+ VersionAdded: 0.24
957
2850
  EnforcedStyle: is_a?
958
2851
  SupportedStyles:
959
2852
  - is_a?
960
2853
  - kind_of?
961
2854
 
2855
+ Style/ClassMethods:
2856
+ Description: 'Use self when defining module/class methods.'
2857
+ StyleGuide: '#def-self-class-methods'
2858
+ Enabled: true
2859
+ VersionAdded: 0.9
2860
+ VersionChanged: 0.20
2861
+
2862
+ Style/ClassVars:
2863
+ Description: 'Avoid the use of class variables.'
2864
+ StyleGuide: '#no-class-vars'
2865
+ Enabled: true
2866
+ VersionAdded: 0.13
2867
+
962
2868
  # Align with the style guide.
963
2869
  Style/CollectionMethods:
964
- # Mapping from undesired method to desired_method
2870
+ Description: 'Preferred collection methods.'
2871
+ StyleGuide: '#map-find-select-reduce-size'
2872
+ Enabled: false
2873
+ VersionAdded: 0.9
2874
+ VersionChanged: 0.27
2875
+ Safe: false
2876
+ # Mapping from undesired method to desired method
965
2877
  # e.g. to use `detect` over `find`:
966
2878
  #
967
- # CollectionMethods:
2879
+ # Style/CollectionMethods:
968
2880
  # PreferredMethods:
969
2881
  # find: detect
970
2882
  PreferredMethods:
@@ -974,8 +2886,23 @@ Style/CollectionMethods:
974
2886
  detect: 'find'
975
2887
  find_all: 'select'
976
2888
 
977
- # Use '`' or '%x' around command literals.
2889
+ Style/ColonMethodCall:
2890
+ Description: 'Do not use :: for method call.'
2891
+ StyleGuide: '#double-colons'
2892
+ Enabled: true
2893
+ VersionAdded: 0.9
2894
+
2895
+ Style/ColonMethodDefinition:
2896
+ Description: 'Do not use :: for defining class methods.'
2897
+ StyleGuide: '#colon-method-definition'
2898
+ Enabled: true
2899
+ VersionAdded: 0.52
2900
+
978
2901
  Style/CommandLiteral:
2902
+ Description: 'Use `` or %x around command literals.'
2903
+ StyleGuide: '#percent-x'
2904
+ Enabled: true
2905
+ VersionAdded: 0.30
979
2906
  EnforcedStyle: backticks
980
2907
  # backticks: Always use backticks.
981
2908
  # percent_x: Always use `%x`.
@@ -990,6 +2917,13 @@ Style/CommandLiteral:
990
2917
 
991
2918
  # Checks formatting of special comments
992
2919
  Style/CommentAnnotation:
2920
+ Description: >-
2921
+ Checks formatting of special comments
2922
+ (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
2923
+ StyleGuide: '#annotate-keywords'
2924
+ Enabled: true
2925
+ VersionAdded: 0.10
2926
+ VersionChanged: 0.31
993
2927
  Keywords:
994
2928
  - TODO
995
2929
  - FIXME
@@ -997,7 +2931,19 @@ Style/CommentAnnotation:
997
2931
  - HACK
998
2932
  - REVIEW
999
2933
 
2934
+ Style/CommentedKeyword:
2935
+ Description: 'Do not place comments on the same line as certain keywords.'
2936
+ Enabled: true
2937
+ VersionAdded: 0.51
2938
+
1000
2939
  Style/ConditionalAssignment:
2940
+ Description: >-
2941
+ Use the return value of `if` and `case` statements for
2942
+ assignment to a variable and variable comparison instead
2943
+ of assigning that variable inside of each branch.
2944
+ Enabled: true
2945
+ VersionAdded: 0.36
2946
+ VersionChanged: 0.47
1001
2947
  EnforcedStyle: assign_to_condition
1002
2948
  SupportedStyles:
1003
2949
  - assign_to_condition
@@ -1030,46 +2976,178 @@ Style/ConditionalAssignment:
1030
2976
  # AutocorrectNotice: '# Copyright (c) 2015 Yahoo! Inc.'
1031
2977
  #
1032
2978
  Style/Copyright:
2979
+ Description: 'Include a copyright notice in each file before any code.'
2980
+ Enabled: false
2981
+ VersionAdded: 0.30
1033
2982
  Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
1034
2983
  AutocorrectNotice: ''
1035
2984
 
1036
- Style/DocumentationMethod:
1037
- RequireForNonPublicMethods: false
2985
+ Style/DateTime:
2986
+ Description: 'Use Date or Time over DateTime.'
2987
+ StyleGuide: '#date--time'
2988
+ Enabled: true
2989
+ VersionAdded: 0.51
2990
+ VersionChanged: 0.59
2991
+ AllowCoercion: false
2992
+
2993
+ Style/DefWithParentheses:
2994
+ Description: 'Use def with parentheses when there are arguments.'
2995
+ StyleGuide: '#method-parens'
2996
+ Enabled: true
2997
+ VersionAdded: 0.9
2998
+ VersionChanged: 0.12
2999
+
3000
+ Style/Dir:
3001
+ Description: >-
3002
+ Use the `__dir__` method to retrieve the canonicalized
3003
+ absolute path to the current file.
3004
+ Enabled: true
3005
+ VersionAdded: 0.50
3006
+
3007
+ Style/Documentation:
3008
+ Description: 'Document classes and non-namespace modules.'
3009
+ Enabled: true
3010
+ VersionAdded: 0.9
3011
+ Exclude:
3012
+ - 'spec/**/*'
3013
+ - 'test/**/*'
3014
+
3015
+ Style/DocumentationMethod:
3016
+ Description: 'Checks for missing documentation comment for public methods.'
3017
+ Enabled: false
3018
+ VersionAdded: 0.43
3019
+ Exclude:
3020
+ - 'spec/**/*'
3021
+ - 'test/**/*'
3022
+ RequireForNonPublicMethods: false
3023
+
3024
+ Style/DoubleNegation:
3025
+ Description: 'Checks for uses of double negation (!!).'
3026
+ StyleGuide: '#no-bang-bang'
3027
+ Enabled: true
3028
+ VersionAdded: 0.19
3029
+
3030
+ Style/EachForSimpleLoop:
3031
+ Description: >-
3032
+ Use `Integer#times` for a simple loop which iterates a fixed
3033
+ number of times.
3034
+ Enabled: true
3035
+ VersionAdded: 0.41
3036
+
3037
+ Style/EachWithObject:
3038
+ Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
3039
+ Enabled: true
3040
+ VersionAdded: 0.22
3041
+ VersionChanged: 0.42
3042
+
3043
+ Style/EmptyBlockParameter:
3044
+ Description: 'Omit pipes for empty block parameters.'
3045
+ Enabled: true
3046
+ VersionAdded: 0.52
3047
+
3048
+ Style/EmptyCaseCondition:
3049
+ Description: 'Avoid empty condition in case statements.'
3050
+ Enabled: true
3051
+ VersionAdded: 0.40
1038
3052
 
1039
- # Warn on empty else statements
1040
- # empty - warn only on empty `else`
1041
- # nil - warn on `else` with nil in it
1042
- # both - warn on empty `else` and `else` with `nil` in it
1043
3053
  Style/EmptyElse:
3054
+ Description: 'Avoid empty else-clauses.'
3055
+ Enabled: true
3056
+ VersionAdded: 0.28
3057
+ VersionChanged: 0.32
1044
3058
  EnforcedStyle: both
3059
+ # empty - warn only on empty `else`
3060
+ # nil - warn on `else` with nil in it
3061
+ # both - warn on empty `else` and `else` with `nil` in it
1045
3062
  SupportedStyles:
1046
3063
  - empty
1047
3064
  - nil
1048
3065
  - both
1049
3066
 
3067
+ Style/EmptyLambdaParameter:
3068
+ Description: 'Omit parens for empty lambda parameters.'
3069
+ Enabled: true
3070
+ VersionAdded: 0.52
3071
+
3072
+ Style/EmptyLiteral:
3073
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
3074
+ StyleGuide: '#literal-array-hash'
3075
+ Enabled: true
3076
+ VersionAdded: 0.9
3077
+ VersionChanged: 0.12
3078
+
1050
3079
  Style/EmptyMethod:
3080
+ Description: 'Checks the formatting of empty method definitions.'
3081
+ StyleGuide: '#no-single-line-methods'
3082
+ Enabled: true
3083
+ VersionAdded: 0.46
1051
3084
  EnforcedStyle: compact
1052
3085
  SupportedStyles:
1053
3086
  - compact
1054
3087
  - expanded
1055
3088
 
1056
- # Checks use of for or each in multiline loops.
3089
+ Style/Encoding:
3090
+ Description: 'Use UTF-8 as the source file encoding.'
3091
+ StyleGuide: '#utf-8'
3092
+ Enabled: true
3093
+ VersionAdded: 0.9
3094
+ VersionChanged: 0.50
3095
+
3096
+ Style/EndBlock:
3097
+ Description: 'Avoid the use of END blocks.'
3098
+ StyleGuide: '#no-END-blocks'
3099
+ Enabled: true
3100
+ VersionAdded: 0.9
3101
+
3102
+ Style/EvalWithLocation:
3103
+ Description: 'Pass `__FILE__` and `__LINE__` to `eval` method, as they are used by backtraces.'
3104
+ Enabled: true
3105
+ VersionAdded: 0.52
3106
+
3107
+ Style/EvenOdd:
3108
+ Description: 'Favor the use of Integer#even? && Integer#odd?'
3109
+ StyleGuide: '#predicate-methods'
3110
+ Enabled: true
3111
+ VersionAdded: 0.12
3112
+ VersionChanged: 0.29
3113
+
3114
+ Style/ExpandPathArguments:
3115
+ Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
3116
+ Enabled: true
3117
+ VersionAdded: 0.53
3118
+
3119
+ Style/FlipFlop:
3120
+ Description: 'Checks for flip flops'
3121
+ StyleGuide: '#no-flip-flops'
3122
+ Enabled: true
3123
+ VersionAdded: 0.16
3124
+
1057
3125
  Style/For:
3126
+ Description: 'Checks use of for or each in multiline loops.'
3127
+ StyleGuide: '#no-for-loops'
3128
+ Enabled: true
3129
+ VersionAdded: 0.13
3130
+ VersionChanged: 0.59
1058
3131
  EnforcedStyle: each
1059
3132
  SupportedStyles:
1060
3133
  - each
1061
3134
  - for
1062
3135
 
1063
- # Enforce the method used for string formatting.
1064
3136
  Style/FormatString:
3137
+ Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
3138
+ StyleGuide: '#sprintf'
3139
+ Enabled: true
3140
+ VersionAdded: 0.19
3141
+ VersionChanged: 0.49
1065
3142
  EnforcedStyle: format
1066
3143
  SupportedStyles:
1067
3144
  - format
1068
3145
  - sprintf
1069
3146
  - percent
1070
3147
 
1071
- # Enforce using either `%<token>s` or `%{token}`
1072
3148
  Style/FormatStringToken:
3149
+ Description: 'Use a consistent style for format string tokens.'
3150
+ Enabled: true
1073
3151
  EnforcedStyle: annotated
1074
3152
  SupportedStyles:
1075
3153
  # Prefer tokens which contain a sprintf like type annotation like
@@ -1078,8 +3156,16 @@ Style/FormatStringToken:
1078
3156
  # Prefer simple looking "template" style tokens like `%{name}`, `%{age}`
1079
3157
  - template
1080
3158
  - unannotated
3159
+ VersionAdded: 0.49
3160
+ VersionChanged: 0.52
1081
3161
 
1082
3162
  Style/FrozenStringLiteralComment:
3163
+ Description: >-
3164
+ Add the frozen_string_literal comment to the top of files
3165
+ to help transition from Ruby 2.3.0 to Ruby 3.0.
3166
+ Enabled: true
3167
+ VersionAdded: 0.36
3168
+ VersionChanged: 0.47
1083
3169
  EnforcedStyle: when_needed
1084
3170
  SupportedStyles:
1085
3171
  # `when_needed` will add the frozen string literal comment to files
@@ -1094,16 +3180,33 @@ Style/FrozenStringLiteralComment:
1094
3180
  # exist in a file.
1095
3181
  - never
1096
3182
 
1097
- # Built-in global variables are allowed by default.
1098
3183
  Style/GlobalVars:
3184
+ Description: 'Do not introduce global variables.'
3185
+ StyleGuide: '#instance-vars'
3186
+ Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
3187
+ Enabled: true
3188
+ VersionAdded: 0.13
3189
+ # Built-in global variables are allowed by default.
1099
3190
  AllowedVariables: []
1100
3191
 
1101
- # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
1102
- # needs to have to trigger this cop
1103
3192
  Style/GuardClause:
3193
+ Description: 'Check for conditionals that can be replaced with guard clauses'
3194
+ StyleGuide: '#no-nested-conditionals'
3195
+ Enabled: true
3196
+ VersionAdded: 0.20
3197
+ VersionChanged: 0.22
3198
+ # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
3199
+ # needs to have to trigger this cop
1104
3200
  MinBodyLength: 1
1105
3201
 
1106
3202
  Style/HashSyntax:
3203
+ Description: >-
3204
+ Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
3205
+ { :a => 1, :b => 2 }.
3206
+ StyleGuide: '#hash-literals'
3207
+ Enabled: true
3208
+ VersionAdded: 0.9
3209
+ VersionChanged: 0.43
1107
3210
  EnforcedStyle: ruby19
1108
3211
  SupportedStyles:
1109
3212
  # checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys
@@ -1119,7 +3222,66 @@ Style/HashSyntax:
1119
3222
  # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
1120
3223
  PreferHashRocketsForNonAlnumEndingSymbols: false
1121
3224
 
3225
+ Style/IdenticalConditionalBranches:
3226
+ Description: >-
3227
+ Checks that conditional statements do not have an identical
3228
+ line at the end of each branch, which can validly be moved
3229
+ out of the conditional.
3230
+ Enabled: true
3231
+ VersionAdded: 0.36
3232
+
3233
+ Style/IfInsideElse:
3234
+ Description: 'Finds if nodes inside else, which can be converted to elsif.'
3235
+ Enabled: true
3236
+ VersionAdded: 0.36
3237
+
3238
+ Style/IfUnlessModifier:
3239
+ Description: >-
3240
+ Favor modifier if/unless usage when you have a
3241
+ single-line body.
3242
+ StyleGuide: '#if-as-a-modifier'
3243
+ Enabled: true
3244
+ VersionAdded: 0.9
3245
+ VersionChanged: 0.30
3246
+
3247
+ Style/IfUnlessModifierOfIfUnless:
3248
+ Description: >-
3249
+ Avoid modifier if/unless usage on conditionals.
3250
+ Enabled: true
3251
+ VersionAdded: 0.39
3252
+
3253
+ Style/IfWithSemicolon:
3254
+ Description: 'Do not use if x; .... Use the ternary operator instead.'
3255
+ StyleGuide: '#no-semicolon-ifs'
3256
+ Enabled: true
3257
+ VersionAdded: 0.9
3258
+
3259
+ Style/ImplicitRuntimeError:
3260
+ Description: >-
3261
+ Use `raise` or `fail` with an explicit exception class and
3262
+ message, rather than just a message.
3263
+ Enabled: false
3264
+ VersionAdded: 0.41
3265
+
3266
+ Style/InfiniteLoop:
3267
+ Description: 'Use Kernel#loop for infinite loops.'
3268
+ StyleGuide: '#infinite-loop'
3269
+ Enabled: true
3270
+ VersionAdded: 0.26
3271
+ SafeAutoCorrect: false
3272
+
3273
+ Style/InlineComment:
3274
+ Description: 'Avoid trailing inline comments.'
3275
+ Enabled: false
3276
+ VersionAdded: 0.23
3277
+
1122
3278
  Style/InverseMethods:
3279
+ Description: >-
3280
+ Use the inverse method instead of `!.method`
3281
+ if an inverse method is defined.
3282
+ Enabled: true
3283
+ Safe: false
3284
+ VersionAdded: 0.48
1123
3285
  # `InverseMethods` are methods that can be inverted by a not (`not` or `!`)
1124
3286
  # The relationship of inverse methods only needs to be defined in one direction.
1125
3287
  # Keys and values both need to be defined as symbols.
@@ -1141,12 +3303,20 @@ Style/InverseMethods:
1141
3303
  :select!: :reject!
1142
3304
 
1143
3305
  Style/IpAddresses:
3306
+ Description: "Don't include literal IP addresses in code."
3307
+ Enabled: false
3308
+ VersionAdded: 0.58
1144
3309
  # Allow strings to be whitelisted
1145
3310
  Whitelist:
1146
3311
  - "::"
1147
3312
  # :: is a valid IPv6 address, but could potentially be legitimately in code
1148
3313
 
1149
3314
  Style/Lambda:
3315
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
3316
+ StyleGuide: '#lambda-multi-line'
3317
+ Enabled: true
3318
+ VersionAdded: 0.9
3319
+ VersionChanged: 0.40
1150
3320
  EnforcedStyle: line_count_dependent
1151
3321
  SupportedStyles:
1152
3322
  - line_count_dependent
@@ -1154,26 +3324,83 @@ Style/Lambda:
1154
3324
  - literal
1155
3325
 
1156
3326
  Style/LambdaCall:
3327
+ Description: 'Use lambda.call(...) instead of lambda.(...).'
3328
+ StyleGuide: '#proc-call'
3329
+ Enabled: true
3330
+ VersionAdded: 0.13.1
3331
+ VersionChanged: 0.14
1157
3332
  EnforcedStyle: call
1158
3333
  SupportedStyles:
1159
3334
  - call
1160
3335
  - braces
1161
3336
 
3337
+ Style/LineEndConcatenation:
3338
+ Description: >-
3339
+ Use \ instead of + or << to concatenate two string literals at
3340
+ line end.
3341
+ Enabled: true
3342
+ VersionAdded: 0.18
3343
+
1162
3344
  Style/MethodCallWithArgsParentheses:
3345
+ Description: 'Use parentheses for method calls with arguments.'
3346
+ StyleGuide: '#method-invocation-parens'
3347
+ Enabled: false
3348
+ VersionAdded: 0.47
3349
+ VersionChanged: 0.48
1163
3350
  IgnoreMacros: true
1164
3351
  IgnoredMethods: []
1165
3352
 
1166
3353
  Style/MethodCallWithoutArgsParentheses:
3354
+ Description: 'Do not use parentheses for method calls with no arguments.'
3355
+ StyleGuide: '#method-invocation-parens'
3356
+ Enabled: true
1167
3357
  IgnoredMethods: []
3358
+ VersionAdded: 0.47
3359
+ VersionChanged: 0.55
3360
+
3361
+ Style/MethodCalledOnDoEndBlock:
3362
+ Description: 'Avoid chaining a method call on a do...end block.'
3363
+ StyleGuide: '#single-line-blocks'
3364
+ Enabled: false
3365
+ VersionAdded: 0.14
1168
3366
 
1169
3367
  Style/MethodDefParentheses:
3368
+ Description: >-
3369
+ Checks if the method definitions have or don't have
3370
+ parentheses.
3371
+ StyleGuide: '#method-parens'
3372
+ Enabled: true
3373
+ VersionAdded: 0.16
3374
+ VersionChanged: 0.35
1170
3375
  EnforcedStyle: require_parentheses
1171
3376
  SupportedStyles:
1172
3377
  - require_parentheses
1173
3378
  - require_no_parentheses
1174
3379
  - require_no_parentheses_except_multiline
1175
3380
 
3381
+ Style/MethodMissingSuper:
3382
+ Description: Checks for `method_missing` to call `super`.
3383
+ StyleGuide: '#no-method-missing'
3384
+ Enabled: true
3385
+ VersionAdded: 0.56
3386
+
3387
+ Style/MinMax:
3388
+ Description: >-
3389
+ Use `Enumerable#minmax` instead of `Enumerable#min`
3390
+ and `Enumerable#max` in conjunction.'
3391
+ Enabled: true
3392
+ VersionAdded: 0.50
3393
+
1176
3394
  Style/MissingElse:
3395
+ Description: >-
3396
+ Require if/case expressions to have an else branches.
3397
+ If enabled, it is recommended that
3398
+ Style/UnlessElse and Style/EmptyElse be enabled.
3399
+ This will conflict with Style/EmptyElse if
3400
+ Style/EmptyElse is configured to style "both"
3401
+ Enabled: false
3402
+ VersionAdded: 0.30
3403
+ VersionChanged: 0.38
1177
3404
  EnforcedStyle: both
1178
3405
  SupportedStyles:
1179
3406
  # if - warn when an if expression is missing an else branch
@@ -1183,9 +3410,20 @@ Style/MissingElse:
1183
3410
  - case
1184
3411
  - both
1185
3412
 
1186
- # Checks the grouping of mixins (`include`, `extend`, `prepend`) in `class` and
1187
- # `module` bodies.
3413
+ Style/MissingRespondToMissing:
3414
+ Description: >-
3415
+ Checks if `method_missing` is implemented
3416
+ without implementing `respond_to_missing`.
3417
+ StyleGuide: '#no-method-missing'
3418
+ Enabled: true
3419
+ VersionAdded: 0.56
3420
+
1188
3421
  Style/MixinGrouping:
3422
+ Description: 'Checks for grouping of mixins in `class` and `module` bodies.'
3423
+ StyleGuide: '#mixin-grouping'
3424
+ Enabled: true
3425
+ VersionAdded: 0.48
3426
+ VersionChanged: 0.49
1189
3427
  EnforcedStyle: separated
1190
3428
  SupportedStyles:
1191
3429
  # separated: each mixed in module goes in a separate statement.
@@ -1193,19 +3431,84 @@ Style/MixinGrouping:
1193
3431
  - separated
1194
3432
  - grouped
1195
3433
 
3434
+ Style/MixinUsage:
3435
+ Description: 'Checks that `include`, `extend` and `prepend` exists at the top level.'
3436
+ Enabled: true
3437
+ VersionAdded: 0.51
3438
+
1196
3439
  Style/ModuleFunction:
3440
+ Description: 'Checks for usage of `extend self` in modules.'
3441
+ StyleGuide: '#module-function'
3442
+ Enabled: true
3443
+ VersionAdded: 0.11
3444
+ VersionChanged: 0.53
1197
3445
  EnforcedStyle: module_function
1198
3446
  SupportedStyles:
1199
3447
  - module_function
1200
3448
  - extend_self
1201
3449
 
3450
+ Style/MultilineBlockChain:
3451
+ Description: 'Avoid multi-line chains of blocks.'
3452
+ StyleGuide: '#single-line-blocks'
3453
+ Enabled: true
3454
+ VersionAdded: 0.13
3455
+
3456
+ Style/MultilineIfModifier:
3457
+ Description: 'Only use if/unless modifiers on single line statements.'
3458
+ StyleGuide: '#no-multiline-if-modifiers'
3459
+ Enabled: true
3460
+ VersionAdded: 0.45
3461
+
3462
+ Style/MultilineIfThen:
3463
+ Description: 'Do not use then for multi-line if/unless.'
3464
+ StyleGuide: '#no-then'
3465
+ Enabled: true
3466
+ VersionAdded: 0.9
3467
+ VersionChanged: 0.26
3468
+
1202
3469
  Style/MultilineMemoization:
3470
+ Description: 'Wrap multiline memoizations in a `begin` and `end` block.'
3471
+ Enabled: true
3472
+ VersionAdded: 0.44
3473
+ VersionChanged: 0.48
1203
3474
  EnforcedStyle: keyword
1204
3475
  SupportedStyles:
1205
3476
  - keyword
1206
3477
  - braces
1207
3478
 
3479
+ Style/MultilineMethodSignature:
3480
+ Description: 'Avoid multi-line method signatures.'
3481
+ Enabled: false
3482
+ VersionAdded: 0.59
3483
+
3484
+ Style/MultilineTernaryOperator:
3485
+ Description: >-
3486
+ Avoid multi-line ?: (the ternary operator);
3487
+ use if/unless instead.
3488
+ StyleGuide: '#no-multiline-ternary'
3489
+ Enabled: true
3490
+ VersionAdded: 0.9
3491
+
3492
+ Style/MultipleComparison:
3493
+ Description: >-
3494
+ Avoid comparing a variable with multiple items in a conditional,
3495
+ use Array#include? instead.
3496
+ Enabled: true
3497
+ VersionAdded: 0.49
3498
+
3499
+ Style/MutableConstant:
3500
+ Description: 'Do not assign mutable objects to constants.'
3501
+ Enabled: true
3502
+ VersionAdded: 0.34
3503
+
1208
3504
  Style/NegatedIf:
3505
+ Description: >-
3506
+ Favor unless over if for negative conditions
3507
+ (or control flow or).
3508
+ StyleGuide: '#unless-for-negatives'
3509
+ Enabled: true
3510
+ VersionAdded: 0.20
3511
+ VersionChanged: 0.48
1209
3512
  EnforcedStyle: both
1210
3513
  SupportedStyles:
1211
3514
  # both: prefix and postfix negated `if` should both use `unless`
@@ -1215,7 +3518,25 @@ Style/NegatedIf:
1215
3518
  - prefix
1216
3519
  - postfix
1217
3520
 
3521
+ Style/NegatedWhile:
3522
+ Description: 'Favor until over while for negative conditions.'
3523
+ StyleGuide: '#until-for-negatives'
3524
+ Enabled: true
3525
+ VersionAdded: 0.20
3526
+
3527
+ Style/NestedModifier:
3528
+ Description: 'Avoid using nested modifiers.'
3529
+ StyleGuide: '#no-nested-modifiers'
3530
+ Enabled: true
3531
+ VersionAdded: 0.35
3532
+
1218
3533
  Style/NestedParenthesizedCalls:
3534
+ Description: >-
3535
+ Parenthesize method calls which are nested inside the
3536
+ argument list of another parenthesized method call.
3537
+ Enabled: true
3538
+ VersionAdded: 0.36
3539
+ VersionChanged: 0.50
1219
3540
  Whitelist:
1220
3541
  - be
1221
3542
  - be_a
@@ -1235,7 +3556,18 @@ Style/NestedParenthesizedCalls:
1235
3556
  - respond_to
1236
3557
  - start_with
1237
3558
 
3559
+ Style/NestedTernaryOperator:
3560
+ Description: 'Use one expression per branch in a ternary operator.'
3561
+ StyleGuide: '#no-nested-ternary'
3562
+ Enabled: true
3563
+ VersionAdded: 0.9
3564
+
1238
3565
  Style/Next:
3566
+ Description: 'Use `next` to skip iteration instead of a condition at the end.'
3567
+ StyleGuide: '#no-nested-conditionals'
3568
+ Enabled: true
3569
+ VersionAdded: 0.22
3570
+ VersionChanged: 0.35
1239
3571
  # With `always` all conditions at the end of an iteration needs to be
1240
3572
  # replaced by next - with `skip_modifier_ifs` the modifier if like this one
1241
3573
  # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
@@ -1248,12 +3580,22 @@ Style/Next:
1248
3580
  - always
1249
3581
 
1250
3582
  Style/NilComparison:
3583
+ Description: 'Prefer x.nil? to x == nil.'
3584
+ StyleGuide: '#predicate-methods'
3585
+ Enabled: true
3586
+ VersionAdded: 0.12
3587
+ VersionChanged: 0.59
1251
3588
  EnforcedStyle: predicate
1252
3589
  SupportedStyles:
1253
3590
  - predicate
1254
3591
  - comparison
1255
3592
 
1256
3593
  Style/NonNilCheck:
3594
+ Description: 'Checks for redundant nil checks.'
3595
+ StyleGuide: '#no-non-nil-checks'
3596
+ Enabled: true
3597
+ VersionAdded: 0.20
3598
+ VersionChanged: 0.22
1257
3599
  # With `IncludeSemanticChanges` set to `true`, this cop reports offenses for
1258
3600
  # `!x.nil?` and autocorrects that and `x != nil` to solely `x`, which is
1259
3601
  # **usually** OK, but might change behavior.
@@ -1262,17 +3604,49 @@ Style/NonNilCheck:
1262
3604
  # offenses for `!x.nil?` and does no changes that might change behavior.
1263
3605
  IncludeSemanticChanges: false
1264
3606
 
1265
- Style/NumericLiterals:
1266
- MinDigits: 5
1267
- Strict: false
3607
+ Style/Not:
3608
+ Description: 'Use ! instead of not.'
3609
+ StyleGuide: '#bang-not-not'
3610
+ Enabled: true
3611
+ VersionAdded: 0.9
3612
+ VersionChanged: 0.20
1268
3613
 
1269
3614
  Style/NumericLiteralPrefix:
3615
+ Description: 'Use smallcase prefixes for numeric literals.'
3616
+ StyleGuide: '#numeric-literal-prefixes'
3617
+ Enabled: true
3618
+ VersionAdded: 0.41
1270
3619
  EnforcedOctalStyle: zero_with_o
1271
3620
  SupportedOctalStyles:
1272
3621
  - zero_with_o
1273
3622
  - zero_only
1274
3623
 
3624
+
3625
+ Style/NumericLiterals:
3626
+ Description: >-
3627
+ Add underscores to large numeric literals to improve their
3628
+ readability.
3629
+ StyleGuide: '#underscores-in-numerics'
3630
+ Enabled: true
3631
+ VersionAdded: 0.9
3632
+ VersionChanged: 0.48
3633
+ MinDigits: 5
3634
+ Strict: false
3635
+
1275
3636
  Style/NumericPredicate:
3637
+ Description: >-
3638
+ Checks for the use of predicate- or comparison methods for
3639
+ numeric comparisons.
3640
+ StyleGuide: '#predicate-methods'
3641
+ Safe: false
3642
+ # This will change to a new method call which isn't guaranteed to be on the
3643
+ # object. Switching these methods has to be done with knowledge of the types
3644
+ # of the variables which rubocop doesn't have.
3645
+ SafeAutoCorrect: false
3646
+ AutoCorrect: false
3647
+ Enabled: true
3648
+ VersionAdded: 0.42
3649
+ VersionChanged: 0.59
1276
3650
  EnforcedStyle: predicate
1277
3651
  SupportedStyles:
1278
3652
  - predicate
@@ -1283,7 +3657,20 @@ Style/NumericPredicate:
1283
3657
  Exclude:
1284
3658
  - 'spec/**/*'
1285
3659
 
3660
+ Style/OneLineConditional:
3661
+ Description: >-
3662
+ Favor the ternary operator(?:) over
3663
+ if/then/else/end constructs.
3664
+ StyleGuide: '#ternary-operator'
3665
+ Enabled: true
3666
+ VersionAdded: 0.9
3667
+ VersionChanged: 0.38
3668
+
1286
3669
  Style/OptionHash:
3670
+ Description: "Don't use option hashes when you can use keyword arguments."
3671
+ Enabled: false
3672
+ VersionAdded: 0.33
3673
+ VersionChanged: 0.34
1287
3674
  # A list of parameter names that will be flagged by this cop.
1288
3675
  SuspiciousParamNames:
1289
3676
  - options
@@ -1292,12 +3679,45 @@ Style/OptionHash:
1292
3679
  - params
1293
3680
  - parameters
1294
3681
 
1295
- # Allow safe assignment in conditions.
3682
+ Style/OptionalArguments:
3683
+ Description: >-
3684
+ Checks for optional arguments that do not appear at the end
3685
+ of the argument list
3686
+ StyleGuide: '#optional-arguments'
3687
+ Enabled: true
3688
+ VersionAdded: 0.33
3689
+
3690
+ Style/OrAssignment:
3691
+ Description: 'Recommend usage of double pipe equals (||=) where applicable.'
3692
+ StyleGuide: '#double-pipe-for-uninit'
3693
+ Enabled: true
3694
+ VersionAdded: 0.50
3695
+
3696
+ Style/ParallelAssignment:
3697
+ Description: >-
3698
+ Check for simple usages of parallel assignment.
3699
+ It will only warn when the number of variables
3700
+ matches on both sides of the assignment.
3701
+ StyleGuide: '#parallel-assignment'
3702
+ Enabled: true
3703
+ VersionAdded: 0.32
3704
+
1296
3705
  Style/ParenthesesAroundCondition:
3706
+ Description: >-
3707
+ Don't use parentheses around the condition of an
3708
+ if/unless/while.
3709
+ StyleGuide: '#no-parens-around-condition'
3710
+ Enabled: true
3711
+ VersionAdded: 0.9
3712
+ VersionChanged: 0.56
1297
3713
  AllowSafeAssignment: true
1298
3714
  AllowInMultilineConditions: false
1299
3715
 
1300
3716
  Style/PercentLiteralDelimiters:
3717
+ Description: 'Use `%`-literal delimiters consistently'
3718
+ StyleGuide: '#percent-literal-braces'
3719
+ Enabled: true
3720
+ VersionAdded: 0.19
1301
3721
  # Specify the default preferred delimiter for all types with the 'default' key
1302
3722
  # Override individual delimiters (even with default specified) by specifying
1303
3723
  # an individual key
@@ -1308,31 +3728,111 @@ Style/PercentLiteralDelimiters:
1308
3728
  '%r': '{}'
1309
3729
  '%w': '[]'
1310
3730
  '%W': '[]'
3731
+ VersionChanged: 0.48.1
1311
3732
 
1312
3733
  Style/PercentQLiterals:
3734
+ Description: 'Checks if uses of %Q/%q match the configured preference.'
3735
+ Enabled: true
3736
+ VersionAdded: 0.25
1313
3737
  EnforcedStyle: lower_case_q
1314
3738
  SupportedStyles:
1315
3739
  - lower_case_q # Use `%q` when possible, `%Q` when necessary
1316
3740
  - upper_case_q # Always use `%Q`
1317
3741
 
3742
+ Style/PerlBackrefs:
3743
+ Description: 'Avoid Perl-style regex back references.'
3744
+ StyleGuide: '#no-perl-regexp-last-matchers'
3745
+ Enabled: true
3746
+ VersionAdded: 0.13
3747
+
1318
3748
  Style/PreferredHashMethods:
3749
+ Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
3750
+ StyleGuide: '#hash-key'
3751
+ Enabled: true
3752
+ VersionAdded: 0.41
3753
+ VersionChanged: 0.44
1319
3754
  EnforcedStyle: short
1320
3755
  SupportedStyles:
1321
3756
  - short
1322
3757
  - verbose
1323
3758
 
3759
+ Style/Proc:
3760
+ Description: 'Use proc instead of Proc.new.'
3761
+ StyleGuide: '#proc'
3762
+ Enabled: true
3763
+ VersionAdded: 0.9
3764
+ VersionChanged: 0.18
3765
+
1324
3766
  Style/RaiseArgs:
3767
+ Description: 'Checks the arguments passed to raise/fail.'
3768
+ StyleGuide: '#exception-class-messages'
3769
+ Enabled: true
3770
+ VersionAdded: 0.14
3771
+ VersionChanged: 0.40
1325
3772
  EnforcedStyle: exploded
1326
3773
  SupportedStyles:
1327
3774
  - compact # raise Exception.new(msg)
1328
3775
  - exploded # raise Exception, msg
1329
3776
 
3777
+ Style/RandomWithOffset:
3778
+ Description: >-
3779
+ Prefer to use ranges when generating random numbers instead of
3780
+ integers with offsets.
3781
+ StyleGuide: '#random-numbers'
3782
+ Enabled: true
3783
+ VersionAdded: 0.52
3784
+
3785
+ Style/RedundantBegin:
3786
+ Description: "Don't use begin blocks when they are not needed."
3787
+ StyleGuide: '#begin-implicit'
3788
+ Enabled: true
3789
+ VersionAdded: 0.10
3790
+ VersionChanged: 0.21
3791
+
3792
+ Style/RedundantConditional:
3793
+ Description: "Don't return true/false from a conditional."
3794
+ Enabled: true
3795
+ VersionAdded: 0.50
3796
+
3797
+ Style/RedundantException:
3798
+ Description: "Checks for an obsolete RuntimeException argument in raise/fail."
3799
+ StyleGuide: '#no-explicit-runtimeerror'
3800
+ Enabled: true
3801
+ VersionAdded: 0.14
3802
+ VersionChanged: 0.29
3803
+
3804
+ Style/RedundantFreeze:
3805
+ Description: "Checks usages of Object#freeze on immutable objects."
3806
+ Enabled: true
3807
+ VersionAdded: 0.34
3808
+
3809
+ Style/RedundantParentheses:
3810
+ Description: "Checks for parentheses that seem not to serve any purpose."
3811
+ Enabled: true
3812
+ VersionAdded: 0.36
3813
+
1330
3814
  Style/RedundantReturn:
3815
+ Description: "Don't use return where it's not required."
3816
+ StyleGuide: '#no-explicit-return'
3817
+ Enabled: true
3818
+ VersionAdded: 0.10
3819
+ VersionChanged: 0.14
1331
3820
  # When `true` allows code like `return x, y`.
1332
3821
  AllowMultipleReturnValues: false
1333
3822
 
1334
- # Use `/` or `%r` around regular expressions.
3823
+ Style/RedundantSelf:
3824
+ Description: "Don't use self where it's not needed."
3825
+ StyleGuide: '#no-self-unless-required'
3826
+ Enabled: true
3827
+ VersionAdded: 0.10
3828
+ VersionChanged: 0.13
3829
+
1335
3830
  Style/RegexpLiteral:
3831
+ Description: 'Use / or %r around regular expressions.'
3832
+ StyleGuide: '#percent-r'
3833
+ Enabled: true
3834
+ VersionAdded: 0.9
3835
+ VersionChanged: 0.30
1336
3836
  EnforcedStyle: slashes
1337
3837
  # slashes: Always use slashes.
1338
3838
  # percent_r: Always use `%r`.
@@ -1345,7 +3845,17 @@ Style/RegexpLiteral:
1345
3845
  # are found in the regexp string.
1346
3846
  AllowInnerSlashes: false
1347
3847
 
3848
+ Style/RescueModifier:
3849
+ Description: 'Avoid using rescue in its modifier form.'
3850
+ StyleGuide: '#no-rescue-modifiers'
3851
+ Enabled: true
3852
+ VersionAdded: 0.9
3853
+ VersionChanged: 0.34
3854
+
1348
3855
  Style/RescueStandardError:
3856
+ Description: 'Avoid rescuing without specifying an error class.'
3857
+ Enabled: true
3858
+ VersionAdded: 0.52
1349
3859
  EnforcedStyle: explicit
1350
3860
  # implicit: Do not include the error class, `rescue`
1351
3861
  # explicit: Require an error class `rescue StandardError`
@@ -1354,12 +3864,22 @@ Style/RescueStandardError:
1354
3864
  - explicit
1355
3865
 
1356
3866
  Style/ReturnNil:
3867
+ Description: 'Use return instead of return nil.'
3868
+ Enabled: false
1357
3869
  EnforcedStyle: return
1358
3870
  SupportedStyles:
1359
3871
  - return
1360
3872
  - return_nil
3873
+ VersionAdded: 0.50
1361
3874
 
1362
3875
  Style/SafeNavigation:
3876
+ Description: >-
3877
+ This cop transforms usages of a method call safeguarded by
3878
+ a check for the existence of the object to
3879
+ safe navigation (`&.`).
3880
+ Enabled: true
3881
+ VersionAdded: 0.43
3882
+ VersionChanged: 0.44
1363
3883
  # Safe navigation may cause a statement to start returning `nil` in addition
1364
3884
  # to whatever it used to return.
1365
3885
  ConvertCodeThatCanStartToReturnNil: false
@@ -1369,12 +3889,38 @@ Style/SafeNavigation:
1369
3889
  - presence
1370
3890
  - try
1371
3891
  - try!
3892
+ VersionChanged: 0.56
3893
+
3894
+ Style/SelfAssignment:
3895
+ Description: >-
3896
+ Checks for places where self-assignment shorthand should have
3897
+ been used.
3898
+ StyleGuide: '#self-assignment'
3899
+ Enabled: true
3900
+ VersionAdded: 0.19
3901
+ VersionChanged: 0.29
1372
3902
 
1373
3903
  Style/Semicolon:
3904
+ Description: "Don't use semicolons to terminate expressions."
3905
+ StyleGuide: '#no-semicolon'
3906
+ Enabled: true
3907
+ VersionAdded: 0.9
3908
+ VersionChanged: 0.19
1374
3909
  # Allow `;` to separate several expressions on the same line.
1375
3910
  AllowAsExpressionSeparator: false
1376
3911
 
3912
+ Style/Send:
3913
+ Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
3914
+ StyleGuide: '#prefer-public-send'
3915
+ Enabled: false
3916
+ VersionAdded: 0.33
3917
+
1377
3918
  Style/SignalException:
3919
+ Description: 'Checks for proper usage of fail and raise.'
3920
+ StyleGuide: '#prefer-raise-over-fail'
3921
+ Enabled: true
3922
+ VersionAdded: 0.11
3923
+ VersionChanged: 0.37
1378
3924
  EnforcedStyle: only_raise
1379
3925
  SupportedStyles:
1380
3926
  - only_raise
@@ -1382,6 +3928,10 @@ Style/SignalException:
1382
3928
  - semantic
1383
3929
 
1384
3930
  Style/SingleLineBlockParams:
3931
+ Description: 'Enforces the names of some block params.'
3932
+ Enabled: false
3933
+ VersionAdded: 0.16
3934
+ VersionChanged: 0.47
1385
3935
  Methods:
1386
3936
  - reduce:
1387
3937
  - acc
@@ -1391,21 +3941,53 @@ Style/SingleLineBlockParams:
1391
3941
  - elem
1392
3942
 
1393
3943
  Style/SingleLineMethods:
3944
+ Description: 'Avoid single-line methods.'
3945
+ StyleGuide: '#no-single-line-methods'
3946
+ Enabled: true
3947
+ VersionAdded: 0.9
3948
+ VersionChanged: 0.19
1394
3949
  AllowIfMethodIsEmpty: true
1395
3950
 
1396
3951
  Style/SpecialGlobalVars:
3952
+ Description: 'Avoid Perl-style global variables.'
3953
+ StyleGuide: '#no-cryptic-perlisms'
3954
+ Enabled: true
3955
+ VersionAdded: 0.13
3956
+ VersionChanged: 0.36
3957
+ SafeAutoCorrect: false
1397
3958
  EnforcedStyle: use_english_names
1398
3959
  SupportedStyles:
1399
3960
  - use_perl_names
1400
3961
  - use_english_names
1401
3962
 
1402
3963
  Style/StabbyLambdaParentheses:
3964
+ Description: 'Check for the usage of parentheses around stabby lambda arguments.'
3965
+ StyleGuide: '#stabby-lambda-with-args'
3966
+ Enabled: true
3967
+ VersionAdded: 0.35
1403
3968
  EnforcedStyle: require_parentheses
1404
3969
  SupportedStyles:
1405
3970
  - require_parentheses
1406
3971
  - require_no_parentheses
1407
3972
 
3973
+ Style/StderrPuts:
3974
+ Description: 'Use `warn` instead of `$stderr.puts`.'
3975
+ StyleGuide: '#warn'
3976
+ Enabled: true
3977
+ VersionAdded: 0.51
3978
+
3979
+ Style/StringHashKeys:
3980
+ Description: 'Prefer symbols instead of strings as hash keys.'
3981
+ StyleGuide: '#symbols-as-keys'
3982
+ Enabled: false
3983
+ VersionAdded: 0.52
3984
+
1408
3985
  Style/StringLiterals:
3986
+ Description: 'Checks if uses of quotes match the configured preference.'
3987
+ StyleGuide: '#consistent-string-literals'
3988
+ Enabled: true
3989
+ VersionAdded: 0.9
3990
+ VersionChanged: 0.36
1409
3991
  EnforcedStyle: single_quotes
1410
3992
  SupportedStyles:
1411
3993
  - single_quotes
@@ -1415,12 +3997,21 @@ Style/StringLiterals:
1415
3997
  ConsistentQuotesInMultiline: false
1416
3998
 
1417
3999
  Style/StringLiteralsInInterpolation:
4000
+ Description: >-
4001
+ Checks if uses of quotes inside expressions in interpolated
4002
+ strings match the configured preference.
4003
+ Enabled: true
4004
+ VersionAdded: 0.27
1418
4005
  EnforcedStyle: single_quotes
1419
4006
  SupportedStyles:
1420
4007
  - single_quotes
1421
4008
  - double_quotes
1422
4009
 
1423
4010
  Style/StringMethods:
4011
+ Description: 'Checks if configured preferred methods are used over non-preferred.'
4012
+ Enabled: false
4013
+ VersionAdded: 0.34
4014
+ VersionChanged: 0.34.2
1424
4015
  # Mapping from undesired method to desired_method
1425
4016
  # e.g. to use `to_sym` over `intern`:
1426
4017
  #
@@ -1430,14 +4021,34 @@ Style/StringMethods:
1430
4021
  PreferredMethods:
1431
4022
  intern: to_sym
1432
4023
 
4024
+ Style/StructInheritance:
4025
+ Description: 'Checks for inheritance from Struct.new.'
4026
+ StyleGuide: '#no-extend-struct-new'
4027
+ Enabled: true
4028
+ VersionAdded: 0.29
4029
+
1433
4030
  Style/SymbolArray:
4031
+ Description: 'Use %i or %I for arrays of symbols.'
4032
+ StyleGuide: '#percent-i'
4033
+ Enabled: true
4034
+ VersionAdded: 0.9
4035
+ VersionChanged: 0.49
1434
4036
  EnforcedStyle: percent
1435
4037
  MinSize: 2
1436
4038
  SupportedStyles:
1437
4039
  - percent
1438
4040
  - brackets
1439
4041
 
4042
+ Style/SymbolLiteral:
4043
+ Description: 'Use plain symbols instead of string symbols when possible.'
4044
+ Enabled: true
4045
+ VersionAdded: 0.30
4046
+
1440
4047
  Style/SymbolProc:
4048
+ Description: 'Use symbols as procs instead of blocks when possible.'
4049
+ Enabled: true
4050
+ VersionAdded: 0.26
4051
+ VersionChanged: 0.40
1441
4052
  # A list of method names to be ignored by the check.
1442
4053
  # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
1443
4054
  IgnoredMethods:
@@ -1445,6 +4056,10 @@ Style/SymbolProc:
1445
4056
  - define_method
1446
4057
 
1447
4058
  Style/TernaryParentheses:
4059
+ Description: 'Checks for use of parentheses around ternary conditions.'
4060
+ Enabled: true
4061
+ VersionAdded: 0.42
4062
+ VersionChanged: 0.46
1448
4063
  EnforcedStyle: require_no_parentheses
1449
4064
  SupportedStyles:
1450
4065
  - require_parentheses
@@ -1452,7 +4067,26 @@ Style/TernaryParentheses:
1452
4067
  - require_parentheses_when_complex
1453
4068
  AllowSafeAssignment: true
1454
4069
 
4070
+ Style/TrailingBodyOnClass:
4071
+ Description: 'Class body goes below class statement.'
4072
+ Enabled: true
4073
+ VersionAdded: 0.53
4074
+
4075
+ Style/TrailingBodyOnMethodDefinition:
4076
+ Description: 'Method body goes below definition.'
4077
+ Enabled: true
4078
+ VersionAdded: 0.52
4079
+
4080
+ Style/TrailingBodyOnModule:
4081
+ Description: 'Module body goes below module statement.'
4082
+ Enabled: true
4083
+ VersionAdded: 0.53
4084
+
1455
4085
  Style/TrailingCommaInArguments:
4086
+ Description: 'Checks for trailing comma in argument lists.'
4087
+ StyleGuide: '#no-trailing-params-comma'
4088
+ Enabled: true
4089
+ VersionAdded: 0.36
1456
4090
  # If `comma`, the cop requires a comma after the last argument, but only for
1457
4091
  # parenthesized method calls where each argument is on its own line.
1458
4092
  # If `consistent_comma`, the cop requires a comma after the last argument,
@@ -1464,7 +4098,10 @@ Style/TrailingCommaInArguments:
1464
4098
  - no_comma
1465
4099
 
1466
4100
  Style/TrailingCommaInArrayLiteral:
1467
- # If `comma`, the cop requires a comma after the last item in an array,
4101
+ Description: 'Checks for trailing comma in array literals.'
4102
+ StyleGuide: '#no-trailing-array-commas'
4103
+ Enabled: true
4104
+ VersionAdded: 0.53
1468
4105
  # but only when each item is on its own line.
1469
4106
  # If `consistent_comma`, the cop requires a comma after the last item of all
1470
4107
  # non-empty array literals.
@@ -1475,6 +4112,8 @@ Style/TrailingCommaInArrayLiteral:
1475
4112
  - no_comma
1476
4113
 
1477
4114
  Style/TrailingCommaInHashLiteral:
4115
+ Description: 'Checks for trailing comma in hash literals.'
4116
+ Enabled: true
1478
4117
  # If `comma`, the cop requires a comma after the last item in a hash,
1479
4118
  # but only when each item is on its own line.
1480
4119
  # If `consistent_comma`, the cop requires a comma after the last item of all
@@ -1484,10 +4123,30 @@ Style/TrailingCommaInHashLiteral:
1484
4123
  - comma
1485
4124
  - consistent_comma
1486
4125
  - no_comma
4126
+ VersionAdded: 0.53
4127
+
4128
+ Style/TrailingMethodEndStatement:
4129
+ Description: 'Checks for trailing end statement on line of method body.'
4130
+ Enabled: true
4131
+ VersionAdded: 0.52
4132
+
4133
+ Style/TrailingUnderscoreVariable:
4134
+ Description: >-
4135
+ Checks for the usage of unneeded trailing underscores at the
4136
+ end of parallel variable assignment.
4137
+ AllowNamedUnderscoreVariables: true
4138
+ Enabled: true
4139
+ VersionAdded: 0.31
4140
+ VersionChanged: 0.35
1487
4141
 
1488
4142
  # `TrivialAccessors` requires exact name matches and doesn't allow
1489
4143
  # predicated methods by default.
1490
4144
  Style/TrivialAccessors:
4145
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
4146
+ StyleGuide: '#attr_family'
4147
+ Enabled: true
4148
+ VersionAdded: 0.9
4149
+ VersionChanged: 0.38
1491
4150
  # When set to `false` the cop will suggest the use of accessor methods
1492
4151
  # in situations like:
1493
4152
  #
@@ -1527,8 +4186,79 @@ Style/TrivialAccessors:
1527
4186
  - to_s
1528
4187
  - to_sym
1529
4188
 
1530
- # `WordArray` enforces how array literals of word-like strings should be expressed.
4189
+ Style/UnlessElse:
4190
+ Description: >-
4191
+ Do not use unless with else. Rewrite these with the positive
4192
+ case first.
4193
+ StyleGuide: '#no-else-with-unless'
4194
+ Enabled: true
4195
+ VersionAdded: 0.9
4196
+
4197
+ Style/UnneededCapitalW:
4198
+ Description: 'Checks for %W when interpolation is not needed.'
4199
+ Enabled: true
4200
+ VersionAdded: 0.21
4201
+ VersionChanged: 0.24
4202
+
4203
+ Style/UnneededCondition:
4204
+ Description: 'Checks for unnecessary conditional expressions.'
4205
+ Enabled: true
4206
+ VersionAdded: 0.57
4207
+
4208
+ Style/UnneededInterpolation:
4209
+ Description: 'Checks for strings that are just an interpolated expression.'
4210
+ Enabled: true
4211
+ VersionAdded: 0.36
4212
+
4213
+ Style/UnneededPercentQ:
4214
+ Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
4215
+ StyleGuide: '#percent-q'
4216
+ Enabled: true
4217
+ VersionAdded: 0.24
4218
+
4219
+ Style/UnpackFirst:
4220
+ Description: >-
4221
+ Checks for accessing the first element of `String#unpack`
4222
+ instead of using `unpack1`
4223
+ Enabled: true
4224
+ VersionAdded: 0.54
4225
+
4226
+ Style/VariableInterpolation:
4227
+ Description: >-
4228
+ Don't interpolate global, instance and class variables
4229
+ directly in strings.
4230
+ StyleGuide: '#curlies-interpolate'
4231
+ Enabled: true
4232
+ VersionAdded: 0.9
4233
+ VersionChanged: 0.20
4234
+
4235
+ Style/WhenThen:
4236
+ Description: 'Use when x then ... for one-line cases.'
4237
+ StyleGuide: '#one-line-cases'
4238
+ Enabled: true
4239
+ VersionAdded: 0.9
4240
+
4241
+ Style/WhileUntilDo:
4242
+ Description: 'Checks for redundant do after while or until.'
4243
+ StyleGuide: '#no-multiline-while-do'
4244
+ Enabled: true
4245
+ VersionAdded: 0.9
4246
+
4247
+ Style/WhileUntilModifier:
4248
+ Description: >-
4249
+ Favor modifier while/until usage when you have a
4250
+ single-line body.
4251
+ StyleGuide: '#while-as-a-modifier'
4252
+ Enabled: true
4253
+ VersionAdded: 0.9
4254
+ VersionChanged: 0.30
4255
+
1531
4256
  Style/WordArray:
4257
+ Description: 'Use %w or %W for arrays of words.'
4258
+ StyleGuide: '#percent-w'
4259
+ Enabled: true
4260
+ VersionAdded: 0.9
4261
+ VersionChanged: 0.36
1532
4262
  EnforcedStyle: percent
1533
4263
  SupportedStyles:
1534
4264
  # percent style: %w(word1 word2)
@@ -1543,343 +4273,21 @@ Style/WordArray:
1543
4273
  WordRegex: !ruby/regexp '/\A[\p{Word}\n\t]+\z/'
1544
4274
 
1545
4275
  Style/YodaCondition:
4276
+ Description: 'Do not use literals as the first operand of a comparison.'
4277
+ Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
4278
+ Enabled: true
1546
4279
  EnforcedStyle: all_comparison_operators
1547
4280
  SupportedStyles:
1548
4281
  # check all comparison operators
1549
4282
  - all_comparison_operators
1550
4283
  # check only equality operators: `!=` and `==`
1551
4284
  - equality_operators_only
1552
-
1553
- #################### Metrics ###############################
1554
-
1555
- Metrics/AbcSize:
1556
- # The ABC size is a calculated magnitude, so this number can be an Integer or
1557
- # a Float.
1558
- Max: 15
1559
-
1560
- Metrics/BlockLength:
1561
- CountComments: false # count full line comments?
1562
- Max: 25
1563
- ExcludedMethods:
1564
- # By default, exclude the `#refine` method, as it tends to have larger
1565
- # associated blocks.
1566
- - refine
1567
-
1568
- Metrics/BlockNesting:
1569
- CountBlocks: false
1570
- Max: 3
1571
-
1572
- Metrics/ClassLength:
1573
- CountComments: false # count full line comments?
1574
- Max: 100
1575
-
1576
- # Avoid complex methods.
1577
- Metrics/CyclomaticComplexity:
1578
- Max: 6
1579
-
1580
- Metrics/LineLength:
1581
- Max: 80
1582
- # To make it possible to copy or click on URIs in the code, we allow lines
1583
- # containing a URI to be longer than Max.
1584
- AllowHeredoc: true
1585
- AllowURI: true
1586
- URISchemes:
1587
- - http
1588
- - https
1589
- # The IgnoreCopDirectives option causes the LineLength rule to ignore cop
1590
- # directives like '# rubocop: enable ...' when calculating a line's length.
1591
- IgnoreCopDirectives: false
1592
- # The IgnoredPatterns option is a list of !ruby/regexp and/or string
1593
- # elements. Strings will be converted to Regexp objects. A line that matches
1594
- # any regular expression listed in this option will be ignored by LineLength.
1595
- IgnoredPatterns: []
1596
-
1597
- Metrics/MethodLength:
1598
- CountComments: false # count full line comments?
1599
- Max: 10
1600
- ExcludedMethods: []
1601
-
1602
- Metrics/ModuleLength:
1603
- CountComments: false # count full line comments?
1604
- Max: 100
1605
-
1606
- Metrics/ParameterLists:
1607
- Max: 5
1608
- CountKeywordArgs: true
1609
-
1610
- Metrics/PerceivedComplexity:
1611
- Max: 7
1612
-
1613
- #################### Lint ##################################
1614
-
1615
- # Allow safe assignment in conditions.
1616
- Lint/AssignmentInCondition:
1617
- AllowSafeAssignment: true
1618
-
1619
- Lint/InheritException:
1620
- # The default base class in favour of `Exception`.
1621
- EnforcedStyle: runtime_error
1622
- SupportedStyles:
1623
- - runtime_error
1624
- - standard_error
1625
-
1626
- Lint/MissingCopEnableDirective:
1627
- # Maximum number of consecutive lines the cop can be disabled for.
1628
- # 0 allows only single-line disables
1629
- # 1 would mean the maximum allowed is the following:
1630
- # # rubocop:disable SomeCop
1631
- # a = 1
1632
- # # rubocop:enable SomeCop
1633
- # .inf for any size
1634
- MaximumRangeSize: .inf
1635
-
1636
- Lint/SafeNavigationChain:
1637
- Whitelist:
1638
- - present?
1639
- - blank?
1640
- - presence
1641
- - try
1642
- - try!
1643
-
1644
- Lint/SafeNavigationConsistency:
1645
- Whitelist:
1646
- - present?
1647
- - blank?
1648
- - presence
1649
- - try
1650
- - try!
1651
-
1652
- # Checks for shadowed arguments
1653
- Lint/ShadowedArgument:
1654
- IgnoreImplicitReferences: false
1655
-
1656
- # Checks for unused block arguments
1657
- Lint/UnusedBlockArgument:
1658
- IgnoreEmptyBlocks: true
1659
- AllowUnusedKeywordArguments: false
1660
-
1661
- # Checks for unused method arguments.
1662
- Lint/UnusedMethodArgument:
1663
- AllowUnusedKeywordArguments: false
1664
- IgnoreEmptyMethods: true
1665
-
1666
- Lint/UselessAccessModifier:
1667
- ContextCreatingMethods: []
1668
- MethodCreatingMethods: []
1669
-
1670
- Lint/Void:
1671
- CheckForMethodsWithNoSideEffects: false
1672
-
1673
- #################### Performance ###########################
1674
-
1675
- Performance/DoubleStartEndWith:
1676
- # Used to check for `starts_with?` and `ends_with?`.
1677
- # These methods are defined by `ActiveSupport`.
1678
- IncludeActiveSupportAliases: false
1679
-
1680
- Performance/RedundantMerge:
1681
- # Max number of key-value pairs to consider an offense
1682
- MaxKeyValuePairs: 2
1683
-
1684
- #################### Rails #################################
1685
-
1686
- Rails/ActionFilter:
1687
- EnforcedStyle: action
1688
- SupportedStyles:
1689
- - action
1690
- - filter
1691
- Include:
1692
- - app/controllers/**/*.rb
1693
-
1694
- Rails/AssertNot:
1695
- Include:
1696
- - '**/test/**/*'
1697
-
1698
- Rails/Blank:
1699
- # Convert usages of `nil? || empty?` to `blank?`
1700
- NilOrEmpty: true
1701
- # Convert usages of `!present?` to `blank?`
1702
- NotPresent: true
1703
- # Convert usages of `unless present?` to `if blank?`
1704
- UnlessPresent: true
1705
-
1706
- Rails/BulkChangeTable:
1707
- Database: null
1708
- SupportedDatabases:
1709
- - mysql
1710
- - postgresql
1711
- Include:
1712
- - db/migrate/*.rb
1713
-
1714
- Rails/CreateTableWithTimestamps:
1715
- Include:
1716
- - db/migrate/*.rb
1717
-
1718
- Rails/Date:
1719
- # The value `strict` disallows usage of `Date.today`, `Date.current`,
1720
- # `Date#to_time` etc.
1721
- # The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
1722
- # (but not `Date.today`) which are overridden by ActiveSupport to handle current
1723
- # time zone.
1724
- EnforcedStyle: flexible
1725
- SupportedStyles:
1726
- - strict
1727
- - flexible
1728
-
1729
- Rails/Delegate:
1730
- # When set to true, using the target object as a prefix of the
1731
- # method name without using the `delegate` method will be a
1732
- # violation. When set to false, this case is legal.
1733
- EnforceForPrefixed: true
1734
-
1735
- Rails/DynamicFindBy:
1736
- Whitelist:
1737
- - find_by_sql
1738
-
1739
- Rails/EnumUniqueness:
1740
- Include:
1741
- - app/models/**/*.rb
1742
-
1743
- Rails/Exit:
1744
- Include:
1745
- - app/**/*.rb
1746
- - config/**/*.rb
1747
- - lib/**/*.rb
1748
- Exclude:
1749
- - lib/**/*.rake
1750
-
1751
- Rails/FilePath:
1752
- EnforcedStyle: arguments
1753
- SupportedStyles:
1754
- - slashes
1755
- - arguments
1756
-
1757
- Rails/FindBy:
1758
- Include:
1759
- - app/models/**/*.rb
1760
-
1761
- Rails/FindEach:
1762
- Include:
1763
- - app/models/**/*.rb
1764
-
1765
- Rails/HasAndBelongsToMany:
1766
- Include:
1767
- - app/models/**/*.rb
1768
-
1769
- Rails/HasManyOrHasOneDependent:
1770
- Include:
1771
- - app/models/**/*.rb
1772
-
1773
- Rails/HttpStatus:
1774
- EnforcedStyle: symbolic
1775
- SupportedStyles:
1776
- - numeric
1777
- - symbolic
1778
-
1779
- Rails/InverseOf:
1780
- Include:
1781
- - app/models/**/*.rb
1782
-
1783
- Rails/LexicallyScopedActionFilter:
1784
- Include:
1785
- - app/controllers/**/*.rb
1786
-
1787
- Rails/NotNullColumn:
1788
- Include:
1789
- - db/migrate/*.rb
1790
-
1791
- Rails/Output:
1792
- Include:
1793
- - app/**/*.rb
1794
- - config/**/*.rb
1795
- - db/**/*.rb
1796
- - lib/**/*.rb
1797
-
1798
- Rails/Present:
1799
- # Convert usages of `!nil? && !empty?` to `present?`
1800
- NotNilAndNotEmpty: true
1801
- # Convert usages of `!blank?` to `present?`
1802
- NotBlank: true
1803
- # Convert usages of `unless blank?` to `if present?`
1804
- UnlessBlank: true
1805
-
1806
- Rails/ReadWriteAttribute:
1807
- Include:
1808
- - app/models/**/*.rb
1809
-
1810
- Rails/RefuteMethods:
1811
- Include:
1812
- - '**/test/**/*'
1813
-
1814
- Rails/RelativeDateConstant:
1815
- AutoCorrect: false
1816
-
1817
- Rails/RequestReferer:
1818
- EnforcedStyle: referer
1819
- SupportedStyles:
1820
- - referer
1821
- - referrer
1822
-
1823
- Rails/ReversibleMigration:
1824
- Include:
1825
- - db/migrate/*.rb
1826
-
1827
- Rails/SafeNavigation:
1828
- # This will convert usages of `try` to use safe navigation as well as `try!`.
1829
- # `try` and `try!` work slightly differently. `try!` and safe navigation will
1830
- # both raise a `NoMethodError` if the receiver of the method call does not
1831
- # implement the intended method. `try` will not raise an exception for this.
1832
- ConvertTry: false
1833
-
1834
- Rails/SaveBang:
1835
- AllowImplicitReturn: true
1836
- AllowedReceivers: []
1837
-
1838
- Rails/ScopeArgs:
1839
- Include:
1840
- - app/models/**/*.rb
1841
-
1842
- Rails/TimeZone:
1843
- # The value `strict` means that `Time` should be used with `zone`.
1844
- # The value `flexible` allows usage of `in_time_zone` instead of `zone`.
1845
- EnforcedStyle: flexible
1846
- SupportedStyles:
1847
- - strict
1848
- - flexible
1849
-
1850
- Rails/UniqBeforePluck:
1851
- EnforcedStyle: conservative
1852
- SupportedStyles:
1853
- - conservative
1854
- - aggressive
1855
- AutoCorrect: false
1856
-
1857
- Rails/UnknownEnv:
1858
- Environments:
1859
- - development
1860
- - test
1861
- - production
1862
-
1863
- Rails/SkipsModelValidations:
1864
- Blacklist:
1865
- - decrement!
1866
- - decrement_counter
1867
- - increment!
1868
- - increment_counter
1869
- - toggle!
1870
- - touch
1871
- - update_all
1872
- - update_attribute
1873
- - update_column
1874
- - update_columns
1875
- - update_counters
1876
-
1877
- Rails/Validation:
1878
- Include:
1879
- - app/models/**/*.rb
1880
-
1881
- Bundler/OrderedGems:
1882
- TreatCommentsAsGroupSeparators: true
1883
-
1884
- Gemspec/OrderedDependencies:
1885
- TreatCommentsAsGroupSeparators: true
4285
+ VersionAdded: 0.49
4286
+ VersionChanged: 0.50
4287
+
4288
+ Style/ZeroLengthPredicate:
4289
+ Description: 'Use #empty? when testing for objects of length 0.'
4290
+ Enabled: true
4291
+ Safe: false
4292
+ VersionAdded: 0.37
4293
+ VersionChanged: 0.39