rubocop 1.46.0 → 1.52.1

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 (269) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/config/default.yml +83 -11
  4. data/lib/rubocop/cli/command/auto_generate_config.rb +7 -0
  5. data/lib/rubocop/cli/command/execute_runner.rb +7 -2
  6. data/lib/rubocop/cli.rb +6 -6
  7. data/lib/rubocop/comment_config.rb +2 -0
  8. data/lib/rubocop/config.rb +7 -3
  9. data/lib/rubocop/config_loader.rb +8 -8
  10. data/lib/rubocop/config_obsoletion.rb +2 -2
  11. data/lib/rubocop/cop/autocorrect_logic.rb +29 -13
  12. data/lib/rubocop/cop/base.rb +6 -2
  13. data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
  14. data/lib/rubocop/cop/cop.rb +2 -2
  15. data/lib/rubocop/cop/corrector.rb +1 -1
  16. data/lib/rubocop/cop/correctors/alignment_corrector.rb +3 -3
  17. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +3 -3
  18. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +3 -3
  19. data/lib/rubocop/cop/correctors/line_break_corrector.rb +1 -1
  20. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +2 -2
  21. data/lib/rubocop/cop/correctors/ordered_gem_corrector.rb +1 -1
  22. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +1 -1
  23. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +2 -2
  24. data/lib/rubocop/cop/gemspec/dependency_version.rb +1 -1
  25. data/lib/rubocop/cop/gemspec/deprecated_attribute_assignment.rb +1 -1
  26. data/lib/rubocop/cop/gemspec/development_dependencies.rb +1 -1
  27. data/lib/rubocop/cop/internal_affairs/cop_description.rb +37 -13
  28. data/lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb +3 -3
  29. data/lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb +1 -1
  30. data/lib/rubocop/cop/internal_affairs/location_expression.rb +37 -0
  31. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +3 -3
  32. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -1
  33. data/lib/rubocop/cop/internal_affairs/processed_source_buffer_name.rb +1 -1
  34. data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -1
  35. data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +1 -1
  36. data/lib/rubocop/cop/internal_affairs/redundant_source_range.rb +66 -0
  37. data/lib/rubocop/cop/internal_affairs.rb +2 -0
  38. data/lib/rubocop/cop/layout/block_end_newline.rb +7 -21
  39. data/lib/rubocop/cop/layout/class_structure.rb +6 -3
  40. data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +1 -2
  41. data/lib/rubocop/cop/layout/empty_comment.rb +3 -3
  42. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +1 -1
  43. data/lib/rubocop/cop/layout/empty_lines.rb +1 -1
  44. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +2 -0
  45. data/lib/rubocop/cop/layout/end_alignment.rb +5 -1
  46. data/lib/rubocop/cop/layout/extra_spacing.rb +6 -1
  47. data/lib/rubocop/cop/layout/first_argument_indentation.rb +7 -2
  48. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +25 -34
  49. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +7 -19
  50. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +42 -52
  51. data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +38 -55
  52. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +4 -4
  53. data/lib/rubocop/cop/layout/heredoc_indentation.rb +2 -2
  54. data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
  55. data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
  56. data/lib/rubocop/cop/layout/line_continuation_leading_space.rb +1 -3
  57. data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +8 -27
  58. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +7 -26
  59. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +4 -21
  60. data/lib/rubocop/cop/layout/multiline_method_parameter_line_breaks.rb +6 -30
  61. data/lib/rubocop/cop/layout/redundant_line_break.rb +6 -7
  62. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +2 -2
  63. data/lib/rubocop/cop/layout/space_before_first_arg.rb +1 -1
  64. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +2 -2
  65. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +3 -1
  66. data/lib/rubocop/cop/layout/space_inside_parens.rb +2 -2
  67. data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +1 -1
  68. data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
  69. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +13 -1
  70. data/lib/rubocop/cop/lint/constant_resolution.rb +1 -1
  71. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +4 -4
  72. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +1 -1
  73. data/lib/rubocop/cop/lint/duplicate_match_pattern.rb +122 -0
  74. data/lib/rubocop/cop/lint/duplicate_methods.rb +2 -2
  75. data/lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb +1 -3
  76. data/lib/rubocop/cop/lint/else_layout.rb +1 -1
  77. data/lib/rubocop/cop/lint/empty_block.rb +1 -1
  78. data/lib/rubocop/cop/lint/empty_conditional_body.rb +4 -2
  79. data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
  80. data/lib/rubocop/cop/lint/erb_new_arguments.rb +3 -4
  81. data/lib/rubocop/cop/lint/identity_comparison.rb +0 -1
  82. data/lib/rubocop/cop/lint/incompatible_io_select_with_fiber_scheduler.rb +5 -3
  83. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
  84. data/lib/rubocop/cop/lint/inherit_exception.rb +9 -0
  85. data/lib/rubocop/cop/lint/lambda_without_literal_block.rb +1 -1
  86. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +46 -4
  87. data/lib/rubocop/cop/lint/missing_super.rb +34 -2
  88. data/lib/rubocop/cop/lint/nested_method_definition.rb +2 -2
  89. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +2 -2
  90. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +2 -0
  91. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +0 -1
  92. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +2 -2
  93. data/lib/rubocop/cop/lint/percent_string_array.rb +1 -1
  94. data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
  95. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +4 -4
  96. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +5 -5
  97. data/lib/rubocop/cop/lint/redundant_require_statement.rb +1 -1
  98. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -1
  99. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +35 -15
  100. data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -1
  101. data/lib/rubocop/cop/lint/redundant_with_object.rb +1 -1
  102. data/lib/rubocop/cop/lint/rescue_type.rb +3 -3
  103. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +1 -1
  104. data/lib/rubocop/cop/lint/script_permission.rb +1 -1
  105. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -2
  106. data/lib/rubocop/cop/lint/shadowed_exception.rb +6 -12
  107. data/lib/rubocop/cop/lint/syntax.rb +4 -0
  108. data/lib/rubocop/cop/lint/to_enum_arguments.rb +7 -1
  109. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +23 -9
  110. data/lib/rubocop/cop/lint/unreachable_loop.rb +3 -3
  111. data/lib/rubocop/cop/lint/useless_access_modifier.rb +9 -1
  112. data/lib/rubocop/cop/lint/useless_assignment.rb +59 -1
  113. data/lib/rubocop/cop/lint/useless_method_definition.rb +10 -2
  114. data/lib/rubocop/cop/lint/useless_rescue.rb +4 -1
  115. data/lib/rubocop/cop/lint/useless_times.rb +1 -1
  116. data/lib/rubocop/cop/lint/void.rb +69 -9
  117. data/lib/rubocop/cop/metrics/block_nesting.rb +1 -1
  118. data/lib/rubocop/cop/metrics/class_length.rb +1 -0
  119. data/lib/rubocop/cop/metrics/collection_literal_length.rb +76 -0
  120. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1 -2
  121. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +3 -3
  122. data/lib/rubocop/cop/migration/department_name.rb +1 -1
  123. data/lib/rubocop/cop/mixin/allowed_receivers.rb +34 -0
  124. data/lib/rubocop/cop/mixin/annotation_comment.rb +1 -1
  125. data/lib/rubocop/cop/mixin/code_length.rb +1 -1
  126. data/lib/rubocop/cop/mixin/comments_help.rb +9 -5
  127. data/lib/rubocop/cop/mixin/documentation_comment.rb +1 -1
  128. data/lib/rubocop/cop/mixin/hash_alignment_styles.rb +1 -1
  129. data/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb +4 -2
  130. data/lib/rubocop/cop/mixin/hash_transform_method.rb +3 -3
  131. data/lib/rubocop/cop/mixin/min_branches_count.rb +40 -0
  132. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +1 -1
  133. data/lib/rubocop/cop/mixin/range_help.rb +1 -6
  134. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
  135. data/lib/rubocop/cop/mixin/statement_modifier.rb +3 -3
  136. data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
  137. data/lib/rubocop/cop/naming/ascii_identifiers.rb +1 -1
  138. data/lib/rubocop/cop/naming/constant_name.rb +1 -1
  139. data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +1 -1
  140. data/lib/rubocop/cop/naming/inclusive_language.rb +23 -4
  141. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +22 -7
  142. data/lib/rubocop/cop/naming/method_name.rb +3 -3
  143. data/lib/rubocop/cop/naming/predicate_name.rb +1 -1
  144. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +12 -4
  145. data/lib/rubocop/cop/naming/variable_name.rb +6 -1
  146. data/lib/rubocop/cop/registry.rb +3 -1
  147. data/lib/rubocop/cop/style/accessor_grouping.rb +32 -7
  148. data/lib/rubocop/cop/style/arguments_forwarding.rb +3 -3
  149. data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
  150. data/lib/rubocop/cop/style/attr.rb +11 -1
  151. data/lib/rubocop/cop/style/begin_block.rb +1 -2
  152. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +1 -1
  153. data/lib/rubocop/cop/style/block_comments.rb +1 -1
  154. data/lib/rubocop/cop/style/block_delimiters.rb +11 -2
  155. data/lib/rubocop/cop/style/case_like_if.rb +20 -3
  156. data/lib/rubocop/cop/style/class_and_module_children.rb +2 -2
  157. data/lib/rubocop/cop/style/class_equality_comparison.rb +51 -40
  158. data/lib/rubocop/cop/style/collection_compact.rb +20 -7
  159. data/lib/rubocop/cop/style/colon_method_call.rb +2 -2
  160. data/lib/rubocop/cop/style/combinable_loops.rb +26 -6
  161. data/lib/rubocop/cop/style/comment_annotation.rb +1 -1
  162. data/lib/rubocop/cop/style/commented_keyword.rb +2 -2
  163. data/lib/rubocop/cop/style/concat_array_literals.rb +10 -2
  164. data/lib/rubocop/cop/style/conditional_assignment.rb +8 -8
  165. data/lib/rubocop/cop/style/copyright.rb +6 -3
  166. data/lib/rubocop/cop/style/data_inheritance.rb +75 -0
  167. data/lib/rubocop/cop/style/dir.rb +1 -1
  168. data/lib/rubocop/cop/style/dir_empty.rb +54 -0
  169. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +2 -2
  170. data/lib/rubocop/cop/style/document_dynamic_eval_definition.rb +2 -2
  171. data/lib/rubocop/cop/style/documentation.rb +11 -5
  172. data/lib/rubocop/cop/style/double_negation.rb +2 -2
  173. data/lib/rubocop/cop/style/each_with_object.rb +1 -1
  174. data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
  175. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
  176. data/lib/rubocop/cop/style/eval_with_location.rb +8 -8
  177. data/lib/rubocop/cop/style/exact_regexp_match.rb +68 -0
  178. data/lib/rubocop/cop/style/explicit_block_argument.rb +1 -1
  179. data/lib/rubocop/cop/style/file_empty.rb +71 -0
  180. data/lib/rubocop/cop/style/file_read.rb +3 -3
  181. data/lib/rubocop/cop/style/file_write.rb +1 -1
  182. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
  183. data/lib/rubocop/cop/style/guard_clause.rb +3 -1
  184. data/lib/rubocop/cop/style/hash_each_methods.rb +1 -22
  185. data/lib/rubocop/cop/style/hash_except.rb +23 -12
  186. data/lib/rubocop/cop/style/hash_like_case.rb +3 -9
  187. data/lib/rubocop/cop/style/hash_syntax.rb +5 -2
  188. data/lib/rubocop/cop/style/hash_transform_keys.rb +2 -2
  189. data/lib/rubocop/cop/style/hash_transform_values.rb +2 -2
  190. data/lib/rubocop/cop/style/if_inside_else.rb +6 -0
  191. data/lib/rubocop/cop/style/if_unless_modifier.rb +111 -15
  192. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +2 -0
  193. data/lib/rubocop/cop/style/inverse_methods.rb +5 -5
  194. data/lib/rubocop/cop/style/invertible_unless_condition.rb +9 -5
  195. data/lib/rubocop/cop/style/map_compact_with_conditional_block.rb +2 -2
  196. data/lib/rubocop/cop/style/map_to_hash.rb +4 -1
  197. data/lib/rubocop/cop/style/map_to_set.rb +4 -1
  198. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +4 -9
  199. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +44 -37
  200. data/lib/rubocop/cop/style/min_max.rb +3 -3
  201. data/lib/rubocop/cop/style/mixin_grouping.rb +4 -4
  202. data/lib/rubocop/cop/style/multiline_method_signature.rb +7 -4
  203. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
  204. data/lib/rubocop/cop/style/multiple_comparison.rb +14 -0
  205. data/lib/rubocop/cop/style/negated_if_else_condition.rb +12 -7
  206. data/lib/rubocop/cop/style/nil_lambda.rb +2 -2
  207. data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
  208. data/lib/rubocop/cop/style/parallel_assignment.rb +26 -18
  209. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -3
  210. data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
  211. data/lib/rubocop/cop/style/redundant_array_constructor.rb +77 -0
  212. data/lib/rubocop/cop/style/redundant_condition.rb +2 -2
  213. data/lib/rubocop/cop/style/redundant_double_splat_hash_braces.rb +2 -2
  214. data/lib/rubocop/cop/style/redundant_fetch_block.rb +6 -4
  215. data/lib/rubocop/cop/style/redundant_filter_chain.rb +101 -0
  216. data/lib/rubocop/cop/style/redundant_interpolation.rb +2 -2
  217. data/lib/rubocop/cop/style/redundant_line_continuation.rb +183 -0
  218. data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -1
  219. data/lib/rubocop/cop/style/redundant_percent_q.rb +1 -1
  220. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +2 -2
  221. data/lib/rubocop/cop/style/redundant_regexp_constructor.rb +46 -0
  222. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +11 -4
  223. data/lib/rubocop/cop/style/redundant_sort.rb +3 -3
  224. data/lib/rubocop/cop/style/redundant_string_escape.rb +3 -4
  225. data/lib/rubocop/cop/style/regexp_literal.rb +11 -2
  226. data/lib/rubocop/cop/style/require_order.rb +12 -8
  227. data/lib/rubocop/cop/style/rescue_modifier.rb +1 -3
  228. data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -2
  229. data/lib/rubocop/cop/style/safe_navigation.rb +2 -2
  230. data/lib/rubocop/cop/style/select_by_regexp.rb +15 -5
  231. data/lib/rubocop/cop/style/semicolon.rb +12 -1
  232. data/lib/rubocop/cop/style/single_line_methods.rb +1 -1
  233. data/lib/rubocop/cop/style/sole_nested_conditional.rb +6 -4
  234. data/lib/rubocop/cop/style/special_global_vars.rb +3 -4
  235. data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
  236. data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
  237. data/lib/rubocop/cop/style/trailing_body_on_class.rb +1 -0
  238. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +1 -1
  239. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  240. data/lib/rubocop/cop/style/unless_logical_operators.rb +1 -0
  241. data/lib/rubocop/cop/style/unpack_first.rb +3 -3
  242. data/lib/rubocop/cop/style/yoda_condition.rb +1 -1
  243. data/lib/rubocop/cop/style/zero_length_predicate.rb +9 -5
  244. data/lib/rubocop/cop/team.rb +2 -2
  245. data/lib/rubocop/cop/util.rb +1 -1
  246. data/lib/rubocop/cop/variable_force/assignment.rb +33 -1
  247. data/lib/rubocop/cop/variable_force/variable.rb +5 -3
  248. data/lib/rubocop/cop/variable_force/variable_table.rb +2 -2
  249. data/lib/rubocop/cop/variable_force.rb +1 -0
  250. data/lib/rubocop/cops_documentation_generator.rb +10 -3
  251. data/lib/rubocop/directive_comment.rb +3 -3
  252. data/lib/rubocop/ext/comment.rb +18 -0
  253. data/lib/rubocop/ext/regexp_node.rb +1 -1
  254. data/lib/rubocop/ext/regexp_parser.rb +1 -1
  255. data/lib/rubocop/formatter/junit_formatter.rb +4 -1
  256. data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
  257. data/lib/rubocop/options.rb +4 -1
  258. data/lib/rubocop/result_cache.rb +2 -2
  259. data/lib/rubocop/rspec/cop_helper.rb +1 -1
  260. data/lib/rubocop/rspec/support.rb +1 -0
  261. data/lib/rubocop/server/cache.rb +1 -1
  262. data/lib/rubocop/server/client_command/exec.rb +2 -1
  263. data/lib/rubocop/server/core.rb +1 -1
  264. data/lib/rubocop/server/helper.rb +1 -1
  265. data/lib/rubocop/server/server_command/exec.rb +1 -1
  266. data/lib/rubocop/target_ruby.rb +3 -2
  267. data/lib/rubocop/version.rb +10 -6
  268. data/lib/rubocop.rb +13 -0
  269. metadata +23 -8
@@ -62,7 +62,10 @@ module RuboCop
62
62
  end
63
63
 
64
64
  def classname_attribute_value(file)
65
- file.gsub(/\.rb\Z/, '').gsub("#{Dir.pwd}/", '').tr('/', '.')
65
+ @classname_attribute_value_cache ||= Hash.new do |hash, key|
66
+ hash[key] = key.gsub(/\.rb\Z/, '').gsub("#{Dir.pwd}/", '').tr('/', '.')
67
+ end
68
+ @classname_attribute_value_cache[file]
66
69
  end
67
70
 
68
71
  def finished(_inspected_files)
@@ -61,7 +61,7 @@ module RuboCop
61
61
  correctable_count,
62
62
  rainbow,
63
63
  # :safe_autocorrect is a derived option based on several command-line
64
- # arguments - see Rubocop::Options#add_autocorrection_options
64
+ # arguments - see RuboCop::Options#add_autocorrection_options
65
65
  safe_autocorrect: @options[:safe_autocorrect])
66
66
 
67
67
  output.puts
@@ -182,7 +182,10 @@ module RuboCop
182
182
  raise OptionArgumentError, message
183
183
  end
184
184
 
185
- @options[:"#{option}"] = list.empty? ? [''] : list.split(',')
185
+ cop_names = list.empty? ? [''] : list.split(',')
186
+ cop_names.unshift('Lint/Syntax') if option == 'only' && !cop_names.include?('Lint/Syntax')
187
+
188
+ @options[:"#{option}"] = cop_names
186
189
  end
187
190
  end
188
191
 
@@ -83,10 +83,10 @@ module RuboCop
83
83
  config_store.for_pwd.for_all_cops['AllowSymlinksInCacheRootDirectory']
84
84
  end
85
85
 
86
- attr :path
86
+ attr_reader :path
87
87
 
88
88
  def initialize(file, team, options, config_store, cache_root = nil)
89
- cache_root ||= options[:cache_root]
89
+ cache_root ||= File.join(options[:cache_root], 'rubocop_cache') if options[:cache_root]
90
90
  cache_root ||= ResultCache.cache_root(config_store)
91
91
  @allow_symlinks_in_cache_location =
92
92
  ResultCache.allow_symlinks_in_cache_location?(config_store)
@@ -6,7 +6,7 @@ require 'tempfile'
6
6
  module CopHelper
7
7
  extend RSpec::SharedContext
8
8
 
9
- let(:ruby_version) { 2.6 }
9
+ let(:ruby_version) { RuboCop::TargetRuby::DEFAULT_VERSION }
10
10
  let(:rails_version) { false }
11
11
 
12
12
  def inspect_source(source, file = nil)
@@ -25,4 +25,5 @@ RSpec.configure do |config|
25
25
  config.include_context 'ruby 3.0', :ruby30
26
26
  config.include_context 'ruby 3.1', :ruby31
27
27
  config.include_context 'ruby 3.2', :ruby32
28
+ config.include_context 'ruby 3.3', :ruby33
28
29
  end
@@ -116,7 +116,7 @@ module RuboCop
116
116
 
117
117
  def pid_running?
118
118
  Process.kill(0, pid_path.read.to_i) == 1
119
- rescue Errno::ESRCH, Errno::ENOENT
119
+ rescue Errno::ESRCH, Errno::ENOENT, Errno::EACCES
120
120
  false
121
121
  end
122
122
 
@@ -18,10 +18,11 @@ module RuboCop
18
18
  def run
19
19
  ensure_server!
20
20
  Cache.status_path.delete if Cache.status_path.file?
21
+ read_stdin = ARGV.include?('-s') || ARGV.include?('--stdin')
21
22
  send_request(
22
23
  command: 'exec',
23
24
  args: ARGV.dup,
24
- body: $stdin.tty? ? '' : $stdin.read
25
+ body: read_stdin ? $stdin.read : ''
25
26
  )
26
27
  warn stderr unless stderr.empty?
27
28
  status
@@ -100,7 +100,7 @@ module RuboCop
100
100
 
101
101
  def use_json_format?
102
102
  return true if ARGV.include?('--format=json') || ARGV.include?('--format=j')
103
- return false unless (index = ARGV.index('--format'))
103
+ return false unless (index = ARGV.index('--format') || ARGV.index('-f'))
104
104
 
105
105
  format = ARGV[index + 1]
106
106
 
@@ -11,7 +11,7 @@
11
11
  #
12
12
  module RuboCop
13
13
  module Server
14
- # This module has a helper memthod for `RuboCop::Server::SocketReader`.
14
+ # This module has a helper method for `RuboCop::Server::SocketReader`.
15
15
  # @api private
16
16
  module Helper
17
17
  def self.redirect(stdin: $stdin, stdout: $stdout, stderr: $stderr, &_block)
@@ -21,7 +21,7 @@ module RuboCop
21
21
  # We must pass the --color option to preserve this behavior.
22
22
  @args.unshift('--color') unless %w[--color --no-color].any? { |f| @args.include?(f) }
23
23
  status = RuboCop::CLI.new.run(@args)
24
- # This status file is read by `rubocop --server` (`RuboCop::Server::Clientcommand::Exec`).
24
+ # This status file is read by `rubocop --server` (`RuboCop::Server::ClientCommand::Exec`).
25
25
  # so that they use the correct exit code.
26
26
  # Status is 1 when there are any issues, and 0 otherwise.
27
27
  Cache.write_status_file(status)
@@ -5,7 +5,7 @@ module RuboCop
5
5
  # @api private
6
6
  class TargetRuby
7
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
8
- DEFAULT_VERSION = 2.6
8
+ DEFAULT_VERSION = 2.7
9
9
 
10
10
  OBSOLETE_RUBIES = {
11
11
  1.9 => '0.41',
@@ -14,7 +14,8 @@ module RuboCop
14
14
  2.2 => '0.68',
15
15
  2.3 => '0.81',
16
16
  2.4 => '1.12',
17
- 2.5 => '1.28'
17
+ 2.5 => '1.28',
18
+ 2.6 => '1.50'
18
19
  }.freeze
19
20
  private_constant :KNOWN_RUBIES, :OBSOLETE_RUBIES
20
21
 
@@ -3,15 +3,19 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '1.46.0'
6
+ STRING = '1.52.1'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<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
- CANONICAL_FEATURE_NAMES = { 'Rspec' => 'RSpec', 'Graphql' => 'GraphQL', 'Md' => 'Markdown',
13
- 'Thread_safety' => 'ThreadSafety' }.freeze
14
- EXTENSION_PATH_NAMES = { 'rubocop-md' => 'markdown' }.freeze
12
+ CANONICAL_FEATURE_NAMES = {
13
+ 'Rspec' => 'RSpec', 'Graphql' => 'GraphQL', 'Md' => 'Markdown', 'Factory_bot' => 'FactoryBot',
14
+ 'Thread_safety' => 'ThreadSafety'
15
+ }.freeze
16
+ EXTENSION_PATH_NAMES = {
17
+ 'rubocop-md' => 'markdown', 'rubocop-factory_bot' => 'factory_bot'
18
+ }.freeze
15
19
 
16
20
  # @api private
17
21
  def self.version(debug: false, env: nil)
@@ -43,7 +47,7 @@ module RuboCop
43
47
  env.config_store.unvalidated.for_pwd.loaded_features.sort
44
48
  end
45
49
 
46
- features.map do |loaded_feature|
50
+ features.filter_map do |loaded_feature|
47
51
  next unless (match = loaded_feature.match(/rubocop-(?<feature>.*)/))
48
52
 
49
53
  # Get the expected name of the folder containing the extension code.
@@ -61,7 +65,7 @@ module RuboCop
61
65
  next unless (feature_version = feature_version(feature))
62
66
 
63
67
  " - #{loaded_feature} #{feature_version}"
64
- end.compact
68
+ end
65
69
  end
66
70
 
67
71
  # Returns feature version in one of two ways:
data/lib/rubocop.rb CHANGED
@@ -14,6 +14,7 @@ require_relative 'rubocop/version'
14
14
  require 'rubocop-ast'
15
15
 
16
16
  require_relative 'rubocop/ast_aliases'
17
+ require_relative 'rubocop/ext/comment'
17
18
  require_relative 'rubocop/ext/range'
18
19
  require_relative 'rubocop/ext/regexp_node'
19
20
  require_relative 'rubocop/ext/regexp_parser'
@@ -68,6 +69,7 @@ require_relative 'rubocop/cop/mixin/alignment'
68
69
  require_relative 'rubocop/cop/mixin/allowed_identifiers'
69
70
  require_relative 'rubocop/cop/mixin/allowed_methods'
70
71
  require_relative 'rubocop/cop/mixin/allowed_pattern'
72
+ require_relative 'rubocop/cop/mixin/allowed_receivers'
71
73
  require_relative 'rubocop/cop/mixin/auto_corrector' # rubocop:todo Naming/InclusiveLanguage
72
74
  require_relative 'rubocop/cop/mixin/check_assignment'
73
75
  require_relative 'rubocop/cop/mixin/check_line_breakable'
@@ -101,6 +103,7 @@ require_relative 'rubocop/cop/mixin/hash_shorthand_syntax'
101
103
  require_relative 'rubocop/cop/mixin/method_complexity'
102
104
  require_relative 'rubocop/cop/mixin/method_preference'
103
105
  require_relative 'rubocop/cop/mixin/min_body_length'
106
+ require_relative 'rubocop/cop/mixin/min_branches_count'
104
107
  require_relative 'rubocop/cop/mixin/multiline_element_indentation'
105
108
  require_relative 'rubocop/cop/mixin/multiline_element_line_breaks'
106
109
  require_relative 'rubocop/cop/mixin/multiline_expression_indentation'
@@ -297,6 +300,7 @@ require_relative 'rubocop/cop/lint/duplicate_case_condition'
297
300
  require_relative 'rubocop/cop/lint/duplicate_elsif_condition'
298
301
  require_relative 'rubocop/cop/lint/duplicate_hash_key'
299
302
  require_relative 'rubocop/cop/lint/duplicate_magic_comment'
303
+ require_relative 'rubocop/cop/lint/duplicate_match_pattern'
300
304
  require_relative 'rubocop/cop/lint/duplicate_methods'
301
305
  require_relative 'rubocop/cop/lint/duplicate_regexp_character_class_element'
302
306
  require_relative 'rubocop/cop/lint/duplicate_require'
@@ -415,6 +419,7 @@ require_relative 'rubocop/cop/metrics/abc_size'
415
419
  require_relative 'rubocop/cop/metrics/block_length'
416
420
  require_relative 'rubocop/cop/metrics/block_nesting'
417
421
  require_relative 'rubocop/cop/metrics/class_length'
422
+ require_relative 'rubocop/cop/metrics/collection_literal_length'
418
423
  require_relative 'rubocop/cop/metrics/method_length'
419
424
  require_relative 'rubocop/cop/metrics/module_length'
420
425
  require_relative 'rubocop/cop/metrics/parameter_lists'
@@ -477,9 +482,11 @@ require_relative 'rubocop/cop/style/concat_array_literals'
477
482
  require_relative 'rubocop/cop/style/conditional_assignment'
478
483
  require_relative 'rubocop/cop/style/constant_visibility'
479
484
  require_relative 'rubocop/cop/style/copyright'
485
+ require_relative 'rubocop/cop/style/data_inheritance'
480
486
  require_relative 'rubocop/cop/style/date_time'
481
487
  require_relative 'rubocop/cop/style/def_with_parentheses'
482
488
  require_relative 'rubocop/cop/style/dir'
489
+ require_relative 'rubocop/cop/style/dir_empty'
483
490
  require_relative 'rubocop/cop/style/disable_cops_within_source_code_directive'
484
491
  require_relative 'rubocop/cop/style/documentation_method'
485
492
  require_relative 'rubocop/cop/style/documentation'
@@ -501,10 +508,12 @@ require_relative 'rubocop/cop/style/end_block'
501
508
  require_relative 'rubocop/cop/style/env_home'
502
509
  require_relative 'rubocop/cop/style/eval_with_location'
503
510
  require_relative 'rubocop/cop/style/even_odd'
511
+ require_relative 'rubocop/cop/style/exact_regexp_match'
504
512
  require_relative 'rubocop/cop/style/expand_path_arguments'
505
513
  require_relative 'rubocop/cop/style/explicit_block_argument'
506
514
  require_relative 'rubocop/cop/style/exponential_notation'
507
515
  require_relative 'rubocop/cop/style/fetch_env_var'
516
+ require_relative 'rubocop/cop/style/file_empty'
508
517
  require_relative 'rubocop/cop/style/file_read'
509
518
  require_relative 'rubocop/cop/style/file_write'
510
519
  require_relative 'rubocop/cop/style/float_division'
@@ -550,14 +559,18 @@ require_relative 'rubocop/cop/style/multiline_in_pattern_then'
550
559
  require_relative 'rubocop/cop/style/numbered_parameters'
551
560
  require_relative 'rubocop/cop/style/open_struct_use'
552
561
  require_relative 'rubocop/cop/style/operator_method_call'
562
+ require_relative 'rubocop/cop/style/redundant_array_constructor'
553
563
  require_relative 'rubocop/cop/style/redundant_assignment'
554
564
  require_relative 'rubocop/cop/style/redundant_constant_base'
555
565
  require_relative 'rubocop/cop/style/redundant_double_splat_hash_braces'
556
566
  require_relative 'rubocop/cop/style/redundant_each'
557
567
  require_relative 'rubocop/cop/style/redundant_fetch_block'
558
568
  require_relative 'rubocop/cop/style/redundant_file_extension_in_require'
569
+ require_relative 'rubocop/cop/style/redundant_filter_chain'
559
570
  require_relative 'rubocop/cop/style/redundant_heredoc_delimiter_quotes'
560
571
  require_relative 'rubocop/cop/style/redundant_initialize'
572
+ require_relative 'rubocop/cop/style/redundant_line_continuation'
573
+ require_relative 'rubocop/cop/style/redundant_regexp_constructor'
561
574
  require_relative 'rubocop/cop/style/redundant_self_assignment'
562
575
  require_relative 'rubocop/cop/style/redundant_self_assignment_branch'
563
576
  require_relative 'rubocop/cop/style/require_order'
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.46.0
4
+ version: 1.52.1
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: 2023-02-22 00:00:00.000000000 Z
13
+ date: 2023-06-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -46,14 +46,14 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 3.2.0.0
49
+ version: 3.2.2.3
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 3.2.0.0
56
+ version: 3.2.2.3
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rainbow
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +120,7 @@ dependencies:
120
120
  requirements:
121
121
  - - ">="
122
122
  - !ruby/object:Gem::Version
123
- version: 1.26.0
123
+ version: 1.28.0
124
124
  - - "<"
125
125
  - !ruby/object:Gem::Version
126
126
  version: '2.0'
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: 1.26.0
133
+ version: 1.28.0
134
134
  - - "<"
135
135
  - !ruby/object:Gem::Version
136
136
  version: '2.0'
@@ -273,6 +273,7 @@ files:
273
273
  - lib/rubocop/cop/internal_affairs/example_heredoc_delimiter.rb
274
274
  - lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb
275
275
  - lib/rubocop/cop/internal_affairs/lambda_or_proc.rb
276
+ - lib/rubocop/cop/internal_affairs/location_expression.rb
276
277
  - lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb
277
278
  - lib/rubocop/cop/internal_affairs/method_name_end_with.rb
278
279
  - lib/rubocop/cop/internal_affairs/method_name_equal.rb
@@ -288,6 +289,7 @@ files:
288
289
  - lib/rubocop/cop/internal_affairs/redundant_location_argument.rb
289
290
  - lib/rubocop/cop/internal_affairs/redundant_message_argument.rb
290
291
  - lib/rubocop/cop/internal_affairs/redundant_method_dispatch_node.rb
292
+ - lib/rubocop/cop/internal_affairs/redundant_source_range.rb
291
293
  - lib/rubocop/cop/internal_affairs/single_line_comparison.rb
292
294
  - lib/rubocop/cop/internal_affairs/style_detected_api_use.rb
293
295
  - lib/rubocop/cop/internal_affairs/undefined_config.rb
@@ -418,6 +420,7 @@ files:
418
420
  - lib/rubocop/cop/lint/duplicate_elsif_condition.rb
419
421
  - lib/rubocop/cop/lint/duplicate_hash_key.rb
420
422
  - lib/rubocop/cop/lint/duplicate_magic_comment.rb
423
+ - lib/rubocop/cop/lint/duplicate_match_pattern.rb
421
424
  - lib/rubocop/cop/lint/duplicate_methods.rb
422
425
  - lib/rubocop/cop/lint/duplicate_regexp_character_class_element.rb
423
426
  - lib/rubocop/cop/lint/duplicate_require.rb
@@ -531,6 +534,7 @@ files:
531
534
  - lib/rubocop/cop/metrics/block_length.rb
532
535
  - lib/rubocop/cop/metrics/block_nesting.rb
533
536
  - lib/rubocop/cop/metrics/class_length.rb
537
+ - lib/rubocop/cop/metrics/collection_literal_length.rb
534
538
  - lib/rubocop/cop/metrics/cyclomatic_complexity.rb
535
539
  - lib/rubocop/cop/metrics/method_length.rb
536
540
  - lib/rubocop/cop/metrics/module_length.rb
@@ -546,6 +550,7 @@ files:
546
550
  - lib/rubocop/cop/mixin/allowed_identifiers.rb
547
551
  - lib/rubocop/cop/mixin/allowed_methods.rb
548
552
  - lib/rubocop/cop/mixin/allowed_pattern.rb
553
+ - lib/rubocop/cop/mixin/allowed_receivers.rb
549
554
  - lib/rubocop/cop/mixin/annotation_comment.rb
550
555
  - lib/rubocop/cop/mixin/array_min_size.rb
551
556
  - lib/rubocop/cop/mixin/array_syntax.rb
@@ -581,6 +586,7 @@ files:
581
586
  - lib/rubocop/cop/mixin/method_complexity.rb
582
587
  - lib/rubocop/cop/mixin/method_preference.rb
583
588
  - lib/rubocop/cop/mixin/min_body_length.rb
589
+ - lib/rubocop/cop/mixin/min_branches_count.rb
584
590
  - lib/rubocop/cop/mixin/multiline_element_indentation.rb
585
591
  - lib/rubocop/cop/mixin/multiline_element_line_breaks.rb
586
592
  - lib/rubocop/cop/mixin/multiline_expression_indentation.rb
@@ -679,9 +685,11 @@ files:
679
685
  - lib/rubocop/cop/style/conditional_assignment.rb
680
686
  - lib/rubocop/cop/style/constant_visibility.rb
681
687
  - lib/rubocop/cop/style/copyright.rb
688
+ - lib/rubocop/cop/style/data_inheritance.rb
682
689
  - lib/rubocop/cop/style/date_time.rb
683
690
  - lib/rubocop/cop/style/def_with_parentheses.rb
684
691
  - lib/rubocop/cop/style/dir.rb
692
+ - lib/rubocop/cop/style/dir_empty.rb
685
693
  - lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb
686
694
  - lib/rubocop/cop/style/document_dynamic_eval_definition.rb
687
695
  - lib/rubocop/cop/style/documentation.rb
@@ -703,10 +711,12 @@ files:
703
711
  - lib/rubocop/cop/style/env_home.rb
704
712
  - lib/rubocop/cop/style/eval_with_location.rb
705
713
  - lib/rubocop/cop/style/even_odd.rb
714
+ - lib/rubocop/cop/style/exact_regexp_match.rb
706
715
  - lib/rubocop/cop/style/expand_path_arguments.rb
707
716
  - lib/rubocop/cop/style/explicit_block_argument.rb
708
717
  - lib/rubocop/cop/style/exponential_notation.rb
709
718
  - lib/rubocop/cop/style/fetch_env_var.rb
719
+ - lib/rubocop/cop/style/file_empty.rb
710
720
  - lib/rubocop/cop/style/file_read.rb
711
721
  - lib/rubocop/cop/style/file_write.rb
712
722
  - lib/rubocop/cop/style/float_division.rb
@@ -806,6 +816,7 @@ files:
806
816
  - lib/rubocop/cop/style/raise_args.rb
807
817
  - lib/rubocop/cop/style/random_with_offset.rb
808
818
  - lib/rubocop/cop/style/redundant_argument.rb
819
+ - lib/rubocop/cop/style/redundant_array_constructor.rb
809
820
  - lib/rubocop/cop/style/redundant_assignment.rb
810
821
  - lib/rubocop/cop/style/redundant_begin.rb
811
822
  - lib/rubocop/cop/style/redundant_capital_w.rb
@@ -817,13 +828,16 @@ files:
817
828
  - lib/rubocop/cop/style/redundant_exception.rb
818
829
  - lib/rubocop/cop/style/redundant_fetch_block.rb
819
830
  - lib/rubocop/cop/style/redundant_file_extension_in_require.rb
831
+ - lib/rubocop/cop/style/redundant_filter_chain.rb
820
832
  - lib/rubocop/cop/style/redundant_freeze.rb
821
833
  - lib/rubocop/cop/style/redundant_heredoc_delimiter_quotes.rb
822
834
  - lib/rubocop/cop/style/redundant_initialize.rb
823
835
  - lib/rubocop/cop/style/redundant_interpolation.rb
836
+ - lib/rubocop/cop/style/redundant_line_continuation.rb
824
837
  - lib/rubocop/cop/style/redundant_parentheses.rb
825
838
  - lib/rubocop/cop/style/redundant_percent_q.rb
826
839
  - lib/rubocop/cop/style/redundant_regexp_character_class.rb
840
+ - lib/rubocop/cop/style/redundant_regexp_constructor.rb
827
841
  - lib/rubocop/cop/style/redundant_regexp_escape.rb
828
842
  - lib/rubocop/cop/style/redundant_return.rb
829
843
  - lib/rubocop/cop/style/redundant_self.rb
@@ -903,6 +917,7 @@ files:
903
917
  - lib/rubocop/core_ext/string.rb
904
918
  - lib/rubocop/directive_comment.rb
905
919
  - lib/rubocop/error.rb
920
+ - lib/rubocop/ext/comment.rb
906
921
  - lib/rubocop/ext/processed_source.rb
907
922
  - lib/rubocop/ext/range.rb
908
923
  - lib/rubocop/ext/regexp_node.rb
@@ -981,7 +996,7 @@ metadata:
981
996
  homepage_uri: https://rubocop.org/
982
997
  changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
983
998
  source_code_uri: https://github.com/rubocop/rubocop/
984
- documentation_uri: https://docs.rubocop.org/rubocop/1.46/
999
+ documentation_uri: https://docs.rubocop.org/rubocop/1.52/
985
1000
  bug_tracker_uri: https://github.com/rubocop/rubocop/issues
986
1001
  rubygems_mfa_required: 'true'
987
1002
  post_install_message:
@@ -992,7 +1007,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
992
1007
  requirements:
993
1008
  - - ">="
994
1009
  - !ruby/object:Gem::Version
995
- version: 2.6.0
1010
+ version: 2.7.0
996
1011
  required_rubygems_version: !ruby/object:Gem::Requirement
997
1012
  requirements:
998
1013
  - - ">="