rubocop 1.88.2 → 1.90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +139 -16
  3. data/exe/rubocop +1 -1
  4. data/lib/rubocop/cached_data.rb +7 -2
  5. data/lib/rubocop/cli/command/execute_runner.rb +31 -0
  6. data/lib/rubocop/cli.rb +2 -4
  7. data/lib/rubocop/comment_config/directive_range.rb +32 -0
  8. data/lib/rubocop/comment_config/disable_next.rb +97 -0
  9. data/lib/rubocop/comment_config.rb +81 -49
  10. data/lib/rubocop/config.rb +76 -5
  11. data/lib/rubocop/config_loader.rb +1 -2
  12. data/lib/rubocop/config_loader_resolver.rb +1 -2
  13. data/lib/rubocop/config_validator.rb +39 -3
  14. data/lib/rubocop/cop/autocorrect_logic.rb +8 -0
  15. data/lib/rubocop/cop/badge.rb +8 -0
  16. data/lib/rubocop/cop/base.rb +40 -6
  17. data/lib/rubocop/cop/bundler.rb +19 -0
  18. data/lib/rubocop/cop/corrector.rb +4 -4
  19. data/lib/rubocop/cop/correctors/alignment_corrector.rb +55 -5
  20. data/lib/rubocop/cop/gemspec.rb +22 -0
  21. data/lib/rubocop/cop/generator/registration_injector.rb +188 -0
  22. data/lib/rubocop/cop/generator.rb +4 -0
  23. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +1 -2
  24. data/lib/rubocop/cop/internal_affairs/node_pattern_groups/ast_walker.rb +1 -2
  25. data/lib/rubocop/cop/layout/block_alignment.rb +1 -2
  26. data/lib/rubocop/cop/layout/class_structure.rb +108 -26
  27. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1 -2
  28. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +63 -5
  29. data/lib/rubocop/cop/layout/end_alignment.rb +1 -2
  30. data/lib/rubocop/cop/layout/extra_spacing.rb +105 -3
  31. data/lib/rubocop/cop/layout/first_argument_indentation.rb +21 -1
  32. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +1 -1
  33. data/lib/rubocop/cop/layout/indentation_width.rb +3 -1
  34. data/lib/rubocop/cop/layout/leading_comment_space.rb +27 -0
  35. data/lib/rubocop/cop/layout/line_continuation_spacing.rb +1 -2
  36. data/lib/rubocop/cop/layout/line_length.rb +84 -12
  37. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +1 -2
  38. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +12 -2
  39. data/lib/rubocop/cop/layout/redundant_line_break.rb +77 -0
  40. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +1 -2
  41. data/lib/rubocop/cop/layout/space_around_operators.rb +7 -0
  42. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +31 -34
  43. data/lib/rubocop/cop/layout.rb +114 -0
  44. data/lib/rubocop/cop/lazy_loader.rb +41 -0
  45. data/lib/rubocop/cop/lint/ambiguous_assignment.rb +9 -7
  46. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +71 -0
  47. data/lib/rubocop/cop/lint/ambiguous_range.rb +1 -2
  48. data/lib/rubocop/cop/lint/argument_mismatch.rb +89 -0
  49. data/lib/rubocop/cop/lint/constant_reassignment.rb +18 -21
  50. data/lib/rubocop/cop/lint/constant_resolution.rb +25 -0
  51. data/lib/rubocop/cop/lint/cop_directive_syntax.rb +84 -8
  52. data/lib/rubocop/cop/lint/deprecated_reference.rb +194 -0
  53. data/lib/rubocop/cop/lint/duplicate_methods.rb +300 -22
  54. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -2
  55. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -2
  56. data/lib/rubocop/cop/lint/inherit_exception.rb +53 -7
  57. data/lib/rubocop/cop/lint/interpolation_check.rb +1 -2
  58. data/lib/rubocop/cop/lint/literal_as_condition.rb +8 -6
  59. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +4 -7
  60. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +25 -12
  61. data/lib/rubocop/cop/lint/missing_super.rb +31 -1
  62. data/lib/rubocop/cop/lint/name_typo.rb +270 -0
  63. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +15 -4
  64. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +98 -19
  65. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +47 -7
  66. data/lib/rubocop/cop/lint/redundant_require_statement.rb +1 -2
  67. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +1 -2
  68. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -2
  69. data/lib/rubocop/cop/lint/redundant_type_conversion.rb +1 -2
  70. data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -2
  71. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +8 -2
  72. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +2 -4
  73. data/lib/rubocop/cop/lint/super_argument_mismatch.rb +179 -0
  74. data/lib/rubocop/cop/lint/suppressed_exception_in_number_conversion.rb +1 -2
  75. data/lib/rubocop/cop/lint/to_enum_arguments.rb +38 -3
  76. data/lib/rubocop/cop/lint/unreachable_code.rb +1 -2
  77. data/lib/rubocop/cop/lint/unused_private_method.rb +234 -0
  78. data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -2
  79. data/lib/rubocop/cop/lint/useless_assignment.rb +1 -2
  80. data/lib/rubocop/cop/lint/useless_constant_scoping.rb +36 -0
  81. data/lib/rubocop/cop/lint/useless_method_definition.rb +1 -1
  82. data/lib/rubocop/cop/lint/useless_rescue.rb +1 -2
  83. data/lib/rubocop/cop/lint/useless_ruby2_keywords.rb +2 -0
  84. data/lib/rubocop/cop/lint/utils/nil_receiver_checker.rb +61 -7
  85. data/lib/rubocop/cop/lint/void.rb +18 -8
  86. data/lib/rubocop/cop/lint.rb +178 -0
  87. data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -2
  88. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -1
  89. data/lib/rubocop/cop/metrics.rb +31 -0
  90. data/lib/rubocop/cop/migration/department_name.rb +1 -6
  91. data/lib/rubocop/cop/migration.rb +13 -0
  92. data/lib/rubocop/cop/mixin/check_line_breakable.rb +23 -5
  93. data/lib/rubocop/cop/mixin/comments_help.rb +1 -2
  94. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -2
  95. data/lib/rubocop/cop/mixin/endless_method_rewriter.rb +13 -5
  96. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +23 -6
  97. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +1 -2
  98. data/lib/rubocop/cop/mixin/hash_subset.rb +1 -2
  99. data/lib/rubocop/cop/mixin/indexed_method_arity.rb +94 -0
  100. data/lib/rubocop/cop/mixin/line_length_help.rb +7 -1
  101. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +51 -6
  102. data/lib/rubocop/cop/mixin/project_index_help.rb +140 -0
  103. data/lib/rubocop/cop/mixin/range_help.rb +1 -2
  104. data/lib/rubocop/cop/mixin/reparsed_equivalence.rb +171 -0
  105. data/lib/rubocop/cop/mixin/statement_modifier.rb +46 -4
  106. data/lib/rubocop/cop/mixin/trailing_comma.rb +2 -4
  107. data/lib/rubocop/cop/mixin.rb +82 -77
  108. data/lib/rubocop/cop/naming/accessor_method_name.rb +24 -0
  109. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +16 -0
  110. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +2 -4
  111. data/lib/rubocop/cop/naming/method_name.rb +5 -2
  112. data/lib/rubocop/cop/naming/predicate_prefix.rb +33 -5
  113. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -2
  114. data/lib/rubocop/cop/naming/variable_number.rb +3 -1
  115. data/lib/rubocop/cop/naming.rb +31 -0
  116. data/lib/rubocop/cop/offense.rb +37 -10
  117. data/lib/rubocop/cop/registry.rb +180 -46
  118. data/lib/rubocop/cop/security.rb +19 -0
  119. data/lib/rubocop/cop/style/accessor_grouping.rb +1 -2
  120. data/lib/rubocop/cop/style/arguments_forwarding.rb +3 -6
  121. data/lib/rubocop/cop/style/array_first_last.rb +1 -2
  122. data/lib/rubocop/cop/style/array_intersect.rb +24 -5
  123. data/lib/rubocop/cop/style/bitwise_predicate.rb +1 -2
  124. data/lib/rubocop/cop/style/block_delimiters.rb +3 -6
  125. data/lib/rubocop/cop/style/case_like_if.rb +2 -4
  126. data/lib/rubocop/cop/style/class_and_module_children.rb +79 -20
  127. data/lib/rubocop/cop/style/combinable_loops.rb +1 -2
  128. data/lib/rubocop/cop/style/concat_array_literals.rb +1 -2
  129. data/lib/rubocop/cop/style/conditional_assignment.rb +23 -2
  130. data/lib/rubocop/cop/style/constant_visibility.rb +1 -2
  131. data/lib/rubocop/cop/style/copyright.rb +5 -1
  132. data/lib/rubocop/cop/style/directive_scope.rb +171 -0
  133. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +76 -12
  134. data/lib/rubocop/cop/style/documentation.rb +47 -0
  135. data/lib/rubocop/cop/style/empty_case_condition.rb +1 -2
  136. data/lib/rubocop/cop/style/endless_method.rb +0 -10
  137. data/lib/rubocop/cop/style/format_string_token.rb +1 -2
  138. data/lib/rubocop/cop/style/guard_clause.rb +1 -2
  139. data/lib/rubocop/cop/style/hash_each_methods.rb +1 -2
  140. data/lib/rubocop/cop/style/hash_syntax.rb +1 -2
  141. data/lib/rubocop/cop/style/identical_conditional_branches.rb +2 -4
  142. data/lib/rubocop/cop/style/if_inside_else.rb +1 -2
  143. data/lib/rubocop/cop/style/if_unless_modifier.rb +8 -50
  144. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +1 -2
  145. data/lib/rubocop/cop/style/lambda.rb +4 -0
  146. data/lib/rubocop/cop/style/map_to_hash.rb +1 -2
  147. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +22 -7
  148. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +1 -2
  149. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +30 -0
  150. data/lib/rubocop/cop/style/multiline_if_then.rb +7 -1
  151. data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -2
  152. data/lib/rubocop/cop/style/multiple_comparison.rb +33 -22
  153. data/lib/rubocop/cop/style/mutable_constant.rb +5 -0
  154. data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -2
  155. data/lib/rubocop/cop/style/negative_array_index.rb +3 -3
  156. data/lib/rubocop/cop/style/nil_comparison.rb +1 -2
  157. data/lib/rubocop/cop/style/operator_method_call.rb +1 -2
  158. data/lib/rubocop/cop/style/parallel_assignment.rb +1 -2
  159. data/lib/rubocop/cop/style/redundant_assignment.rb +12 -2
  160. data/lib/rubocop/cop/style/redundant_condition.rb +2 -4
  161. data/lib/rubocop/cop/style/redundant_constant_base.rb +37 -1
  162. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +1 -2
  163. data/lib/rubocop/cop/style/redundant_each.rb +1 -2
  164. data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +9 -0
  165. data/lib/rubocop/cop/style/redundant_format.rb +14 -7
  166. data/lib/rubocop/cop/style/redundant_line_continuation.rb +78 -135
  167. data/lib/rubocop/cop/style/redundant_parentheses.rb +65 -67
  168. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +1 -2
  169. data/lib/rubocop/cop/style/redundant_return.rb +1 -2
  170. data/lib/rubocop/cop/style/redundant_self_assignment.rb +1 -2
  171. data/lib/rubocop/cop/style/redundant_string_escape.rb +1 -2
  172. data/lib/rubocop/cop/style/rescue_modifier.rb +1 -2
  173. data/lib/rubocop/cop/style/safe_navigation.rb +11 -2
  174. data/lib/rubocop/cop/style/sample.rb +11 -6
  175. data/lib/rubocop/cop/style/select_by_regexp.rb +1 -2
  176. data/lib/rubocop/cop/style/semicolon.rb +2 -4
  177. data/lib/rubocop/cop/style/single_line_do_end_block.rb +1 -2
  178. data/lib/rubocop/cop/style/sole_nested_conditional.rb +21 -5
  179. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +2 -0
  180. data/lib/rubocop/cop/style/static_class.rb +21 -0
  181. data/lib/rubocop/cop/style/string_concatenation.rb +18 -5
  182. data/lib/rubocop/cop/style/super_arguments.rb +1 -2
  183. data/lib/rubocop/cop/style/symbol_proc.rb +1 -2
  184. data/lib/rubocop/cop/style/time_now.rb +41 -0
  185. data/lib/rubocop/cop/style/yoda_condition.rb +1 -2
  186. data/lib/rubocop/cop/style.rb +312 -0
  187. data/lib/rubocop/cop/team.rb +59 -6
  188. data/lib/rubocop/cop/util.rb +2 -4
  189. data/lib/rubocop/cop/variable_force/variable.rb +19 -8
  190. data/lib/rubocop/cops_documentation_generator.rb +4 -7
  191. data/lib/rubocop/directive_comment.rb +39 -3
  192. data/lib/rubocop/feature_loader.rb +0 -6
  193. data/lib/rubocop/formatter/emacs_style_formatter.rb +3 -1
  194. data/lib/rubocop/formatter/html_formatter.rb +2 -4
  195. data/lib/rubocop/formatter/json_formatter.rb +11 -6
  196. data/lib/rubocop/formatter/junit_formatter.rb +26 -9
  197. data/lib/rubocop/formatter/offense_count_formatter.rb +1 -2
  198. data/lib/rubocop/formatter/simple_text_formatter.rb +4 -3
  199. data/lib/rubocop/formatter/tap_formatter.rb +3 -1
  200. data/lib/rubocop/formatter/worst_offenders_formatter.rb +1 -2
  201. data/lib/rubocop/lockfile.rb +18 -0
  202. data/lib/rubocop/lsp/diagnostic.rb +4 -8
  203. data/lib/rubocop/lsp/routes.rb +89 -22
  204. data/lib/rubocop/lsp/runtime.rb +4 -0
  205. data/lib/rubocop/lsp/server.rb +4 -0
  206. data/lib/rubocop/lsp/stdin_runner.rb +20 -0
  207. data/lib/rubocop/mcp/server.rb +1 -2
  208. data/lib/rubocop/options.rb +10 -6
  209. data/lib/rubocop/path_util.rb +1 -2
  210. data/lib/rubocop/pending_cops_reporter.rb +1 -6
  211. data/lib/rubocop/plugin/configuration_integrator.rb +6 -3
  212. data/lib/rubocop/project_index_loader.rb +16 -0
  213. data/lib/rubocop/rake_task.rb +1 -2
  214. data/lib/rubocop/result_cache.rb +6 -4
  215. data/lib/rubocop/rspec/expect_offense.rb +2 -4
  216. data/lib/rubocop/rspec/shared_contexts.rb +16 -2
  217. data/lib/rubocop/runner.rb +71 -43
  218. data/lib/rubocop/server/cache.rb +11 -7
  219. data/lib/rubocop/server/cli.rb +2 -4
  220. data/lib/rubocop/server.rb +14 -0
  221. data/lib/rubocop/target_finder.rb +4 -1
  222. data/lib/rubocop/target_ruby.rb +1 -1
  223. data/lib/rubocop/todo_audit.rb +111 -0
  224. data/lib/rubocop/version.rb +3 -5
  225. data/lib/rubocop.rb +20 -626
  226. data/lib/ruby_lsp/rubocop/addon.rb +1 -2
  227. metadata +28 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8642dc64b958118e0563ed93c4837ac13aca29cb8f8a6267155ef450380ea1b3
4
- data.tar.gz: 569ff18924510b28b60ff03563053d0c53983829d7f4755c0ad39cc213b41f64
3
+ metadata.gz: 382da6a2b30d9de3a34dfad6d8a2aba1f4c314881d4a7a419d698b58faf07cd4
4
+ data.tar.gz: 3807b557f0eedb44f81b1a20880649e15b8c76ed31a916756d626a13b391d556
5
5
  SHA512:
6
- metadata.gz: 1cc966f73a8b890c335fedbc55fa0ec0f8a73099703cf46111e8619933f2d4b9436cf1c7d597f7fef0282e1e1e2f6b6adc4b4e38c7195eabb600fe97d9931526
7
- data.tar.gz: 94cc97c23eeaaff0ec7ab9046a2275547fe2363449d0582733e30be26868e098d12c609703fdc2318b1e4d96b8205abf6fe537d655950cf558debfcb6224366c
6
+ metadata.gz: 7654d620f9e6504e76855f15335df419416a8353da06cb55c0a15b1fa123b2cabc170792846e8ee5ab1b122003d14038809f524fdf7a07773d51a69b1faca234
7
+ data.tar.gz: 296dc584530a8191088320cfcfe2fdd38339da0888aac861b510ba219b50a601bd4bd060b831f9733f12553031c20abd91fdcc7ece654d0e716857ef7eb8cee8
data/config/default.yml CHANGED
@@ -110,6 +110,12 @@ AllCops:
110
110
  # a warning is shown and the flag has no effect.
111
111
  # The default `false` preserves RuboCop's traditional file-local analysis.
112
112
  UseProjectIndex: false
113
+ # When the project index is enabled, also index the sources of the gems in
114
+ # the project's bundle. This lets index-aware cops resolve ancestry chains
115
+ # and members that live in gems (e.g. framework base classes), at the cost
116
+ # of extra memory proportional to the bundle's size. Has no effect when
117
+ # `UseProjectIndex` is `false` or when RuboCop does not run inside Bundler.
118
+ ProjectIndexIncludesGems: false
113
119
  # Enables the result cache if `true`. Can be overridden by the `--cache` command
114
120
  # line option.
115
121
  UseCache: true
@@ -165,6 +171,7 @@ AllCops:
165
171
  rubocop-capybara: [capybara]
166
172
  rubocop-factory_bot: [factory_bot, factory_bot_rails]
167
173
  rubocop-rspec_rails: [rspec-rails]
174
+ rubocop-i18n: [i18n, gettext]
168
175
  # Enable/Disable checking the methods extended by Active Support.
169
176
  ActiveSupportExtensionsEnabled: false
170
177
  # Future version of Ruby will freeze string literals by default.
@@ -420,7 +427,7 @@ Layout/ArrayAlignment:
420
427
  Description: >-
421
428
  Align the elements of an array literal if they span more than
422
429
  one line.
423
- StyleGuide: '#no-double-indent'
430
+ StyleGuide: '#align-multiline-arrays'
424
431
  Enabled: true
425
432
  VersionAdded: '0.49'
426
433
  VersionChanged: '0.77'
@@ -511,7 +518,7 @@ Layout/ClassStructure:
511
518
  Enabled: false
512
519
  SafeAutoCorrect: false
513
520
  VersionAdded: '0.52'
514
- VersionChanged: '1.53'
521
+ VersionChanged: '1.89'
515
522
  Categories:
516
523
  module_inclusion:
517
524
  - include
@@ -524,6 +531,7 @@ Layout/ClassStructure:
524
531
  - initializer
525
532
  - public_methods
526
533
  - protected_methods
534
+ - private_class_methods
527
535
  - private_methods
528
536
 
529
537
  Layout/ClosingHeredocIndentation:
@@ -610,6 +618,12 @@ Layout/EmptyLineAfterMagicComment:
610
618
  StyleGuide: '#separate-magic-comments-from-code'
611
619
  Enabled: true
612
620
  VersionAdded: '0.49'
621
+ VersionChanged: '1.90'
622
+ # The minimum number of empty lines required after the last magic comment. Set this
623
+ # to `2` when using YARD, which otherwise treats the magic comments as documentation
624
+ # for the first module or class in the file. `Layout/EmptyLines` has to be disabled
625
+ # for values greater than `1`.
626
+ NumberOfEmptyLines: 1
613
627
 
614
628
  Layout/EmptyLineAfterMultilineCondition:
615
629
  Description: 'Enforces empty line after multiline condition.'
@@ -1069,6 +1083,7 @@ Layout/LeadingCommentSpace:
1069
1083
  AllowGemfileRubyComment: false
1070
1084
  AllowRBSInlineAnnotation: false
1071
1085
  AllowSteepAnnotation: false
1086
+ AllowYARDCommentBlockSeparator: false
1072
1087
 
1073
1088
  Layout/LeadingEmptyLines:
1074
1089
  Description: Checks for unnecessary blank lines at the beginning of a file.
@@ -1407,6 +1422,7 @@ Layout/SpaceAroundOperators:
1407
1422
  StyleGuide: '#spaces-operators'
1408
1423
  Enabled: true
1409
1424
  VersionAdded: '0.49'
1425
+ VersionChanged: '1.90'
1410
1426
  # When `true`, allows most uses of extra spacing if the intent is to align
1411
1427
  # with an operator on the previous or next line, not counting empty lines
1412
1428
  # or comment lines.
@@ -1615,7 +1631,7 @@ Lint/AmbiguousBlockAssociation:
1615
1631
  parentheses.
1616
1632
  Enabled: true
1617
1633
  VersionAdded: '0.48'
1618
- VersionChanged: '1.13'
1634
+ VersionChanged: '1.89'
1619
1635
  AllowedMethods: []
1620
1636
  AllowedPatterns: []
1621
1637
 
@@ -1650,6 +1666,13 @@ Lint/AmbiguousRegexpLiteral:
1650
1666
  VersionAdded: '0.17'
1651
1667
  VersionChanged: '0.83'
1652
1668
 
1669
+ Lint/ArgumentMismatch:
1670
+ Description: >-
1671
+ Checks for calls that pass the wrong number of positional arguments
1672
+ to a method, using the project index.
1673
+ Enabled: pending
1674
+ VersionAdded: '1.90'
1675
+
1653
1676
  Lint/ArrayLiteralInRegexp:
1654
1677
  Description: 'Checks for an array literal interpolated inside a regexp.'
1655
1678
  Enabled: pending
@@ -1713,6 +1736,7 @@ Lint/ConstantReassignment:
1713
1736
 
1714
1737
  Lint/ConstantResolution:
1715
1738
  Description: 'Checks that constants are fully qualified with `::`.'
1739
+ VersionChanged: '1.89'
1716
1740
  Enabled: false
1717
1741
  VersionAdded: '0.86'
1718
1742
  # Restrict this cop to only looking at certain names
@@ -1724,6 +1748,7 @@ Lint/CopDirectiveSyntax:
1724
1748
  Description: 'Checks that `# rubocop:` directives are strictly formatted.'
1725
1749
  Enabled: pending
1726
1750
  VersionAdded: '1.72'
1751
+ VersionChanged: '1.90'
1727
1752
 
1728
1753
  Lint/DataDefineOverride:
1729
1754
  Description: 'Disallow overriding the `Data` built-in methods via `Data.define`.'
@@ -1829,8 +1854,17 @@ Lint/DeprecatedOpenSSLConstant:
1829
1854
  Enabled: true
1830
1855
  VersionAdded: '0.84'
1831
1856
 
1857
+ Lint/DeprecatedReference:
1858
+ Description: >-
1859
+ Checks for references to methods and constants documented
1860
+ as deprecated with a YARD `@deprecated` tag.
1861
+ Requires `AllCops/UseProjectIndex` to be enabled.
1862
+ Enabled: pending
1863
+ VersionAdded: '1.89'
1864
+
1832
1865
  Lint/DisjunctiveAssignmentInConstructor:
1833
1866
  Description: 'In constructor, plain assignment is preferred over disjunctive.'
1867
+ StyleGuide: '#disjunctive-assignment-in-constructor'
1834
1868
  Enabled: true
1835
1869
  Safe: false
1836
1870
  VersionAdded: '0.62'
@@ -1875,6 +1909,22 @@ Lint/DuplicateMethods:
1875
1909
  Description: 'Checks for duplicate method definitions.'
1876
1910
  Enabled: true
1877
1911
  VersionAdded: '0.29'
1912
+ VersionChanged: '1.90'
1913
+ # Methods that define instance methods by delegation, in the style of
1914
+ # Active Support's `delegate` (`delegate :foo, :bar, to: :target`). Register
1915
+ # a project's own `delegate`-shaped macros here so the cop recognizes the
1916
+ # methods they define. Only takes effect when `AllCops/ActiveSupportExtensionsEnabled`
1917
+ # is `true`.
1918
+ DelegatingMethods:
1919
+ - delegate
1920
+ # Cross-file duplicates (detected with `AllCops/UseProjectIndex`) whose other
1921
+ # definition lives in a file matching one of these patterns are not reported.
1922
+ # Useful for files that redefine application methods but are never loaded
1923
+ # together with them, such as standalone scripts. Patterns follow the same
1924
+ # glob (or regexp) semantics as `Exclude` and are matched against the other
1925
+ # file's path relative to the directory of the config file; absolute patterns
1926
+ # are matched against the absolute path.
1927
+ AllowedCrossFilePaths: []
1878
1928
 
1879
1929
  Lint/DuplicateRegexpCharacterClassElement:
1880
1930
  Description: 'Checks for duplicate elements in Regexp character classes.'
@@ -2057,7 +2107,7 @@ Lint/InheritException:
2057
2107
  Enabled: true
2058
2108
  SafeAutoCorrect: false
2059
2109
  VersionAdded: '0.41'
2060
- VersionChanged: '1.26'
2110
+ VersionChanged: '1.89'
2061
2111
  # The default base class in favour of `Exception`.
2062
2112
  EnforcedStyle: standard_error
2063
2113
  SupportedStyles:
@@ -2114,7 +2164,7 @@ Lint/MissingCopEnableDirective:
2114
2164
  Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
2115
2165
  Enabled: true
2116
2166
  VersionAdded: '0.52'
2117
- VersionChanged: '1.88'
2167
+ VersionChanged: '1.90'
2118
2168
  # Maximum number of consecutive lines the cop can be disabled for.
2119
2169
  # 0 allows only single-line disables
2120
2170
  # 1 would mean the maximum allowed is the following:
@@ -2130,7 +2180,7 @@ Lint/MissingSuper:
2130
2180
  without calls to `super`.
2131
2181
  Enabled: true
2132
2182
  VersionAdded: '0.89'
2133
- VersionChanged: '1.4'
2183
+ VersionChanged: '1.89'
2134
2184
  AllowedParentClasses: []
2135
2185
 
2136
2186
  Lint/MixedCaseRange:
@@ -2141,6 +2191,7 @@ Lint/MixedCaseRange:
2141
2191
 
2142
2192
  Lint/MixedRegexpCaptureTypes:
2143
2193
  Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
2194
+ StyleGuide: '#do-not-mix-named-and-numbered-captures'
2144
2195
  Enabled: true
2145
2196
  VersionAdded: '0.85'
2146
2197
 
@@ -2150,6 +2201,16 @@ Lint/MultipleComparison:
2150
2201
  VersionAdded: '0.47'
2151
2202
  VersionChanged: '1.1'
2152
2203
 
2204
+ Lint/NameTypo:
2205
+ Description: >-
2206
+ Checks for probable typos in constant and method names,
2207
+ using the project index.
2208
+ Enabled: pending
2209
+ CheckConstants: true
2210
+ CheckMethods: true
2211
+ AllowedNames: []
2212
+ VersionAdded: '1.89'
2213
+
2153
2214
  Lint/NestedMethodDefinition:
2154
2215
  Description: 'Do not use nested method definitions.'
2155
2216
  StyleGuide: '#no-nested-methods'
@@ -2287,6 +2348,7 @@ Lint/RedundantCopEnableDirective:
2287
2348
  Description: Checks for rubocop:enable comments that can be removed.
2288
2349
  Enabled: true
2289
2350
  VersionAdded: '0.76'
2351
+ VersionChanged: '1.90'
2290
2352
 
2291
2353
  Lint/RedundantDirGlobSort:
2292
2354
  Description: 'Checks for redundant `sort` method to `Dir.glob` and `Dir[]`.'
@@ -2409,8 +2471,9 @@ Lint/ReturnInVoidContext:
2409
2471
  Lint/SafeNavigationChain:
2410
2472
  Description: 'Do not chain ordinary method call after safe navigation operator.'
2411
2473
  Enabled: true
2474
+ SafeAutoCorrect: false
2412
2475
  VersionAdded: '0.47'
2413
- VersionChanged: '0.77'
2476
+ VersionChanged: '1.89'
2414
2477
  AllowedMethods:
2415
2478
  - present?
2416
2479
  - blank?
@@ -2468,6 +2531,7 @@ Lint/ShadowedException:
2468
2531
  Description: >-
2469
2532
  Avoid rescuing a higher level exception
2470
2533
  before a lower level exception.
2534
+ StyleGuide: '#exception-ordering'
2471
2535
  Enabled: true
2472
2536
  VersionAdded: '0.41'
2473
2537
 
@@ -2490,6 +2554,13 @@ Lint/StructNewOverride:
2490
2554
  Enabled: true
2491
2555
  VersionAdded: '0.81'
2492
2556
 
2557
+ Lint/SuperArgumentMismatch:
2558
+ Description: >-
2559
+ Checks for `super` calls that pass the wrong number of positional
2560
+ arguments to the overridden implementation, using the project index.
2561
+ Enabled: pending
2562
+ VersionAdded: '1.90'
2563
+
2493
2564
  Lint/SuppressedException:
2494
2565
  Description: "Don't suppress exceptions."
2495
2566
  StyleGuide: '#dont-hide-exceptions'
@@ -2580,6 +2651,7 @@ Lint/UnexpectedBlockArity:
2580
2651
 
2581
2652
  Lint/UnifiedInteger:
2582
2653
  Description: 'Use Integer instead of Fixnum or Bignum.'
2654
+ StyleGuide: '#integer-type-checking'
2583
2655
  Enabled: true
2584
2656
  VersionAdded: '0.43'
2585
2657
 
@@ -2632,6 +2704,21 @@ Lint/UnusedMethodArgument:
2632
2704
  NotImplementedExceptions:
2633
2705
  - NotImplementedError
2634
2706
 
2707
+ Lint/UnusedPrivateMethod:
2708
+ Description: >-
2709
+ Checks for private instance methods that are not referenced
2710
+ anywhere in the project. Requires `AllCops/UseProjectIndex`
2711
+ to be enabled.
2712
+ # This cop is disabled by default because symbol-based references from other
2713
+ # files (e.g. Rails callbacks declared in a concern) cannot be detected and
2714
+ # would be reported as false positives. It is intended for occasional
2715
+ # dead-code sweeps rather than permanent enforcement.
2716
+ Enabled: false
2717
+ AllowedNames: []
2718
+ AllowedPatterns: []
2719
+ VersionAdded: '1.89'
2720
+ VersionChanged: '1.90'
2721
+
2635
2722
  Lint/UriEscapeUnescape:
2636
2723
  Description: >-
2637
2724
  `URI.escape` method is obsolete and should not be used. Instead, use
@@ -2669,6 +2756,7 @@ Lint/UselessConstantScoping:
2669
2756
  Description: 'Checks for useless constant scoping.'
2670
2757
  Enabled: pending
2671
2758
  VersionAdded: '1.72'
2759
+ VersionChanged: '1.90'
2672
2760
 
2673
2761
  Lint/UselessDefaultValueArgument:
2674
2762
  Description: 'Checks for usage of `fetch` or `Array.new` with default value argument and block.'
@@ -2863,6 +2951,7 @@ Migration/DepartmentName:
2863
2951
  Naming/AccessorMethodName:
2864
2952
  Description: Checks the naming of accessor methods for get_/set_.
2865
2953
  StyleGuide: '#accessor_mutator_method_names'
2954
+ VersionChanged: '1.89'
2866
2955
  Enabled: true
2867
2956
  VersionAdded: '0.50'
2868
2957
 
@@ -3139,7 +3228,7 @@ Naming/PredicatePrefix:
3139
3228
  StyleGuide: '#bool-methods-qmark'
3140
3229
  Enabled: true
3141
3230
  VersionAdded: '0.50'
3142
- VersionChanged: '1.75'
3231
+ VersionChanged: '1.89'
3143
3232
  # Predicate name prefixes.
3144
3233
  NamePrefix:
3145
3234
  - is_
@@ -3365,6 +3454,7 @@ Style/ArrayCoercion:
3365
3454
 
3366
3455
  Style/ArrayFirstLast:
3367
3456
  Description: 'Use `arr.first` and `arr.last` instead of `arr[0]` and `arr[-1]`.'
3457
+ StyleGuide: '#first-and-last'
3368
3458
  References:
3369
3459
  - '#first-and-last'
3370
3460
  Enabled: false
@@ -3607,13 +3697,14 @@ Style/ClassAndModuleChildren:
3607
3697
  StyleGuide: '#namespace-definition'
3608
3698
  # Moving from compact to nested children requires knowledge of whether the
3609
3699
  # outer parent is a module or a class. Moving from nested to compact requires
3610
- # verification that the outer parent is defined elsewhere. RuboCop does not
3611
- # have the knowledge to perform either operation safely and thus requires
3612
- # manual oversight.
3700
+ # verification that the outer parent is defined elsewhere. By default RuboCop
3701
+ # does not have the knowledge to perform either operation safely and thus
3702
+ # requires manual oversight. When `AllCops/UseProjectIndex` is enabled, the
3703
+ # project-wide index is consulted for both operations.
3613
3704
  SafeAutoCorrect: false
3614
3705
  Enabled: true
3615
3706
  VersionAdded: '0.19'
3616
- VersionChanged: '1.74'
3707
+ VersionChanged: '1.89'
3617
3708
  #
3618
3709
  # Basically there are two different styles:
3619
3710
  #
@@ -3827,6 +3918,7 @@ Style/ConditionalAssignment:
3827
3918
  Use the return value of `if` and `case` statements for
3828
3919
  assignment to a variable and variable comparison instead
3829
3920
  of assigning that variable inside of each branch.
3921
+ StyleGuide: '#use-if-case-returns'
3830
3922
  Enabled: true
3831
3923
  VersionAdded: '0.36'
3832
3924
  VersionChanged: '0.47'
@@ -3887,7 +3979,7 @@ Style/DataInheritance:
3887
3979
 
3888
3980
  Style/DateTime:
3889
3981
  Description: 'Use Time over DateTime.'
3890
- StyleGuide: '#date-time'
3982
+ StyleGuide: '#no-datetime'
3891
3983
  Enabled: false
3892
3984
  VersionAdded: '0.51'
3893
3985
  VersionChanged: '0.92'
@@ -3920,13 +4012,23 @@ Style/DirEmpty:
3920
4012
  Enabled: pending
3921
4013
  VersionAdded: '1.48'
3922
4014
 
4015
+ Style/DirectiveScope:
4016
+ Description: >-
4017
+ Checks for directive scopes that can be expressed with the
4018
+ tighter `disable-next` form.
4019
+ Enabled: pending
4020
+ SafeAutoCorrect: false
4021
+ VersionAdded: '1.90'
4022
+
3923
4023
  Style/DisableCopsWithinSourceCodeDirective:
3924
4024
  Description: >-
3925
4025
  Forbids disabling/enabling cops within source code.
3926
4026
  Enabled: false
3927
4027
  VersionAdded: '0.82'
3928
- VersionChanged: '1.9'
4028
+ VersionChanged: '1.90'
3929
4029
  AllowedCops: []
4030
+ DisallowedCops: []
4031
+ AllowTrailingComment: false
3930
4032
 
3931
4033
  Style/DocumentDynamicEvalDefinition:
3932
4034
  Description: >-
@@ -3941,6 +4043,7 @@ Style/Documentation:
3941
4043
  Description: 'Document classes and non-namespace modules.'
3942
4044
  Enabled: true
3943
4045
  VersionAdded: '0.9'
4046
+ VersionChanged: '1.89'
3944
4047
  AllowedConstants: []
3945
4048
  Exclude:
3946
4049
  - 'spec/**/*'
@@ -3998,6 +4101,7 @@ Style/EmptyCaseCondition:
3998
4101
 
3999
4102
  Style/EmptyClassDefinition:
4000
4103
  Description: 'Enforces consistent style for empty class definitions.'
4104
+ StyleGuide: '#single-line-classes'
4001
4105
  Enabled: pending
4002
4106
  VersionAdded: '1.84'
4003
4107
  VersionChanged: '1.86'
@@ -4163,12 +4267,14 @@ Style/FileEmpty:
4163
4267
 
4164
4268
  Style/FileNull:
4165
4269
  Description: 'Use `File::NULL` instead of hardcoding "dev/null".'
4270
+ StyleGuide: '#null-devices'
4166
4271
  Enabled: pending
4167
4272
  SafeAutoCorrect: false
4168
4273
  VersionAdded: '1.69'
4169
4274
 
4170
4275
  Style/FileOpen:
4171
4276
  Description: 'Checks for `File.open` without a block, which can leak file descriptors.'
4277
+ StyleGuide: '#auto-release-resources'
4172
4278
  Enabled: pending
4173
4279
  Safe: false
4174
4280
  VersionAdded: '1.85'
@@ -4233,6 +4339,7 @@ Style/FormatString:
4233
4339
 
4234
4340
  Style/FormatStringToken:
4235
4341
  Description: 'Use a consistent style for format string tokens.'
4342
+ StyleGuide: '#named-format-tokens'
4236
4343
  Enabled: true
4237
4344
  VersionAdded: '0.49'
4238
4345
  VersionChanged: '1.74'
@@ -4422,6 +4529,7 @@ Style/HashSyntax:
4422
4529
 
4423
4530
  Style/HashTransformKeys:
4424
4531
  Description: 'Prefer `transform_keys` over `each_with_object`, `map`, or `to_h`.'
4532
+ StyleGuide: '#hash-transform-methods'
4425
4533
  Enabled: true
4426
4534
  VersionAdded: '0.80'
4427
4535
  VersionChanged: '0.90'
@@ -4429,6 +4537,7 @@ Style/HashTransformKeys:
4429
4537
 
4430
4538
  Style/HashTransformValues:
4431
4539
  Description: 'Prefer `transform_values` over `each_with_object`, `map`, or `to_h`.'
4540
+ StyleGuide: '#hash-transform-methods'
4432
4541
  Enabled: true
4433
4542
  VersionAdded: '0.80'
4434
4543
  VersionChanged: '0.90'
@@ -4599,7 +4708,7 @@ Style/KeywordArgumentsMerging:
4599
4708
 
4600
4709
  Style/KeywordParametersOrder:
4601
4710
  Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
4602
- StyleGuide: '#keyword-parameters-order'
4711
+ StyleGuide: '#keyword-arguments-order'
4603
4712
  Enabled: true
4604
4713
  VersionAdded: '0.90'
4605
4714
  VersionChanged: '1.7'
@@ -4632,6 +4741,7 @@ Style/LineEndConcatenation:
4632
4741
  Description: >-
4633
4742
  Use \ instead of + or << to concatenate two string literals at
4634
4743
  line end.
4744
+ StyleGuide: '#heredoc-long-strings'
4635
4745
  Enabled: true
4636
4746
  SafeAutoCorrect: false
4637
4747
  VersionAdded: '0.18'
@@ -4778,6 +4888,7 @@ Style/MissingRespondToMissing:
4778
4888
  StyleGuide: '#no-method-missing'
4779
4889
  Enabled: true
4780
4890
  VersionAdded: '0.56'
4891
+ VersionChanged: '1.89'
4781
4892
 
4782
4893
  Style/MixinGrouping:
4783
4894
  Description: 'Checks for grouping of mixins in `class` and `module` bodies.'
@@ -4928,7 +5039,7 @@ Style/NegatedIfElseCondition:
4928
5039
 
4929
5040
  Style/NegatedUnless:
4930
5041
  Description: 'Favor if over unless for negative conditions.'
4931
- StyleGuide: '#if-for-negatives'
5042
+ StyleGuide: '#unless-for-negatives'
4932
5043
  Enabled: true
4933
5044
  VersionAdded: '0.69'
4934
5045
  EnforcedStyle: both
@@ -5131,6 +5242,7 @@ Style/ObjectThen:
5131
5242
 
5132
5243
  Style/OneClassPerFile:
5133
5244
  Description: 'Checks that each source file defines at most one top-level class or module.'
5245
+ StyleGuide: '#one-class-per-file'
5134
5246
  Enabled: pending
5135
5247
  VersionAdded: '1.85'
5136
5248
  VersionChanged: '1.86'
@@ -5397,6 +5509,7 @@ Style/RedundantConditional:
5397
5509
 
5398
5510
  Style/RedundantConstantBase:
5399
5511
  Description: Avoid redundant `::` prefix on constant.
5512
+ VersionChanged: '1.89'
5400
5513
  Enabled: pending
5401
5514
  VersionAdded: '1.40'
5402
5515
 
@@ -5495,6 +5608,7 @@ Style/RedundantInterpolationUnfreeze:
5495
5608
 
5496
5609
  Style/RedundantLineContinuation:
5497
5610
  Description: 'Checks for redundant line continuation.'
5611
+ StyleGuide: '#no-trailing-backslash'
5498
5612
  Enabled: pending
5499
5613
  VersionAdded: '1.49'
5500
5614
 
@@ -5531,6 +5645,7 @@ Style/RedundantRegexpConstructor:
5531
5645
 
5532
5646
  Style/RedundantRegexpEscape:
5533
5647
  Description: 'Checks for redundant escapes in Regexps.'
5648
+ StyleGuide: '#limit-escapes'
5534
5649
  Enabled: true
5535
5650
  VersionAdded: '0.85'
5536
5651
 
@@ -5830,6 +5945,7 @@ Style/StabbyLambdaParentheses:
5830
5945
  Style/StaticClass:
5831
5946
  Description: 'Prefer modules to classes with only class methods.'
5832
5947
  StyleGuide: '#modules-vs-classes'
5948
+ VersionChanged: '1.89'
5833
5949
  Enabled: false
5834
5950
  Safe: false
5835
5951
  VersionAdded: '1.3'
@@ -5983,6 +6099,12 @@ Style/TernaryParentheses:
5983
6099
  - require_parentheses_when_complex
5984
6100
  AllowSafeAssignment: true
5985
6101
 
6102
+ Style/TimeNow:
6103
+ Description: 'Prefer `Time.now` over `Time.new` when retrieving the current system time.'
6104
+ StyleGuide: '#time-now'
6105
+ Enabled: pending
6106
+ VersionAdded: '1.90'
6107
+
5986
6108
  Style/TopLevelMethodDefinition:
5987
6109
  Description: 'Looks for top-level method definitions.'
5988
6110
  StyleGuide: '#top-level-methods'
@@ -6073,6 +6195,7 @@ Style/TrailingUnderscoreVariable:
6073
6195
  Description: >-
6074
6196
  Checks for the usage of unneeded trailing underscores at the
6075
6197
  end of parallel variable assignment.
6198
+ StyleGuide: '#trailing-underscore-variables'
6076
6199
  Enabled: true
6077
6200
  VersionAdded: '0.31'
6078
6201
  VersionChanged: '0.35'
data/exe/rubocop CHANGED
@@ -8,7 +8,7 @@ server_cli = RuboCop::Server::CLI.new
8
8
  exit_status = server_cli.run
9
9
  exit exit_status if server_cli.exit?
10
10
 
11
- if RuboCop::Server.running?
11
+ if RuboCop::Server.forward_to_server?
12
12
  exit_status = RuboCop::Server::ClientCommand::Exec.new.run
13
13
  else
14
14
  require 'rubocop'
@@ -22,7 +22,7 @@ module RuboCop
22
22
 
23
23
  def serialize_offense(offense)
24
24
  status = :uncorrected if %i[corrected corrected_with_todo].include?(offense.status)
25
- {
25
+ hash = {
26
26
  # Calling #to_s here ensures that the serialization works when using
27
27
  # other json serializers such as Oj. Some of these gems do not call
28
28
  # #to_s implicitly.
@@ -35,6 +35,10 @@ module RuboCop
35
35
  cop_name: offense.cop_name,
36
36
  status: status || offense.status
37
37
  }
38
+ # Only offenses suppressed by a directive can carry one, so keep the key out of the
39
+ # common case rather than writing a null for every cached offense.
40
+ hash[:justification] = offense.justification if offense.justification
41
+ hash
38
42
  end
39
43
 
40
44
  def message(offense)
@@ -47,7 +51,8 @@ module RuboCop
47
51
  def deserialize_offenses(offenses)
48
52
  offenses.map! do |o|
49
53
  location = location_from_source_buffer(o)
50
- Cop::Offense.new(o['severity'], location, o['message'], o['cop_name'], o['status'].to_sym)
54
+ Cop::Offense.new(o['severity'], location, o['message'], o['cop_name'], o['status'].to_sym,
55
+ justification: o['justification'])
51
56
  end
52
57
  end
53
58
 
@@ -30,6 +30,10 @@ module RuboCop
30
30
 
31
31
  maybe_print_corrected_source
32
32
 
33
+ merge_todo_audit_status(runner_status(runner, all_pass_or_excluded))
34
+ end
35
+
36
+ def runner_status(runner, all_pass_or_excluded)
33
37
  if runner.aborting?
34
38
  STATUS_INTERRUPTED
35
39
  elsif all_pass_or_excluded && runner.errors.empty?
@@ -39,6 +43,33 @@ module RuboCop
39
43
  end
40
44
  end
41
45
 
46
+ def merge_todo_audit_status(status)
47
+ return status if status == STATUS_INTERRUPTED || !@options[:report_unused_todo_entries]
48
+
49
+ audit_status = report_unused_todo_entries
50
+ status == STATUS_SUCCESS ? audit_status : status
51
+ end
52
+
53
+ def report_unused_todo_entries
54
+ audit = TodoAudit.new(@config_store, @options)
55
+ unused = audit.unused_entries
56
+
57
+ if unused.nil?
58
+ warn Rainbow("No `#{audit.todo_file}` found; nothing to audit.").yellow
59
+ return STATUS_SUCCESS
60
+ end
61
+ return STATUS_SUCCESS if unused.empty?
62
+
63
+ print_unused_todo_entries(audit.todo_file, unused)
64
+ STATUS_OFFENSES
65
+ end
66
+
67
+ def print_unused_todo_entries(todo_file, unused)
68
+ noun = unused.size == 1 ? 'entry' : 'entries'
69
+ warn Rainbow("\n#{unused.size} unused todo #{noun} found in `#{todo_file}`:").red
70
+ unused.each { |entry| warn " #{entry.cop_name}: #{entry.path}" }
71
+ end
72
+
42
73
  def with_redirect
43
74
  if @options[:stderr]
44
75
  orig_stdout = $stdout
data/lib/rubocop/cli.rb CHANGED
@@ -35,7 +35,7 @@ module RuboCop
35
35
  # @param args [Array<String>] command line arguments
36
36
  # @return [Integer] UNIX exit code
37
37
  #
38
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
38
+ # rubocop:disable-next Metrics/MethodLength, Metrics/AbcSize
39
39
  def run(args = ARGV)
40
40
  time_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
41
41
 
@@ -80,11 +80,10 @@ module RuboCop
80
80
  puts "Finished in #{elapsed_time.round(5)} seconds"
81
81
  end
82
82
  end
83
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
84
83
 
85
84
  private
86
85
 
87
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
86
+ # rubocop:disable-next Metrics/MethodLength, Metrics/AbcSize
88
87
  def profile_if_needed
89
88
  return yield unless @options[:profile]
90
89
 
@@ -116,7 +115,6 @@ module RuboCop
116
115
  end
117
116
  status
118
117
  end
119
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
120
118
 
121
119
  def require_gem(name)
122
120
  require name
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ class CommentConfig
5
+ # A disabled line range that remembers the directive comment that opened
6
+ # it. Value-equal to a plain `Range`, so consumers comparing or hashing
7
+ # ranges are unaffected.
8
+ # @api private
9
+ class DirectiveRange < Range
10
+ attr_reader :directive
11
+
12
+ def initialize(first_line, last_line, directive)
13
+ super(first_line, last_line)
14
+ @directive = directive
15
+ end
16
+ end
17
+
18
+ # The per-cop state accumulated while analyzing directives: the disabled
19
+ # ranges so far, plus the line and directive of the currently open
20
+ # disable, if any.
21
+ # @api private
22
+ CopAnalysis = Struct.new(:line_ranges, :start_line_number, :start_directive) do
23
+ # The open range (if any) closed at the given line, appended to the
24
+ # accumulated ranges, each remembering the directive that opened it.
25
+ def close(line)
26
+ return line_ranges unless start_line_number
27
+
28
+ line_ranges + [DirectiveRange.new(start_line_number, line, start_directive)]
29
+ end
30
+ end
31
+ end
32
+ end