rubocop 1.68.0 → 1.69.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +41 -6
  4. data/lib/rubocop/cop/base.rb +1 -1
  5. data/lib/rubocop/cop/bundler/gem_filename.rb +0 -1
  6. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +0 -1
  7. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +1 -1
  8. data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +1 -2
  9. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +0 -2
  10. data/lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb +2 -4
  11. data/lib/rubocop/cop/internal_affairs/numblock_handler.rb +1 -1
  12. data/lib/rubocop/cop/internal_affairs/operator_keyword.rb +46 -0
  13. data/lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +0 -2
  14. data/lib/rubocop/cop/internal_affairs.rb +1 -0
  15. data/lib/rubocop/cop/layout/argument_alignment.rb +1 -2
  16. data/lib/rubocop/cop/layout/array_alignment.rb +1 -1
  17. data/lib/rubocop/cop/layout/begin_end_alignment.rb +0 -1
  18. data/lib/rubocop/cop/layout/block_alignment.rb +1 -2
  19. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +1 -1
  20. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +2 -3
  21. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +3 -4
  22. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +3 -1
  23. data/lib/rubocop/cop/layout/indentation_width.rb +7 -7
  24. data/lib/rubocop/cop/layout/leading_comment_space.rb +15 -0
  25. data/lib/rubocop/cop/layout/line_length.rb +118 -4
  26. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -1
  27. data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +1 -1
  28. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +2 -3
  29. data/lib/rubocop/cop/layout/parameter_alignment.rb +3 -4
  30. data/lib/rubocop/cop/layout/redundant_line_break.rb +3 -35
  31. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +3 -2
  32. data/lib/rubocop/cop/layout/space_around_keyword.rb +1 -1
  33. data/lib/rubocop/cop/layout/space_around_operators.rb +16 -17
  34. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +6 -0
  35. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +4 -0
  36. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +0 -1
  37. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +11 -12
  38. data/lib/rubocop/cop/lint/circular_argument_reference.rb +2 -0
  39. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +1 -1
  40. data/lib/rubocop/cop/lint/empty_ensure.rb +1 -1
  41. data/lib/rubocop/cop/lint/empty_file.rb +0 -2
  42. data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
  43. data/lib/rubocop/cop/lint/float_comparison.rb +14 -6
  44. data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -3
  45. data/lib/rubocop/cop/lint/hash_new_with_keyword_arguments_as_default.rb +55 -0
  46. data/lib/rubocop/cop/lint/interpolation_check.rb +9 -0
  47. data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +3 -0
  48. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +1 -1
  49. data/lib/rubocop/cop/lint/mixed_case_range.rb +2 -5
  50. data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
  51. data/lib/rubocop/cop/lint/no_return_in_begin_end_blocks.rb +2 -2
  52. data/lib/rubocop/cop/lint/non_atomic_file_operation.rb +1 -1
  53. data/lib/rubocop/cop/lint/number_conversion.rb +0 -1
  54. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +1 -2
  55. data/lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb +106 -0
  56. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +1 -2
  57. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +1 -1
  58. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +1 -1
  59. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +12 -7
  60. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +8 -7
  61. data/lib/rubocop/cop/lint/regexp_as_condition.rb +0 -1
  62. data/lib/rubocop/cop/lint/rescue_type.rb +3 -7
  63. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +2 -0
  64. data/lib/rubocop/cop/lint/self_assignment.rb +8 -10
  65. data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
  66. data/lib/rubocop/cop/lint/unused_method_argument.rb +18 -2
  67. data/lib/rubocop/cop/lint/useless_defined.rb +55 -0
  68. data/lib/rubocop/cop/lint/useless_rescue.rb +1 -1
  69. data/lib/rubocop/cop/lint/useless_setter_call.rb +14 -25
  70. data/lib/rubocop/cop/lint/void.rb +3 -2
  71. data/lib/rubocop/cop/metrics/class_length.rb +7 -7
  72. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1 -1
  73. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -2
  74. data/lib/rubocop/cop/mixin/check_assignment.rb +4 -12
  75. data/lib/rubocop/cop/mixin/check_single_line_suitability.rb +49 -0
  76. data/lib/rubocop/cop/mixin/dig_help.rb +27 -0
  77. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +5 -9
  78. data/lib/rubocop/cop/mixin/range_help.rb +0 -1
  79. data/lib/rubocop/cop/mixin/target_ruby_version.rb +17 -1
  80. data/lib/rubocop/cop/naming/constant_name.rb +6 -7
  81. data/lib/rubocop/cop/naming/file_name.rb +0 -2
  82. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +11 -12
  83. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +3 -11
  84. data/lib/rubocop/cop/naming/variable_name.rb +3 -4
  85. data/lib/rubocop/cop/naming/variable_number.rb +2 -3
  86. data/lib/rubocop/cop/style/access_modifier_declarations.rb +53 -24
  87. data/lib/rubocop/cop/style/ambiguous_endless_method_definition.rb +1 -1
  88. data/lib/rubocop/cop/style/array_intersect.rb +5 -4
  89. data/lib/rubocop/cop/style/bitwise_predicate.rb +1 -1
  90. data/lib/rubocop/cop/style/block_delimiters.rb +1 -1
  91. data/lib/rubocop/cop/style/case_like_if.rb +8 -11
  92. data/lib/rubocop/cop/style/commented_keyword.rb +11 -1
  93. data/lib/rubocop/cop/style/conditional_assignment.rb +19 -21
  94. data/lib/rubocop/cop/style/constant_visibility.rb +3 -12
  95. data/lib/rubocop/cop/style/dig_chain.rb +90 -0
  96. data/lib/rubocop/cop/style/file_null.rb +73 -0
  97. data/lib/rubocop/cop/style/file_touch.rb +75 -0
  98. data/lib/rubocop/cop/style/for.rb +0 -1
  99. data/lib/rubocop/cop/style/global_vars.rb +1 -3
  100. data/lib/rubocop/cop/style/guard_clause.rb +1 -1
  101. data/lib/rubocop/cop/style/hash_conversion.rb +1 -2
  102. data/lib/rubocop/cop/style/if_inside_else.rb +0 -1
  103. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +1 -2
  104. data/lib/rubocop/cop/style/if_with_semicolon.rb +14 -5
  105. data/lib/rubocop/cop/style/inverse_methods.rb +0 -1
  106. data/lib/rubocop/cop/style/keyword_arguments_merging.rb +2 -2
  107. data/lib/rubocop/cop/style/lambda_call.rb +0 -1
  108. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +1 -1
  109. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +7 -11
  110. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +33 -3
  111. data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
  112. data/lib/rubocop/cop/style/mutable_constant.rb +4 -5
  113. data/lib/rubocop/cop/style/negated_if_else_condition.rb +6 -4
  114. data/lib/rubocop/cop/style/nested_ternary_operator.rb +5 -4
  115. data/lib/rubocop/cop/style/not.rb +1 -1
  116. data/lib/rubocop/cop/style/one_line_conditional.rb +25 -4
  117. data/lib/rubocop/cop/style/operator_method_call.rb +5 -6
  118. data/lib/rubocop/cop/style/or_assignment.rb +3 -6
  119. data/lib/rubocop/cop/style/parallel_assignment.rb +8 -13
  120. data/lib/rubocop/cop/style/raise_args.rb +1 -1
  121. data/lib/rubocop/cop/style/redundant_assignment.rb +1 -1
  122. data/lib/rubocop/cop/style/redundant_condition.rb +36 -21
  123. data/lib/rubocop/cop/style/redundant_line_continuation.rb +7 -6
  124. data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -1
  125. data/lib/rubocop/cop/style/redundant_regexp_argument.rb +1 -0
  126. data/lib/rubocop/cop/style/redundant_return.rb +2 -2
  127. data/lib/rubocop/cop/style/redundant_self.rb +7 -14
  128. data/lib/rubocop/cop/style/redundant_self_assignment.rb +7 -5
  129. data/lib/rubocop/cop/style/redundant_self_assignment_branch.rb +4 -4
  130. data/lib/rubocop/cop/style/redundant_sort.rb +1 -1
  131. data/lib/rubocop/cop/style/rescue_modifier.rb +2 -3
  132. data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
  133. data/lib/rubocop/cop/style/select_by_regexp.rb +1 -1
  134. data/lib/rubocop/cop/style/self_assignment.rb +11 -17
  135. data/lib/rubocop/cop/style/signal_exception.rb +2 -3
  136. data/lib/rubocop/cop/style/single_argument_dig.rb +9 -5
  137. data/lib/rubocop/cop/style/single_line_do_end_block.rb +13 -3
  138. data/lib/rubocop/cop/style/sole_nested_conditional.rb +2 -3
  139. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  140. data/lib/rubocop/cop/style/string_concatenation.rb +0 -1
  141. data/lib/rubocop/cop/style/swap_values.rb +4 -15
  142. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +4 -4
  143. data/lib/rubocop/cop/style/variable_interpolation.rb +1 -2
  144. data/lib/rubocop/cop/variable_force.rb +4 -10
  145. data/lib/rubocop/cops_documentation_generator.rb +9 -1
  146. data/lib/rubocop/version.rb +1 -1
  147. data/lib/rubocop.rb +8 -0
  148. metadata +17 -8
@@ -37,33 +37,29 @@ module RuboCop
37
37
  private
38
38
 
39
39
  def check(node, var_type)
40
- var_name, rhs = *node
41
- return unless rhs
40
+ return unless (rhs = node.expression)
42
41
 
43
- if rhs.send_type?
44
- check_send_node(node, rhs, var_name, var_type)
42
+ if rhs.send_type? && rhs.arguments.one?
43
+ check_send_node(node, rhs, node.name, var_type)
45
44
  elsif rhs.operator_keyword?
46
- check_boolean_node(node, rhs, var_name, var_type)
45
+ check_boolean_node(node, rhs, node.name, var_type)
47
46
  end
48
47
  end
49
48
 
50
49
  def check_send_node(node, rhs, var_name, var_type)
51
- receiver, method_name, *_args = *rhs
52
- return unless OPS.include?(method_name)
50
+ return unless OPS.include?(rhs.method_name)
53
51
 
54
52
  target_node = s(var_type, var_name)
55
- return unless receiver == target_node
53
+ return unless rhs.receiver == target_node
56
54
 
57
- add_offense(node, message: format(MSG, method: method_name)) do |corrector|
55
+ add_offense(node, message: format(MSG, method: rhs.method_name)) do |corrector|
58
56
  autocorrect(corrector, node)
59
57
  end
60
58
  end
61
59
 
62
60
  def check_boolean_node(node, rhs, var_name, var_type)
63
- first_operand, _second_operand = *rhs
64
-
65
61
  target_node = s(var_type, var_name)
66
- return unless first_operand == target_node
62
+ return unless rhs.lhs == target_node
67
63
 
68
64
  operator = rhs.loc.operator.source
69
65
  add_offense(node, message: format(MSG, method: operator)) do |corrector|
@@ -72,7 +68,7 @@ module RuboCop
72
68
  end
73
69
 
74
70
  def autocorrect(corrector, node)
75
- _var_name, rhs = *node
71
+ rhs = node.expression
76
72
 
77
73
  if rhs.send_type?
78
74
  autocorrect_send_node(corrector, node, rhs)
@@ -82,13 +78,11 @@ module RuboCop
82
78
  end
83
79
 
84
80
  def autocorrect_send_node(corrector, node, rhs)
85
- _receiver, method_name, args = *rhs
86
- apply_autocorrect(corrector, node, rhs, method_name.to_s, args)
81
+ apply_autocorrect(corrector, node, rhs, rhs.method_name, rhs.first_argument)
87
82
  end
88
83
 
89
84
  def autocorrect_boolean_node(corrector, node, rhs)
90
- _first_operand, second_operand = *rhs
91
- apply_autocorrect(corrector, node, rhs, rhs.loc.operator.source, second_operand)
85
+ apply_autocorrect(corrector, node, rhs, rhs.loc.operator.source, rhs.rhs)
92
86
  end
93
87
 
94
88
  def apply_autocorrect(corrector, node, rhs, operator, new_rhs)
@@ -122,10 +122,9 @@ module RuboCop
122
122
  def on_rescue(node)
123
123
  return unless style == :semantic
124
124
 
125
- begin_node, *rescue_nodes, _else_node = *node
126
- check_scope(:raise, begin_node)
125
+ check_scope(:raise, node.body)
127
126
 
128
- rescue_nodes.each do |rescue_node|
127
+ node.resbody_branches.each do |rescue_node|
129
128
  check_scope(:fail, rescue_node)
130
129
  allow(:raise, rescue_node)
131
130
  end
@@ -33,22 +33,19 @@ module RuboCop
33
33
  #
34
34
  class SingleArgumentDig < Base
35
35
  extend AutoCorrector
36
+ include DigHelp
36
37
 
37
38
  MSG = 'Use `%<receiver>s[%<argument>s]` instead of `%<original>s`.'
38
39
  RESTRICT_ON_SEND = %i[dig].freeze
39
40
  IGNORED_ARGUMENT_TYPES = %i[block_pass forwarded_restarg forwarded_args hash].freeze
40
41
 
41
- # @!method single_argument_dig?(node)
42
- def_node_matcher :single_argument_dig?, <<~PATTERN
43
- (send _ :dig $!splat)
44
- PATTERN
45
-
46
42
  def on_send(node)
47
43
  return unless node.receiver
48
44
 
49
45
  expression = single_argument_dig?(node)
50
46
  return unless expression
51
47
  return if IGNORED_ARGUMENT_TYPES.include?(expression.type)
48
+ return if ignore_dig_chain?(node)
52
49
 
53
50
  receiver = node.receiver.source
54
51
  argument = expression.source
@@ -63,6 +60,13 @@ module RuboCop
63
60
 
64
61
  ignore_node(node)
65
62
  end
63
+
64
+ private
65
+
66
+ def ignore_dig_chain?(node)
67
+ dig_chain_enabled? &&
68
+ (dig?(node.receiver) || dig?(node.parent))
69
+ end
66
70
  end
67
71
  end
68
72
  end
@@ -6,8 +6,13 @@ module RuboCop
6
6
  # Checks for single-line `do`...`end` block.
7
7
  #
8
8
  # In practice a single line `do`...`end` is autocorrected when `EnforcedStyle: semantic`
9
- # in `Style/BlockDelimiters`. The autocorrection maintains the `do` ... `end` syntax to
10
- # preserve semantics and does not change it to `{`...`}` block.
9
+ # is configured for `Style/BlockDelimiters`. The autocorrection maintains the
10
+ # `do` ... `end` syntax to preserve semantics and does not change it to `{`...`}` block.
11
+ #
12
+ # NOTE: If `InspectBlocks` is set to `true` for `Layout/RedundantLineBreak`, blocks will
13
+ # be autocorrected to be on a single line if possible. This cop respects that configuration
14
+ # by not registering an offense if it would subsequently cause a
15
+ # `Layout/RedundantLineBreak` offense.
11
16
  #
12
17
  # @example
13
18
  #
@@ -27,12 +32,14 @@ module RuboCop
27
32
  #
28
33
  class SingleLineDoEndBlock < Base
29
34
  extend AutoCorrector
35
+ include CheckSingleLineSuitability
30
36
 
31
37
  MSG = 'Prefer multiline `do`...`end` block.'
32
38
 
33
39
  # rubocop:disable Metrics/AbcSize
34
40
  def on_block(node)
35
41
  return if !node.single_line? || node.braces?
42
+ return if single_line_blocks_preferred? && suitable_as_single_line?(node)
36
43
 
37
44
  add_offense(node) do |corrector|
38
45
  corrector.insert_after(do_line(node), "\n")
@@ -60,7 +67,10 @@ module RuboCop
60
67
  end
61
68
  end
62
69
 
63
- def x(corrector, node); end
70
+ def single_line_blocks_preferred?
71
+ redundant_line_break_config = @config.for_cop('Layout/RedundantLineBreak')
72
+ redundant_line_break_config['Enabled'] && redundant_line_break_config['InspectBlocks']
73
+ end
64
74
  end
65
75
  end
66
76
  end
@@ -214,7 +214,7 @@ module RuboCop
214
214
  end
215
215
 
216
216
  def insert_bang_for_and(corrector, node)
217
- lhs, rhs = *node
217
+ lhs, rhs = *node # rubocop:disable InternalAffairs/NodeDestructuring
218
218
 
219
219
  if lhs.and_type?
220
220
  insert_bang_for_and(corrector, lhs)
@@ -237,8 +237,7 @@ module RuboCop
237
237
  end
238
238
 
239
239
  def wrap_condition?(node)
240
- node.and_type? || node.or_type? ||
241
- (node.call_type? && node.arguments.any? && !node.parenthesized?)
240
+ node.operator_keyword? || (node.call_type? && node.arguments.any? && !node.parenthesized?)
242
241
  end
243
242
 
244
243
  def replace_condition(condition)
@@ -149,7 +149,7 @@ module RuboCop
149
149
  end
150
150
 
151
151
  def on_gvar(node)
152
- global_var, = *node
152
+ global_var = node.name
153
153
 
154
154
  return unless (preferred = preferred_names(global_var))
155
155
 
@@ -51,7 +51,6 @@ module RuboCop
51
51
  # Pathname.new('/') + 'test'
52
52
  #
53
53
  class StringConcatenation < Base
54
- include Util
55
54
  include RangeHelp
56
55
  extend AutoCorrector
57
56
 
@@ -79,26 +79,15 @@ module RuboCop
79
79
  end
80
80
 
81
81
  def lhs(node)
82
- case node.type
83
- when :casgn
84
- namespace, name, = *node
85
- if namespace
86
- "#{namespace.const_name}::#{name}"
87
- else
88
- name.to_s
89
- end
82
+ if node.casgn_type?
83
+ "#{'::' if node.absolute?}#{node.const_name}"
90
84
  else
91
- node.children[0].to_s
85
+ node.name.to_s
92
86
  end
93
87
  end
94
88
 
95
89
  def rhs(node)
96
- case node.type
97
- when :casgn
98
- node.children[2].source
99
- else
100
- node.children[1].source
101
- end
90
+ node.expression.source
102
91
  end
103
92
 
104
93
  def correction_range(tmp_assign, y_assign)
@@ -94,7 +94,7 @@ module RuboCop
94
94
  end
95
95
 
96
96
  def unneeded_ranges(node)
97
- node.masgn_type? ? (mlhs_node, = *node) : mlhs_node = node
97
+ mlhs_node = node.masgn_type? ? node.lhs : node
98
98
  variables = *mlhs_node
99
99
 
100
100
  main_offense = main_node_offense(node)
@@ -106,15 +106,15 @@ module RuboCop
106
106
  end
107
107
 
108
108
  def main_node_offense(node)
109
- node.masgn_type? ? (mlhs_node, right = *node) : mlhs_node = node
110
-
109
+ mlhs_node = node.masgn_type? ? node.lhs : node
111
110
  variables = *mlhs_node
111
+
112
112
  first_offense = find_first_offense(variables)
113
113
 
114
114
  return unless first_offense
115
115
 
116
116
  if unused_variables_only?(first_offense, variables)
117
- return unused_range(node.type, mlhs_node, right)
117
+ return unused_range(node.type, mlhs_node, node.rhs)
118
118
  end
119
119
 
120
120
  return range_for_parentheses(first_offense, mlhs_node) if Util.parentheses?(mlhs_node)
@@ -19,8 +19,7 @@ module RuboCop
19
19
  include Interpolation
20
20
  extend AutoCorrector
21
21
 
22
- MSG = 'Replace interpolated variable `%<variable>s` ' \
23
- 'with expression `#{%<variable>s}`.' # rubocop:disable Lint/InterpolationCheck
22
+ MSG = 'Replace interpolated variable `%<variable>s` with expression `#{%<variable>s}`.'
24
23
 
25
24
  def on_node_with_interpolations(node)
26
25
  var_nodes(node.children).each do |var_node|
@@ -194,15 +194,10 @@ module RuboCop
194
194
  end
195
195
 
196
196
  def process_variable_operator_assignment(node)
197
- if LOGICAL_OPERATOR_ASSIGNMENT_TYPES.include?(node.type)
198
- asgn_node, rhs_node = *node
199
- else
200
- asgn_node, _operator, rhs_node = *node
201
- end
202
-
197
+ asgn_node = node.lhs
203
198
  return unless asgn_node.lvasgn_type?
204
199
 
205
- name = asgn_node.children.first
200
+ name = asgn_node.name
206
201
 
207
202
  variable_table.declare_variable(name, asgn_node) unless variable_table.variable_exist?(name)
208
203
 
@@ -222,7 +217,7 @@ module RuboCop
222
217
  # before processing rhs nodes.
223
218
 
224
219
  variable_table.reference_variable(name, node)
225
- process_node(rhs_node)
220
+ process_node(node.rhs)
226
221
  variable_table.assign_to_variable(name, asgn_node)
227
222
 
228
223
  skip_children!
@@ -355,8 +350,7 @@ module RuboCop
355
350
  when :lvasgn
356
351
  AssignmentReference.new(node)
357
352
  when *OPERATOR_ASSIGNMENT_TYPES
358
- asgn_node = node.children.first
359
- VariableReference.new(asgn_node.children.first) if asgn_node.lvasgn_type?
353
+ VariableReference.new(node.lhs.name) if node.lhs.lvasgn_type?
360
354
  end
361
355
  end
362
356
 
@@ -114,7 +114,15 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
114
114
  def required_ruby_version(cop)
115
115
  return '' unless cop.respond_to?(:required_minimum_ruby_version)
116
116
 
117
- "NOTE: Required Ruby version: #{cop.required_minimum_ruby_version}\n\n"
117
+ if cop.required_minimum_ruby_version
118
+ requirement = cop.required_minimum_ruby_version
119
+ elsif cop.required_maximum_ruby_version
120
+ requirement = "<= #{cop.required_maximum_ruby_version}"
121
+ else
122
+ return ''
123
+ end
124
+
125
+ "NOTE: Requires Ruby version #{requirement}\n\n"
118
126
  end
119
127
 
120
128
  # rubocop:disable Metrics/MethodLength
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.68.0'
6
+ STRING = '1.69.0'
7
7
 
8
8
  MSG = '%<version>s (using %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
data/lib/rubocop.rb CHANGED
@@ -78,12 +78,14 @@ require_relative 'rubocop/cop/mixin/allowed_receivers'
78
78
  require_relative 'rubocop/cop/mixin/auto_corrector' # rubocop:todo Naming/InclusiveLanguage
79
79
  require_relative 'rubocop/cop/mixin/check_assignment'
80
80
  require_relative 'rubocop/cop/mixin/check_line_breakable'
81
+ require_relative 'rubocop/cop/mixin/check_single_line_suitability'
81
82
  require_relative 'rubocop/cop/mixin/configurable_max'
82
83
  require_relative 'rubocop/cop/mixin/code_length' # relies on configurable_max
83
84
  require_relative 'rubocop/cop/mixin/configurable_enforced_style'
84
85
  require_relative 'rubocop/cop/mixin/configurable_formatting'
85
86
  require_relative 'rubocop/cop/mixin/configurable_naming'
86
87
  require_relative 'rubocop/cop/mixin/configurable_numbering'
88
+ require_relative 'rubocop/cop/mixin/dig_help'
87
89
  require_relative 'rubocop/cop/mixin/documentation_comment'
88
90
  require_relative 'rubocop/cop/mixin/duplication'
89
91
  require_relative 'rubocop/cop/mixin/range_help'
@@ -333,6 +335,7 @@ require_relative 'rubocop/cop/lint/float_comparison'
333
335
  require_relative 'rubocop/cop/lint/float_out_of_range'
334
336
  require_relative 'rubocop/cop/lint/format_parameter_mismatch'
335
337
  require_relative 'rubocop/cop/lint/hash_compare_by_identity'
338
+ require_relative 'rubocop/cop/lint/hash_new_with_keyword_arguments_as_default'
336
339
  require_relative 'rubocop/cop/lint/heredoc_method_call_position'
337
340
  require_relative 'rubocop/cop/lint/identity_comparison'
338
341
  require_relative 'rubocop/cop/lint/implicit_string_concatenation'
@@ -360,6 +363,7 @@ require_relative 'rubocop/cop/lint/non_deterministic_require_order'
360
363
  require_relative 'rubocop/cop/lint/non_local_exit_from_iterator'
361
364
  require_relative 'rubocop/cop/lint/number_conversion'
362
365
  require_relative 'rubocop/cop/lint/numbered_parameter_assignment'
366
+ require_relative 'rubocop/cop/lint/numeric_operation_with_constant_result'
363
367
  require_relative 'rubocop/cop/lint/or_assignment_to_constant'
364
368
  require_relative 'rubocop/cop/lint/ordered_magic_comments'
365
369
  require_relative 'rubocop/cop/lint/out_of_range_regexp_ref'
@@ -417,6 +421,7 @@ require_relative 'rubocop/cop/lint/uri_escape_unescape'
417
421
  require_relative 'rubocop/cop/lint/uri_regexp'
418
422
  require_relative 'rubocop/cop/lint/useless_access_modifier'
419
423
  require_relative 'rubocop/cop/lint/useless_assignment'
424
+ require_relative 'rubocop/cop/lint/useless_defined'
420
425
  require_relative 'rubocop/cop/lint/useless_else_without_rescue'
421
426
  require_relative 'rubocop/cop/lint/useless_method_definition'
422
427
  require_relative 'rubocop/cop/lint/useless_numeric_operation'
@@ -505,6 +510,7 @@ require_relative 'rubocop/cop/style/copyright'
505
510
  require_relative 'rubocop/cop/style/data_inheritance'
506
511
  require_relative 'rubocop/cop/style/date_time'
507
512
  require_relative 'rubocop/cop/style/def_with_parentheses'
513
+ require_relative 'rubocop/cop/style/dig_chain'
508
514
  require_relative 'rubocop/cop/style/dir'
509
515
  require_relative 'rubocop/cop/style/dir_empty'
510
516
  require_relative 'rubocop/cop/style/disable_cops_within_source_code_directive'
@@ -534,7 +540,9 @@ require_relative 'rubocop/cop/style/explicit_block_argument'
534
540
  require_relative 'rubocop/cop/style/exponential_notation'
535
541
  require_relative 'rubocop/cop/style/fetch_env_var'
536
542
  require_relative 'rubocop/cop/style/file_empty'
543
+ require_relative 'rubocop/cop/style/file_null'
537
544
  require_relative 'rubocop/cop/style/file_read'
545
+ require_relative 'rubocop/cop/style/file_touch'
538
546
  require_relative 'rubocop/cop/style/file_write'
539
547
  require_relative 'rubocop/cop/style/float_division'
540
548
  require_relative 'rubocop/cop/style/for'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.68.0
4
+ version: 1.69.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2024-10-31 00:00:00.000000000 Z
13
+ date: 2024-11-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 1.32.2
117
+ version: 1.36.1
118
118
  - - "<"
119
119
  - !ruby/object:Gem::Version
120
120
  version: '2.0'
@@ -124,7 +124,7 @@ dependencies:
124
124
  requirements:
125
125
  - - ">="
126
126
  - !ruby/object:Gem::Version
127
- version: 1.32.2
127
+ version: 1.36.1
128
128
  - - "<"
129
129
  - !ruby/object:Gem::Version
130
130
  version: '2.0'
@@ -151,7 +151,7 @@ dependencies:
151
151
  version: 2.4.0
152
152
  - - "<"
153
153
  - !ruby/object:Gem::Version
154
- version: '3.0'
154
+ version: '4.0'
155
155
  type: :runtime
156
156
  prerelease: false
157
157
  version_requirements: !ruby/object:Gem::Requirement
@@ -161,7 +161,7 @@ dependencies:
161
161
  version: 2.4.0
162
162
  - - "<"
163
163
  - !ruby/object:Gem::Version
164
- version: '3.0'
164
+ version: '4.0'
165
165
  description: |
166
166
  RuboCop is a Ruby code style checking and code formatting tool.
167
167
  It aims to enforce the community-driven Ruby Style Guide.
@@ -282,6 +282,7 @@ files:
282
282
  - lib/rubocop/cop/internal_affairs/node_type_predicate.rb
283
283
  - lib/rubocop/cop/internal_affairs/numblock_handler.rb
284
284
  - lib/rubocop/cop/internal_affairs/offense_location_keyword.rb
285
+ - lib/rubocop/cop/internal_affairs/operator_keyword.rb
285
286
  - lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb
286
287
  - lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb
287
288
  - lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb
@@ -445,6 +446,7 @@ files:
445
446
  - lib/rubocop/cop/lint/float_out_of_range.rb
446
447
  - lib/rubocop/cop/lint/format_parameter_mismatch.rb
447
448
  - lib/rubocop/cop/lint/hash_compare_by_identity.rb
449
+ - lib/rubocop/cop/lint/hash_new_with_keyword_arguments_as_default.rb
448
450
  - lib/rubocop/cop/lint/heredoc_method_call_position.rb
449
451
  - lib/rubocop/cop/lint/identity_comparison.rb
450
452
  - lib/rubocop/cop/lint/implicit_string_concatenation.rb
@@ -472,6 +474,7 @@ files:
472
474
  - lib/rubocop/cop/lint/non_local_exit_from_iterator.rb
473
475
  - lib/rubocop/cop/lint/number_conversion.rb
474
476
  - lib/rubocop/cop/lint/numbered_parameter_assignment.rb
477
+ - lib/rubocop/cop/lint/numeric_operation_with_constant_result.rb
475
478
  - lib/rubocop/cop/lint/or_assignment_to_constant.rb
476
479
  - lib/rubocop/cop/lint/ordered_magic_comments.rb
477
480
  - lib/rubocop/cop/lint/out_of_range_regexp_ref.rb
@@ -529,6 +532,7 @@ files:
529
532
  - lib/rubocop/cop/lint/uri_regexp.rb
530
533
  - lib/rubocop/cop/lint/useless_access_modifier.rb
531
534
  - lib/rubocop/cop/lint/useless_assignment.rb
535
+ - lib/rubocop/cop/lint/useless_defined.rb
532
536
  - lib/rubocop/cop/lint/useless_else_without_rescue.rb
533
537
  - lib/rubocop/cop/lint/useless_method_definition.rb
534
538
  - lib/rubocop/cop/lint/useless_numeric_operation.rb
@@ -565,6 +569,7 @@ files:
565
569
  - lib/rubocop/cop/mixin/auto_corrector.rb
566
570
  - lib/rubocop/cop/mixin/check_assignment.rb
567
571
  - lib/rubocop/cop/mixin/check_line_breakable.rb
572
+ - lib/rubocop/cop/mixin/check_single_line_suitability.rb
568
573
  - lib/rubocop/cop/mixin/code_length.rb
569
574
  - lib/rubocop/cop/mixin/comments_help.rb
570
575
  - lib/rubocop/cop/mixin/configurable_enforced_style.rb
@@ -573,6 +578,7 @@ files:
573
578
  - lib/rubocop/cop/mixin/configurable_naming.rb
574
579
  - lib/rubocop/cop/mixin/configurable_numbering.rb
575
580
  - lib/rubocop/cop/mixin/def_node.rb
581
+ - lib/rubocop/cop/mixin/dig_help.rb
576
582
  - lib/rubocop/cop/mixin/documentation_comment.rb
577
583
  - lib/rubocop/cop/mixin/duplication.rb
578
584
  - lib/rubocop/cop/mixin/empty_lines_around_body.rb
@@ -701,6 +707,7 @@ files:
701
707
  - lib/rubocop/cop/style/data_inheritance.rb
702
708
  - lib/rubocop/cop/style/date_time.rb
703
709
  - lib/rubocop/cop/style/def_with_parentheses.rb
710
+ - lib/rubocop/cop/style/dig_chain.rb
704
711
  - lib/rubocop/cop/style/dir.rb
705
712
  - lib/rubocop/cop/style/dir_empty.rb
706
713
  - lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb
@@ -730,7 +737,9 @@ files:
730
737
  - lib/rubocop/cop/style/exponential_notation.rb
731
738
  - lib/rubocop/cop/style/fetch_env_var.rb
732
739
  - lib/rubocop/cop/style/file_empty.rb
740
+ - lib/rubocop/cop/style/file_null.rb
733
741
  - lib/rubocop/cop/style/file_read.rb
742
+ - lib/rubocop/cop/style/file_touch.rb
734
743
  - lib/rubocop/cop/style/file_write.rb
735
744
  - lib/rubocop/cop/style/float_division.rb
736
745
  - lib/rubocop/cop/style/for.rb
@@ -1026,9 +1035,9 @@ licenses:
1026
1035
  - MIT
1027
1036
  metadata:
1028
1037
  homepage_uri: https://rubocop.org/
1029
- changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.68.0
1038
+ changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.69.0
1030
1039
  source_code_uri: https://github.com/rubocop/rubocop/
1031
- documentation_uri: https://docs.rubocop.org/rubocop/1.68/
1040
+ documentation_uri: https://docs.rubocop.org/rubocop/1.69/
1032
1041
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
1033
1042
  rubygems_mfa_required: 'true'
1034
1043
  post_install_message: