rubocop 1.57.1 → 1.65.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 (266) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +4 -5
  4. data/assets/output.css.erb +159 -0
  5. data/assets/output.html.erb +1 -160
  6. data/config/default.yml +136 -19
  7. data/lib/rubocop/cached_data.rb +11 -3
  8. data/lib/rubocop/cli/command/auto_generate_config.rb +22 -8
  9. data/lib/rubocop/cli/command/lsp.rb +2 -2
  10. data/lib/rubocop/cli/command/show_docs_url.rb +2 -2
  11. data/lib/rubocop/cli.rb +10 -1
  12. data/lib/rubocop/config.rb +36 -12
  13. data/lib/rubocop/config_finder.rb +12 -2
  14. data/lib/rubocop/config_loader.rb +1 -2
  15. data/lib/rubocop/config_loader_resolver.rb +9 -3
  16. data/lib/rubocop/config_obsoletion.rb +11 -8
  17. data/lib/rubocop/config_validator.rb +14 -7
  18. data/lib/rubocop/cop/autocorrect_logic.rb +6 -1
  19. data/lib/rubocop/cop/base.rb +63 -16
  20. data/lib/rubocop/cop/bundler/gem_comment.rb +2 -2
  21. data/lib/rubocop/cop/bundler/gem_version.rb +3 -5
  22. data/lib/rubocop/cop/cop.rb +20 -2
  23. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +4 -8
  24. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +5 -13
  25. data/lib/rubocop/cop/documentation.rb +16 -6
  26. data/lib/rubocop/cop/exclude_limit.rb +1 -1
  27. data/lib/rubocop/cop/force.rb +12 -0
  28. data/lib/rubocop/cop/gemspec/add_runtime_dependency.rb +38 -0
  29. data/lib/rubocop/cop/gemspec/dependency_version.rb +3 -5
  30. data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +2 -2
  31. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
  32. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +5 -1
  33. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +3 -3
  34. data/lib/rubocop/cop/internal_affairs/example_description.rb +6 -5
  35. data/lib/rubocop/cop/internal_affairs/method_name_end_with.rb +8 -6
  36. data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +19 -20
  37. data/lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb +53 -0
  38. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +123 -29
  39. data/lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb +34 -0
  40. data/lib/rubocop/cop/internal_affairs.rb +2 -0
  41. data/lib/rubocop/cop/layout/argument_alignment.rb +1 -1
  42. data/lib/rubocop/cop/layout/case_indentation.rb +1 -1
  43. data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
  44. data/lib/rubocop/cop/layout/empty_comment.rb +3 -1
  45. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +14 -7
  46. data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +1 -1
  47. data/lib/rubocop/cop/layout/end_alignment.rb +15 -3
  48. data/lib/rubocop/cop/layout/extra_spacing.rb +4 -10
  49. data/lib/rubocop/cop/layout/first_argument_indentation.rb +2 -2
  50. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +24 -7
  51. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +1 -1
  52. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
  53. data/lib/rubocop/cop/layout/heredoc_indentation.rb +2 -2
  54. data/lib/rubocop/cop/layout/indentation_width.rb +1 -1
  55. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +1 -1
  56. data/lib/rubocop/cop/layout/line_length.rb +20 -20
  57. data/lib/rubocop/cop/layout/redundant_line_break.rb +16 -3
  58. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +4 -4
  59. data/lib/rubocop/cop/layout/single_line_block_chain.rb +5 -0
  60. data/lib/rubocop/cop/layout/space_around_operators.rb +53 -20
  61. data/lib/rubocop/cop/layout/space_before_block_braces.rb +19 -10
  62. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +1 -1
  63. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +3 -4
  64. data/lib/rubocop/cop/legacy/corrector.rb +12 -2
  65. data/lib/rubocop/cop/lint/assignment_in_condition.rb +6 -6
  66. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +2 -2
  67. data/lib/rubocop/cop/lint/constant_overwritten_in_rescue.rb +1 -1
  68. data/lib/rubocop/cop/lint/debugger.rb +29 -3
  69. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
  70. data/lib/rubocop/cop/lint/duplicate_case_condition.rb +1 -1
  71. data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -1
  72. data/lib/rubocop/cop/lint/empty_conditional_body.rb +2 -2
  73. data/lib/rubocop/cop/lint/empty_when.rb +1 -1
  74. data/lib/rubocop/cop/lint/erb_new_arguments.rb +24 -17
  75. data/lib/rubocop/cop/lint/float_comparison.rb +10 -0
  76. data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +2 -1
  77. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +14 -7
  78. data/lib/rubocop/cop/lint/it_without_arguments_in_block.rb +56 -0
  79. data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -1
  80. data/lib/rubocop/cop/lint/literal_assignment_in_condition.rb +85 -0
  81. data/lib/rubocop/cop/lint/mixed_case_range.rb +9 -4
  82. data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
  83. data/lib/rubocop/cop/lint/next_without_accumulator.rb +6 -21
  84. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +3 -5
  85. data/lib/rubocop/cop/lint/number_conversion.rb +9 -4
  86. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +54 -6
  87. data/lib/rubocop/cop/lint/redundant_with_index.rb +6 -2
  88. data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -2
  89. data/lib/rubocop/cop/lint/rescue_type.rb +1 -3
  90. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +3 -4
  91. data/lib/rubocop/cop/lint/script_permission.rb +3 -3
  92. data/lib/rubocop/cop/lint/self_assignment.rb +38 -0
  93. data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -0
  94. data/lib/rubocop/cop/lint/symbol_conversion.rb +7 -2
  95. data/lib/rubocop/cop/lint/syntax.rb +6 -3
  96. data/lib/rubocop/cop/lint/to_enum_arguments.rb +1 -3
  97. data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +1 -1
  98. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +3 -2
  99. data/lib/rubocop/cop/lint/unreachable_code.rb +4 -2
  100. data/lib/rubocop/cop/lint/unreachable_loop.rb +8 -2
  101. data/lib/rubocop/cop/lint/useless_access_modifier.rb +2 -2
  102. data/lib/rubocop/cop/lint/useless_times.rb +2 -2
  103. data/lib/rubocop/cop/lint/void.rb +53 -12
  104. data/lib/rubocop/cop/metrics/abc_size.rb +3 -3
  105. data/lib/rubocop/cop/metrics/block_nesting.rb +19 -7
  106. data/lib/rubocop/cop/metrics/class_length.rb +6 -1
  107. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +5 -5
  108. data/lib/rubocop/cop/mixin/alignment.rb +5 -1
  109. data/lib/rubocop/cop/mixin/allowed_methods.rb +7 -1
  110. data/lib/rubocop/cop/mixin/allowed_pattern.rb +15 -3
  111. data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
  112. data/lib/rubocop/cop/mixin/code_length.rb +12 -1
  113. data/lib/rubocop/cop/mixin/comments_help.rb +16 -12
  114. data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -0
  115. data/lib/rubocop/cop/mixin/configurable_max.rb +5 -1
  116. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +23 -13
  117. data/lib/rubocop/cop/mixin/method_complexity.rb +15 -6
  118. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -1
  119. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
  120. data/lib/rubocop/cop/mixin/rescue_node.rb +4 -0
  121. data/lib/rubocop/cop/mixin/safe_assignment.rb +1 -1
  122. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
  123. data/lib/rubocop/cop/naming/block_forwarding.rb +34 -7
  124. data/lib/rubocop/cop/naming/constant_name.rb +1 -2
  125. data/lib/rubocop/cop/naming/file_name.rb +2 -2
  126. data/lib/rubocop/cop/naming/inclusive_language.rb +1 -2
  127. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
  128. data/lib/rubocop/cop/naming/predicate_name.rb +2 -2
  129. data/lib/rubocop/cop/registry.rb +1 -1
  130. data/lib/rubocop/cop/security/compound_hash.rb +2 -2
  131. data/lib/rubocop/cop/security/open.rb +2 -2
  132. data/lib/rubocop/cop/style/access_modifier_declarations.rb +52 -2
  133. data/lib/rubocop/cop/style/accessor_grouping.rb +1 -1
  134. data/lib/rubocop/cop/style/alias.rb +1 -0
  135. data/lib/rubocop/cop/style/arguments_forwarding.rb +155 -21
  136. data/lib/rubocop/cop/style/array_first_last.rb +64 -0
  137. data/lib/rubocop/cop/style/auto_resource_cleanup.rb +21 -14
  138. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +2 -2
  139. data/lib/rubocop/cop/style/case_like_if.rb +5 -5
  140. data/lib/rubocop/cop/style/class_check.rb +1 -0
  141. data/lib/rubocop/cop/style/class_vars.rb +3 -3
  142. data/lib/rubocop/cop/style/collection_compact.rb +21 -11
  143. data/lib/rubocop/cop/style/combinable_loops.rb +13 -7
  144. data/lib/rubocop/cop/style/commented_keyword.rb +5 -2
  145. data/lib/rubocop/cop/style/concat_array_literals.rb +1 -0
  146. data/lib/rubocop/cop/style/conditional_assignment.rb +7 -8
  147. data/lib/rubocop/cop/style/copyright.rb +31 -21
  148. data/lib/rubocop/cop/style/date_time.rb +5 -4
  149. data/lib/rubocop/cop/style/documentation.rb +24 -24
  150. data/lib/rubocop/cop/style/documentation_method.rb +20 -0
  151. data/lib/rubocop/cop/style/each_for_simple_loop.rb +7 -7
  152. data/lib/rubocop/cop/style/each_with_object.rb +2 -2
  153. data/lib/rubocop/cop/style/empty_literal.rb +1 -1
  154. data/lib/rubocop/cop/style/eval_with_location.rb +6 -15
  155. data/lib/rubocop/cop/style/exact_regexp_match.rb +4 -2
  156. data/lib/rubocop/cop/style/explicit_block_argument.rb +2 -2
  157. data/lib/rubocop/cop/style/for.rb +2 -0
  158. data/lib/rubocop/cop/style/format_string.rb +9 -9
  159. data/lib/rubocop/cop/style/hash_each_methods.rb +105 -11
  160. data/lib/rubocop/cop/style/hash_except.rb +10 -6
  161. data/lib/rubocop/cop/style/hash_syntax.rb +24 -2
  162. data/lib/rubocop/cop/style/identical_conditional_branches.rb +12 -1
  163. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +5 -3
  164. data/lib/rubocop/cop/style/inverse_methods.rb +14 -13
  165. data/lib/rubocop/cop/style/invertible_unless_condition.rb +44 -2
  166. data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +82 -50
  167. data/lib/rubocop/cop/style/map_into_array.rb +175 -0
  168. data/lib/rubocop/cop/style/map_to_hash.rb +18 -8
  169. data/lib/rubocop/cop/style/map_to_set.rb +1 -1
  170. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +19 -5
  171. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +2 -4
  172. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +20 -0
  173. data/lib/rubocop/cop/style/method_def_parentheses.rb +1 -1
  174. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +2 -2
  175. data/lib/rubocop/cop/style/multiline_method_signature.rb +10 -1
  176. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +5 -3
  177. data/lib/rubocop/cop/style/next.rb +1 -1
  178. data/lib/rubocop/cop/style/nil_comparison.rb +2 -0
  179. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
  180. data/lib/rubocop/cop/style/numeric_predicate.rb +10 -2
  181. data/lib/rubocop/cop/style/object_then.rb +5 -3
  182. data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
  183. data/lib/rubocop/cop/style/operator_method_call.rb +2 -2
  184. data/lib/rubocop/cop/style/parallel_assignment.rb +3 -5
  185. data/lib/rubocop/cop/style/parentheses_around_condition.rb +8 -0
  186. data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
  187. data/lib/rubocop/cop/style/raise_args.rb +4 -1
  188. data/lib/rubocop/cop/style/redundant_argument.rb +27 -3
  189. data/lib/rubocop/cop/style/redundant_assignment.rb +10 -2
  190. data/lib/rubocop/cop/style/redundant_begin.rb +1 -1
  191. data/lib/rubocop/cop/style/redundant_current_directory_in_path.rb +5 -4
  192. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +17 -10
  193. data/lib/rubocop/cop/style/redundant_each.rb +7 -4
  194. data/lib/rubocop/cop/style/redundant_fetch_block.rb +3 -3
  195. data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +1 -1
  196. data/lib/rubocop/cop/style/redundant_filter_chain.rb +5 -4
  197. data/lib/rubocop/cop/style/redundant_line_continuation.rb +19 -2
  198. data/lib/rubocop/cop/style/redundant_parentheses.rb +50 -19
  199. data/lib/rubocop/cop/style/redundant_percent_q.rb +1 -1
  200. data/lib/rubocop/cop/style/redundant_return.rb +7 -1
  201. data/lib/rubocop/cop/style/redundant_self.rb +17 -2
  202. data/lib/rubocop/cop/style/redundant_sort.rb +9 -8
  203. data/lib/rubocop/cop/style/redundant_sort_by.rb +2 -2
  204. data/lib/rubocop/cop/style/redundant_string_escape.rb +1 -1
  205. data/lib/rubocop/cop/style/require_order.rb +1 -1
  206. data/lib/rubocop/cop/style/sample.rb +3 -4
  207. data/lib/rubocop/cop/style/select_by_regexp.rb +7 -6
  208. data/lib/rubocop/cop/style/self_assignment.rb +1 -1
  209. data/lib/rubocop/cop/style/semicolon.rb +8 -0
  210. data/lib/rubocop/cop/style/send.rb +4 -4
  211. data/lib/rubocop/cop/style/send_with_literal_method_name.rb +104 -0
  212. data/lib/rubocop/cop/style/single_argument_dig.rb +7 -3
  213. data/lib/rubocop/cop/style/single_line_do_end_block.rb +3 -1
  214. data/lib/rubocop/cop/style/slicing_with_range.rb +76 -10
  215. data/lib/rubocop/cop/style/special_global_vars.rb +1 -2
  216. data/lib/rubocop/cop/style/string_chars.rb +1 -0
  217. data/lib/rubocop/cop/style/strip.rb +7 -4
  218. data/lib/rubocop/cop/style/super_arguments.rb +174 -0
  219. data/lib/rubocop/cop/style/super_with_args_parentheses.rb +35 -0
  220. data/lib/rubocop/cop/style/symbol_proc.rb +75 -5
  221. data/lib/rubocop/cop/style/top_level_method_definition.rb +1 -1
  222. data/lib/rubocop/cop/style/unpack_first.rb +11 -14
  223. data/lib/rubocop/cop/style/zero_length_predicate.rb +28 -24
  224. data/lib/rubocop/cop/team.rb +13 -0
  225. data/lib/rubocop/cop/util.rb +7 -1
  226. data/lib/rubocop/cop/utils/regexp_ranges.rb +1 -1
  227. data/lib/rubocop/cops_documentation_generator.rb +16 -4
  228. data/lib/rubocop/directive_comment.rb +10 -8
  229. data/lib/rubocop/ext/regexp_node.rb +9 -4
  230. data/lib/rubocop/ext/regexp_parser.rb +4 -21
  231. data/lib/rubocop/formatter/clang_style_formatter.rb +3 -7
  232. data/lib/rubocop/formatter/disabled_config_formatter.rb +23 -8
  233. data/lib/rubocop/formatter/formatter_set.rb +7 -1
  234. data/lib/rubocop/formatter/html_formatter.rb +37 -14
  235. data/lib/rubocop/formatter/json_formatter.rb +0 -1
  236. data/lib/rubocop/formatter/offense_count_formatter.rb +12 -2
  237. data/lib/rubocop/formatter/tap_formatter.rb +3 -7
  238. data/lib/rubocop/formatter.rb +1 -1
  239. data/lib/rubocop/lockfile.rb +56 -7
  240. data/lib/rubocop/lsp/logger.rb +1 -1
  241. data/lib/rubocop/lsp/routes.rb +12 -15
  242. data/lib/rubocop/lsp/runtime.rb +1 -1
  243. data/lib/rubocop/lsp/server.rb +7 -2
  244. data/lib/rubocop/lsp/severity.rb +1 -1
  245. data/lib/rubocop/lsp.rb +36 -0
  246. data/lib/rubocop/magic_comment.rb +1 -1
  247. data/lib/rubocop/options.rb +14 -11
  248. data/lib/rubocop/path_util.rb +6 -2
  249. data/lib/rubocop/rake_task.rb +1 -1
  250. data/lib/rubocop/result_cache.rb +0 -1
  251. data/lib/rubocop/rspec/cop_helper.rb +8 -2
  252. data/lib/rubocop/rspec/expect_offense.rb +16 -8
  253. data/lib/rubocop/rspec/shared_contexts.rb +73 -16
  254. data/lib/rubocop/rspec/support.rb +3 -0
  255. data/lib/rubocop/runner.rb +14 -3
  256. data/lib/rubocop/server/cache.rb +11 -2
  257. data/lib/rubocop/server/client_command/exec.rb +2 -3
  258. data/lib/rubocop/server/client_command/start.rb +1 -1
  259. data/lib/rubocop/server/core.rb +4 -0
  260. data/lib/rubocop/server/server_command/exec.rb +0 -1
  261. data/lib/rubocop/target_finder.rb +84 -78
  262. data/lib/rubocop/target_ruby.rb +82 -80
  263. data/lib/rubocop/version.rb +19 -4
  264. data/lib/rubocop.rb +8 -0
  265. metadata +27 -29
  266. /data/lib/rubocop/formatter/{git_hub_actions_formatter.rb → github_actions_formatter.rb} +0 -0
@@ -4,7 +4,7 @@ module RuboCop
4
4
  # The kind of Ruby that code inspected by RuboCop is written in.
5
5
  # @api private
6
6
  class TargetRuby
7
- KNOWN_RUBIES = [2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3].freeze
7
+ KNOWN_RUBIES = [2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, 3.4].freeze
8
8
  DEFAULT_VERSION = 2.7
9
9
 
10
10
  OBSOLETE_RUBIES = {
@@ -48,6 +48,86 @@ module RuboCop
48
48
  end
49
49
  end
50
50
 
51
+ # The target ruby version may be found in a .gemspec file.
52
+ # @api private
53
+ class GemspecFile < Source
54
+ extend NodePattern::Macros
55
+
56
+ GEMSPEC_EXTENSION = '.gemspec'
57
+
58
+ # @!method required_ruby_version(node)
59
+ def_node_search :required_ruby_version, <<~PATTERN
60
+ (send _ :required_ruby_version= $_)
61
+ PATTERN
62
+
63
+ # @!method gem_requirement_versions(node)
64
+ def_node_matcher :gem_requirement_versions, <<~PATTERN
65
+ (send (const(const _ :Gem):Requirement) :new
66
+ {$str+ | (send $str :freeze)+ | (array $str+) | (array (send $str :freeze)+)}
67
+ )
68
+ PATTERN
69
+
70
+ def name
71
+ "`required_ruby_version` parameter (in #{gemspec_filename})"
72
+ end
73
+
74
+ private
75
+
76
+ def find_version
77
+ file = gemspec_filepath
78
+ return unless file && File.file?(file)
79
+
80
+ right_hand_side = version_from_gemspec_file(file)
81
+ return if right_hand_side.nil?
82
+
83
+ find_default_minimal_known_ruby(right_hand_side)
84
+ end
85
+
86
+ def gemspec_filename
87
+ @gemspec_filename ||= begin
88
+ basename = Pathname.new(@config.base_dir_for_path_parameters).basename.to_s
89
+ "#{basename}#{GEMSPEC_EXTENSION}"
90
+ end
91
+ end
92
+
93
+ def gemspec_filepath
94
+ @gemspec_filepath ||=
95
+ @config.find_file_upwards(gemspec_filename, @config.base_dir_for_path_parameters)
96
+ end
97
+
98
+ def version_from_gemspec_file(file)
99
+ processed_source = ProcessedSource.from_file(
100
+ file, DEFAULT_VERSION, parser_engine: @config.parser_engine
101
+ )
102
+ required_ruby_version(processed_source.ast).first
103
+ end
104
+
105
+ def version_from_right_hand_side(right_hand_side)
106
+ gem_requirement_versions = gem_requirement_versions(right_hand_side)
107
+
108
+ if right_hand_side.array_type? && right_hand_side.children.all?(&:str_type?)
109
+ version_from_array(right_hand_side)
110
+ elsif gem_requirement_versions
111
+ gem_requirement_versions.map(&:value)
112
+ elsif right_hand_side.str_type?
113
+ right_hand_side.value
114
+ end
115
+ end
116
+
117
+ def version_from_array(array)
118
+ array.children.map(&:value)
119
+ end
120
+
121
+ def find_default_minimal_known_ruby(right_hand_side)
122
+ version = version_from_right_hand_side(right_hand_side)
123
+ requirement = Gem::Requirement.new(version)
124
+
125
+ KNOWN_RUBIES.detect do |v|
126
+ v >= DEFAULT_VERSION && requirement.satisfied_by?(Gem::Version.new("#{v}.99"))
127
+ end
128
+ end
129
+ end
130
+
51
131
  # The target ruby version may be found in a .ruby-version file.
52
132
  # @api private
53
133
  class RubyVersionFile < Source
@@ -143,84 +223,6 @@ module RuboCop
143
223
  end
144
224
  end
145
225
 
146
- # The target ruby version may be found in a .gemspec file.
147
- # @api private
148
- class GemspecFile < Source
149
- extend NodePattern::Macros
150
-
151
- GEMSPEC_EXTENSION = '.gemspec'
152
-
153
- # @!method required_ruby_version(node)
154
- def_node_search :required_ruby_version, <<~PATTERN
155
- (send _ :required_ruby_version= $_)
156
- PATTERN
157
-
158
- # @!method gem_requirement_versions(node)
159
- def_node_matcher :gem_requirement_versions, <<~PATTERN
160
- (send (const(const _ :Gem):Requirement) :new
161
- {$str+ | (send $str :freeze)+ | (array $str+) | (array (send $str :freeze)+)}
162
- )
163
- PATTERN
164
-
165
- def name
166
- "`required_ruby_version` parameter (in #{gemspec_filename})"
167
- end
168
-
169
- private
170
-
171
- def find_version
172
- file = gemspec_filepath
173
- return unless file && File.file?(file)
174
-
175
- right_hand_side = version_from_gemspec_file(file)
176
- return if right_hand_side.nil?
177
-
178
- find_default_minimal_known_ruby(right_hand_side)
179
- end
180
-
181
- def gemspec_filename
182
- @gemspec_filename ||= begin
183
- basename = Pathname.new(@config.base_dir_for_path_parameters).basename.to_s
184
- "#{basename}#{GEMSPEC_EXTENSION}"
185
- end
186
- end
187
-
188
- def gemspec_filepath
189
- @gemspec_filepath ||=
190
- @config.find_file_upwards(gemspec_filename, @config.base_dir_for_path_parameters)
191
- end
192
-
193
- def version_from_gemspec_file(file)
194
- processed_source = ProcessedSource.from_file(file, DEFAULT_VERSION)
195
- required_ruby_version(processed_source.ast).first
196
- end
197
-
198
- def version_from_right_hand_side(right_hand_side)
199
- gem_requirement_versions = gem_requirement_versions(right_hand_side)
200
-
201
- if right_hand_side.array_type?
202
- version_from_array(right_hand_side)
203
- elsif gem_requirement_versions
204
- gem_requirement_versions.map(&:value)
205
- else
206
- right_hand_side.value
207
- end
208
- end
209
-
210
- def version_from_array(array)
211
- array.children.map(&:value)
212
- end
213
-
214
- def find_default_minimal_known_ruby(right_hand_side)
215
- version = version_from_right_hand_side(right_hand_side)
216
- requirement = Gem::Requirement.new(version)
217
-
218
- KNOWN_RUBIES.detect do |v|
219
- v >= DEFAULT_VERSION && requirement.satisfied_by?(Gem::Version.new("#{v}.99"))
220
- end
221
- end
222
- end
223
-
224
226
  # If all else fails, a default version will be picked.
225
227
  # @api private
226
228
  class Default < Source
@@ -241,10 +243,10 @@ module RuboCop
241
243
 
242
244
  SOURCES = [
243
245
  RuboCopConfig,
246
+ GemspecFile,
244
247
  RubyVersionFile,
245
248
  ToolVersionsFile,
246
249
  BundlerLockFile,
247
- GemspecFile,
248
250
  Default
249
251
  ].freeze
250
252
 
@@ -3,15 +3,15 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.57.1'
6
+ STRING = '1.65.0'
7
7
 
8
- MSG = '%<version>s (using Parser %<parser_version>s, ' \
8
+ MSG = '%<version>s (using %<parser_version>s, ' \
9
9
  'rubocop-ast %<rubocop_ast_version>s, ' \
10
10
  'running on %<ruby_engine>s %<ruby_version>s)%<server_mode>s [%<ruby_platform>s]'
11
11
 
12
12
  CANONICAL_FEATURE_NAMES = {
13
13
  'Rspec' => 'RSpec', 'Graphql' => 'GraphQL', 'Md' => 'Markdown', 'Factory_bot' => 'FactoryBot',
14
- 'Thread_safety' => 'ThreadSafety'
14
+ 'Thread_safety' => 'ThreadSafety', 'Rspec_rails' => 'RSpecRails'
15
15
  }.freeze
16
16
  EXTENSION_PATH_NAMES = {
17
17
  'rubocop-md' => 'markdown', 'rubocop-factory_bot' => 'factory_bot'
@@ -20,7 +20,7 @@ module RuboCop
20
20
  # @api private
21
21
  def self.version(debug: false, env: nil)
22
22
  if debug
23
- verbose_version = format(MSG, version: STRING, parser_version: Parser::VERSION,
23
+ verbose_version = format(MSG, version: STRING, parser_version: parser_version,
24
24
  rubocop_ast_version: RuboCop::AST::Version::STRING,
25
25
  ruby_engine: RUBY_ENGINE, ruby_version: RUBY_VERSION,
26
26
  server_mode: server_mode,
@@ -39,6 +39,21 @@ module RuboCop
39
39
  end
40
40
  end
41
41
 
42
+ # @api private
43
+ def self.parser_version
44
+ config_path = ConfigFinder.find_config_path(Dir.pwd)
45
+ yaml = Util.silence_warnings do
46
+ ConfigLoader.load_yaml_configuration(config_path)
47
+ end
48
+
49
+ if yaml.dig('AllCops', 'ParserEngine') == 'parser_prism'
50
+ require 'prism'
51
+ "Prism #{Prism::VERSION}"
52
+ else
53
+ "Parser #{Parser::VERSION}"
54
+ end
55
+ end
56
+
42
57
  # @api private
43
58
  def self.extension_versions(env)
44
59
  features = Util.silence_warnings do
data/lib/rubocop.rb CHANGED
@@ -169,6 +169,7 @@ require_relative 'rubocop/cop/bundler/gem_version'
169
169
  require_relative 'rubocop/cop/bundler/insecure_protocol_source'
170
170
  require_relative 'rubocop/cop/bundler/ordered_gems'
171
171
 
172
+ require_relative 'rubocop/cop/gemspec/add_runtime_dependency'
172
173
  require_relative 'rubocop/cop/gemspec/dependency_version'
173
174
  require_relative 'rubocop/cop/gemspec/deprecated_attribute_assignment'
174
175
  require_relative 'rubocop/cop/gemspec/development_dependencies'
@@ -332,8 +333,10 @@ require_relative 'rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler'
332
333
  require_relative 'rubocop/cop/lint/ineffective_access_modifier'
333
334
  require_relative 'rubocop/cop/lint/inherit_exception'
334
335
  require_relative 'rubocop/cop/lint/interpolation_check'
336
+ require_relative 'rubocop/cop/lint/it_without_arguments_in_block'
335
337
  require_relative 'rubocop/cop/lint/lambda_without_literal_block'
336
338
  require_relative 'rubocop/cop/lint/literal_as_condition'
339
+ require_relative 'rubocop/cop/lint/literal_assignment_in_condition'
337
340
  require_relative 'rubocop/cop/lint/literal_in_interpolation'
338
341
  require_relative 'rubocop/cop/lint/loop'
339
342
  require_relative 'rubocop/cop/lint/missing_cop_enable_directive'
@@ -454,6 +457,7 @@ require_relative 'rubocop/cop/style/alias'
454
457
  require_relative 'rubocop/cop/style/and_or'
455
458
  require_relative 'rubocop/cop/style/arguments_forwarding'
456
459
  require_relative 'rubocop/cop/style/array_coercion'
460
+ require_relative 'rubocop/cop/style/array_first_last'
457
461
  require_relative 'rubocop/cop/style/array_intersect'
458
462
  require_relative 'rubocop/cop/style/array_join'
459
463
  require_relative 'rubocop/cop/style/ascii_comments'
@@ -554,6 +558,7 @@ require_relative 'rubocop/cop/style/lambda'
554
558
  require_relative 'rubocop/cop/style/lambda_call'
555
559
  require_relative 'rubocop/cop/style/line_end_concatenation'
556
560
  require_relative 'rubocop/cop/style/magic_comment_format'
561
+ require_relative 'rubocop/cop/style/map_into_array'
557
562
  require_relative 'rubocop/cop/style/map_to_hash'
558
563
  require_relative 'rubocop/cop/style/map_to_set'
559
564
  require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
@@ -662,6 +667,7 @@ require_relative 'rubocop/cop/style/select_by_regexp'
662
667
  require_relative 'rubocop/cop/style/self_assignment'
663
668
  require_relative 'rubocop/cop/style/semicolon'
664
669
  require_relative 'rubocop/cop/style/send'
670
+ require_relative 'rubocop/cop/style/send_with_literal_method_name'
665
671
  require_relative 'rubocop/cop/style/signal_exception'
666
672
  require_relative 'rubocop/cop/style/single_argument_dig'
667
673
  require_relative 'rubocop/cop/style/single_line_block_params'
@@ -678,6 +684,8 @@ require_relative 'rubocop/cop/style/string_literals_in_interpolation'
678
684
  require_relative 'rubocop/cop/style/string_methods'
679
685
  require_relative 'rubocop/cop/style/strip'
680
686
  require_relative 'rubocop/cop/style/struct_inheritance'
687
+ require_relative 'rubocop/cop/style/super_arguments'
688
+ require_relative 'rubocop/cop/style/super_with_args_parentheses'
681
689
  require_relative 'rubocop/cop/style/swap_values'
682
690
  require_relative 'rubocop/cop/style/symbol_array'
683
691
  require_relative 'rubocop/cop/style/symbol_literal'
metadata CHANGED
@@ -1,31 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.57.1
4
+ version: 1.65.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  - Jonas Arvidsson
9
9
  - Yuji Nakayama
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2023-10-13 00:00:00.000000000 Z
13
+ date: 2024-07-10 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: base64
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - "~>"
20
- - !ruby/object:Gem::Version
21
- version: 0.1.1
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - "~>"
27
- - !ruby/object:Gem::Version
28
- version: 0.1.1
29
15
  - !ruby/object:Gem::Dependency
30
16
  name: json
31
17
  requirement: !ruby/object:Gem::Requirement
@@ -74,14 +60,14 @@ dependencies:
74
60
  requirements:
75
61
  - - ">="
76
62
  - !ruby/object:Gem::Version
77
- version: 3.2.2.4
63
+ version: 3.3.0.2
78
64
  type: :runtime
79
65
  prerelease: false
80
66
  version_requirements: !ruby/object:Gem::Requirement
81
67
  requirements:
82
68
  - - ">="
83
69
  - !ruby/object:Gem::Version
84
- version: 3.2.2.4
70
+ version: 3.3.0.2
85
71
  - !ruby/object:Gem::Dependency
86
72
  name: rainbow
87
73
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +94,7 @@ dependencies:
108
94
  requirements:
109
95
  - - ">="
110
96
  - !ruby/object:Gem::Version
111
- version: '1.8'
97
+ version: '2.4'
112
98
  - - "<"
113
99
  - !ruby/object:Gem::Version
114
100
  version: '3.0'
@@ -118,7 +104,7 @@ dependencies:
118
104
  requirements:
119
105
  - - ">="
120
106
  - !ruby/object:Gem::Version
121
- version: '1.8'
107
+ version: '2.4'
122
108
  - - "<"
123
109
  - !ruby/object:Gem::Version
124
110
  version: '3.0'
@@ -148,7 +134,7 @@ dependencies:
148
134
  requirements:
149
135
  - - ">="
150
136
  - !ruby/object:Gem::Version
151
- version: 1.28.1
137
+ version: 1.31.1
152
138
  - - "<"
153
139
  - !ruby/object:Gem::Version
154
140
  version: '2.0'
@@ -158,7 +144,7 @@ dependencies:
158
144
  requirements:
159
145
  - - ">="
160
146
  - !ruby/object:Gem::Version
161
- version: 1.28.1
147
+ version: 1.31.1
162
148
  - - "<"
163
149
  - !ruby/object:Gem::Version
164
150
  version: '2.0'
@@ -210,6 +196,7 @@ files:
210
196
  - LICENSE.txt
211
197
  - README.md
212
198
  - assets/logo.png
199
+ - assets/output.css.erb
213
200
  - assets/output.html.erb
214
201
  - config/default.yml
215
202
  - config/obsoletion.yml
@@ -283,6 +270,7 @@ files:
283
270
  - lib/rubocop/cop/documentation.rb
284
271
  - lib/rubocop/cop/exclude_limit.rb
285
272
  - lib/rubocop/cop/force.rb
273
+ - lib/rubocop/cop/gemspec/add_runtime_dependency.rb
286
274
  - lib/rubocop/cop/gemspec/dependency_version.rb
287
275
  - lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb
288
276
  - lib/rubocop/cop/gemspec/development_dependencies.rb
@@ -308,6 +296,7 @@ files:
308
296
  - lib/rubocop/cop/internal_affairs/method_name_end_with.rb
309
297
  - lib/rubocop/cop/internal_affairs/method_name_equal.rb
310
298
  - lib/rubocop/cop/internal_affairs/node_destructuring.rb
299
+ - lib/rubocop/cop/internal_affairs/node_first_or_last_argument.rb
311
300
  - lib/rubocop/cop/internal_affairs/node_matcher_directive.rb
312
301
  - lib/rubocop/cop/internal_affairs/node_type_predicate.rb
313
302
  - lib/rubocop/cop/internal_affairs/numblock_handler.rb
@@ -315,6 +304,7 @@ files:
315
304
  - lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb
316
305
  - lib/rubocop/cop/internal_affairs/redundant_context_config_parameter.rb
317
306
  - lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb
307
+ - lib/rubocop/cop/internal_affairs/redundant_expect_offense_arguments.rb
318
308
  - lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb
319
309
  - lib/rubocop/cop/internal_affairs/redundant_location_argument.rb
320
310
  - lib/rubocop/cop/internal_affairs/redundant_message_argument.rb
@@ -480,8 +470,10 @@ files:
480
470
  - lib/rubocop/cop/lint/ineffective_access_modifier.rb
481
471
  - lib/rubocop/cop/lint/inherit_exception.rb
482
472
  - lib/rubocop/cop/lint/interpolation_check.rb
473
+ - lib/rubocop/cop/lint/it_without_arguments_in_block.rb
483
474
  - lib/rubocop/cop/lint/lambda_without_literal_block.rb
484
475
  - lib/rubocop/cop/lint/literal_as_condition.rb
476
+ - lib/rubocop/cop/lint/literal_assignment_in_condition.rb
485
477
  - lib/rubocop/cop/lint/literal_in_interpolation.rb
486
478
  - lib/rubocop/cop/lint/loop.rb
487
479
  - lib/rubocop/cop/lint/missing_cop_enable_directive.rb
@@ -684,6 +676,7 @@ files:
684
676
  - lib/rubocop/cop/style/and_or.rb
685
677
  - lib/rubocop/cop/style/arguments_forwarding.rb
686
678
  - lib/rubocop/cop/style/array_coercion.rb
679
+ - lib/rubocop/cop/style/array_first_last.rb
687
680
  - lib/rubocop/cop/style/array_intersect.rb
688
681
  - lib/rubocop/cop/style/array_join.rb
689
682
  - lib/rubocop/cop/style/ascii_comments.rb
@@ -786,6 +779,7 @@ files:
786
779
  - lib/rubocop/cop/style/line_end_concatenation.rb
787
780
  - lib/rubocop/cop/style/magic_comment_format.rb
788
781
  - lib/rubocop/cop/style/map_compact_with_conditional_block.rb
782
+ - lib/rubocop/cop/style/map_into_array.rb
789
783
  - lib/rubocop/cop/style/map_to_hash.rb
790
784
  - lib/rubocop/cop/style/map_to_set.rb
791
785
  - lib/rubocop/cop/style/method_call_with_args_parentheses.rb
@@ -892,6 +886,7 @@ files:
892
886
  - lib/rubocop/cop/style/self_assignment.rb
893
887
  - lib/rubocop/cop/style/semicolon.rb
894
888
  - lib/rubocop/cop/style/send.rb
889
+ - lib/rubocop/cop/style/send_with_literal_method_name.rb
895
890
  - lib/rubocop/cop/style/signal_exception.rb
896
891
  - lib/rubocop/cop/style/single_argument_dig.rb
897
892
  - lib/rubocop/cop/style/single_line_block_params.rb
@@ -911,6 +906,8 @@ files:
911
906
  - lib/rubocop/cop/style/string_methods.rb
912
907
  - lib/rubocop/cop/style/strip.rb
913
908
  - lib/rubocop/cop/style/struct_inheritance.rb
909
+ - lib/rubocop/cop/style/super_arguments.rb
910
+ - lib/rubocop/cop/style/super_with_args_parentheses.rb
914
911
  - lib/rubocop/cop/style/swap_values.rb
915
912
  - lib/rubocop/cop/style/symbol_array.rb
916
913
  - lib/rubocop/cop/style/symbol_literal.rb
@@ -973,7 +970,7 @@ files:
973
970
  - lib/rubocop/formatter/file_list_formatter.rb
974
971
  - lib/rubocop/formatter/formatter_set.rb
975
972
  - lib/rubocop/formatter/fuubar_style_formatter.rb
976
- - lib/rubocop/formatter/git_hub_actions_formatter.rb
973
+ - lib/rubocop/formatter/github_actions_formatter.rb
977
974
  - lib/rubocop/formatter/html_formatter.rb
978
975
  - lib/rubocop/formatter/json_formatter.rb
979
976
  - lib/rubocop/formatter/junit_formatter.rb
@@ -987,6 +984,7 @@ files:
987
984
  - lib/rubocop/formatter/text_util.rb
988
985
  - lib/rubocop/formatter/worst_offenders_formatter.rb
989
986
  - lib/rubocop/lockfile.rb
987
+ - lib/rubocop/lsp.rb
990
988
  - lib/rubocop/lsp/logger.rb
991
989
  - lib/rubocop/lsp/routes.rb
992
990
  - lib/rubocop/lsp/runtime.rb
@@ -1037,12 +1035,12 @@ licenses:
1037
1035
  - MIT
1038
1036
  metadata:
1039
1037
  homepage_uri: https://rubocop.org/
1040
- changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
1038
+ changelog_uri: https://github.com/rubocop/rubocop/releases/tag/v1.65.0
1041
1039
  source_code_uri: https://github.com/rubocop/rubocop/
1042
- documentation_uri: https://docs.rubocop.org/rubocop/1.57/
1040
+ documentation_uri: https://docs.rubocop.org/rubocop/1.65/
1043
1041
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
1044
1042
  rubygems_mfa_required: 'true'
1045
- post_install_message:
1043
+ post_install_message:
1046
1044
  rdoc_options: []
1047
1045
  require_paths:
1048
1046
  - lib
@@ -1057,8 +1055,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1057
1055
  - !ruby/object:Gem::Version
1058
1056
  version: '0'
1059
1057
  requirements: []
1060
- rubygems_version: 3.3.7
1061
- signing_key:
1058
+ rubygems_version: 3.4.22
1059
+ signing_key:
1062
1060
  specification_version: 4
1063
1061
  summary: Automatic Ruby code style checking tool.
1064
1062
  test_files: []