rubocop 0.89.0 → 0.92.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 (416) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/config/default.yml +128 -14
  4. data/lib/rubocop.rb +30 -4
  5. data/lib/rubocop/cached_data.rb +1 -0
  6. data/lib/rubocop/cli/command.rb +1 -0
  7. data/lib/rubocop/cli/command/auto_genenerate_config.rb +1 -0
  8. data/lib/rubocop/cli/command/base.rb +1 -0
  9. data/lib/rubocop/cli/command/execute_runner.rb +9 -0
  10. data/lib/rubocop/cli/command/init_dotfile.rb +1 -0
  11. data/lib/rubocop/cli/command/show_cops.rb +2 -1
  12. data/lib/rubocop/cli/command/version.rb +1 -0
  13. data/lib/rubocop/cli/environment.rb +1 -0
  14. data/lib/rubocop/comment_config.rb +17 -10
  15. data/lib/rubocop/config.rb +1 -1
  16. data/lib/rubocop/config_loader.rb +21 -10
  17. data/lib/rubocop/config_loader_resolver.rb +1 -0
  18. data/lib/rubocop/config_obsoletion.rb +1 -0
  19. data/lib/rubocop/config_regeneration.rb +33 -0
  20. data/lib/rubocop/config_store.rb +3 -3
  21. data/lib/rubocop/config_validator.rb +4 -1
  22. data/lib/rubocop/cop/base.rb +23 -0
  23. data/lib/rubocop/cop/bundler/duplicated_gem.rb +5 -1
  24. data/lib/rubocop/cop/bundler/gem_comment.rb +8 -3
  25. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +2 -0
  26. data/lib/rubocop/cop/commissioner.rb +47 -7
  27. data/lib/rubocop/cop/correctors/alignment_corrector.rb +4 -4
  28. data/lib/rubocop/cop/correctors/condition_corrector.rb +3 -5
  29. data/lib/rubocop/cop/correctors/empty_line_corrector.rb +9 -10
  30. data/lib/rubocop/cop/correctors/line_break_corrector.rb +4 -4
  31. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +8 -3
  32. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +5 -8
  33. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +5 -10
  34. data/lib/rubocop/cop/correctors/punctuation_corrector.rb +8 -10
  35. data/lib/rubocop/cop/documentation.rb +22 -0
  36. data/lib/rubocop/cop/generator.rb +2 -1
  37. data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +1 -0
  38. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -0
  39. data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +1 -0
  40. data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -0
  41. data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +1 -0
  42. data/lib/rubocop/cop/layout/array_alignment.rb +1 -0
  43. data/lib/rubocop/cop/layout/begin_end_alignment.rb +77 -0
  44. data/lib/rubocop/cop/layout/block_alignment.rb +23 -19
  45. data/lib/rubocop/cop/layout/case_indentation.rb +4 -7
  46. data/lib/rubocop/cop/layout/class_structure.rb +14 -17
  47. data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +4 -6
  48. data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
  49. data/lib/rubocop/cop/layout/condition_position.rb +13 -15
  50. data/lib/rubocop/cop/layout/def_end_alignment.rb +8 -5
  51. data/lib/rubocop/cop/layout/dot_position.rb +21 -17
  52. data/lib/rubocop/cop/layout/empty_comment.rb +30 -23
  53. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +21 -18
  54. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +13 -13
  55. data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +136 -0
  56. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +21 -23
  57. data/lib/rubocop/cop/layout/empty_lines.rb +6 -7
  58. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +18 -14
  59. data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +7 -8
  60. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +4 -7
  61. data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +2 -5
  62. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +2 -5
  63. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +2 -5
  64. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +3 -7
  65. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +2 -5
  66. data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +2 -5
  67. data/lib/rubocop/cop/layout/end_alignment.rb +11 -17
  68. data/lib/rubocop/cop/layout/extra_spacing.rb +14 -21
  69. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +2 -5
  70. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +2 -5
  71. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +4 -8
  72. data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +2 -5
  73. data/lib/rubocop/cop/layout/hash_alignment.rb +17 -20
  74. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +15 -14
  75. data/lib/rubocop/cop/layout/heredoc_indentation.rb +14 -11
  76. data/lib/rubocop/cop/layout/initial_indentation.rb +6 -7
  77. data/lib/rubocop/cop/layout/leading_comment_space.rb +12 -10
  78. data/lib/rubocop/cop/layout/leading_empty_lines.rb +6 -11
  79. data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +2 -5
  80. data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +2 -5
  81. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +10 -14
  82. data/lib/rubocop/cop/layout/multiline_block_layout.rb +21 -19
  83. data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +2 -5
  84. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +2 -5
  85. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +5 -9
  86. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +2 -5
  87. data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +2 -5
  88. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +41 -22
  89. data/lib/rubocop/cop/layout/space_after_colon.rb +11 -7
  90. data/lib/rubocop/cop/layout/space_after_comma.rb +2 -5
  91. data/lib/rubocop/cop/layout/space_after_method_name.rb +5 -6
  92. data/lib/rubocop/cop/layout/space_after_not.rb +9 -11
  93. data/lib/rubocop/cop/layout/space_after_semicolon.rb +2 -5
  94. data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +22 -17
  95. data/lib/rubocop/cop/layout/space_around_keyword.rb +17 -18
  96. data/lib/rubocop/cop/layout/space_around_operators.rb +17 -16
  97. data/lib/rubocop/cop/layout/space_before_block_braces.rb +23 -22
  98. data/lib/rubocop/cop/layout/space_before_comma.rb +3 -5
  99. data/lib/rubocop/cop/layout/space_before_comment.rb +10 -7
  100. data/lib/rubocop/cop/layout/space_before_first_arg.rb +7 -7
  101. data/lib/rubocop/cop/layout/space_before_semicolon.rb +2 -5
  102. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +9 -17
  103. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +20 -23
  104. data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +3 -8
  105. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +17 -16
  106. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +19 -37
  107. data/lib/rubocop/cop/layout/space_inside_parens.rb +9 -14
  108. data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +5 -10
  109. data/lib/rubocop/cop/layout/space_inside_range_literal.rb +8 -17
  110. data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +16 -24
  111. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +12 -13
  112. data/lib/rubocop/cop/layout/trailing_empty_lines.rb +10 -15
  113. data/lib/rubocop/cop/layout/trailing_whitespace.rb +11 -11
  114. data/lib/rubocop/cop/lint/ambiguous_operator.rb +2 -0
  115. data/lib/rubocop/cop/lint/big_decimal_new.rb +1 -2
  116. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +2 -1
  117. data/lib/rubocop/cop/lint/constant_definition_in_block.rb +74 -0
  118. data/lib/rubocop/cop/lint/constant_resolution.rb +1 -1
  119. data/lib/rubocop/cop/lint/debugger.rb +2 -3
  120. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -3
  121. data/lib/rubocop/cop/lint/duplicate_methods.rb +2 -4
  122. data/lib/rubocop/cop/lint/duplicate_require.rb +46 -0
  123. data/lib/rubocop/cop/lint/duplicate_rescue_exception.rb +2 -15
  124. data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -0
  125. data/lib/rubocop/cop/lint/empty_file.rb +50 -0
  126. data/lib/rubocop/cop/lint/erb_new_arguments.rb +2 -0
  127. data/lib/rubocop/cop/lint/float_comparison.rb +2 -2
  128. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +2 -2
  129. data/lib/rubocop/cop/lint/identity_comparison.rb +51 -0
  130. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +2 -5
  131. data/lib/rubocop/cop/lint/inherit_exception.rb +2 -2
  132. data/lib/rubocop/cop/lint/missing_super.rb +11 -11
  133. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +2 -35
  134. data/lib/rubocop/cop/lint/multiple_comparison.rb +3 -1
  135. data/lib/rubocop/cop/lint/number_conversion.rb +1 -0
  136. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +33 -15
  137. data/lib/rubocop/cop/lint/percent_string_array.rb +8 -12
  138. data/lib/rubocop/cop/lint/raise_exception.rb +1 -0
  139. data/lib/rubocop/cop/lint/rand_one.rb +2 -1
  140. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +36 -29
  141. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +14 -4
  142. data/lib/rubocop/cop/lint/redundant_require_statement.rb +1 -0
  143. data/lib/rubocop/cop/lint/rescue_type.rb +0 -1
  144. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +3 -1
  145. data/lib/rubocop/cop/lint/shadowed_exception.rb +6 -6
  146. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +4 -4
  147. data/lib/rubocop/cop/lint/struct_new_override.rb +1 -0
  148. data/lib/rubocop/cop/lint/to_json.rb +16 -5
  149. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +1 -1
  150. data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +57 -0
  151. data/lib/rubocop/cop/lint/unreachable_loop.rb +3 -6
  152. data/lib/rubocop/cop/lint/uri_escape_unescape.rb +3 -1
  153. data/lib/rubocop/cop/lint/uri_regexp.rb +10 -25
  154. data/lib/rubocop/cop/lint/useless_access_modifier.rb +3 -9
  155. data/lib/rubocop/cop/lint/useless_method_definition.rb +70 -0
  156. data/lib/rubocop/cop/lint/useless_times.rb +106 -0
  157. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +27 -16
  158. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +1 -0
  159. data/lib/rubocop/cop/migration/department_name.rb +2 -2
  160. data/lib/rubocop/cop/mixin/alignment.rb +5 -1
  161. data/lib/rubocop/cop/mixin/allowed_methods.rb +2 -0
  162. data/lib/rubocop/cop/mixin/annotation_comment.rb +5 -0
  163. data/lib/rubocop/cop/mixin/check_line_breakable.rb +17 -8
  164. data/lib/rubocop/cop/mixin/comments_help.rb +48 -0
  165. data/lib/rubocop/cop/mixin/configurable_naming.rb +2 -2
  166. data/lib/rubocop/cop/mixin/configurable_numbering.rb +3 -3
  167. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +8 -7
  168. data/lib/rubocop/cop/mixin/empty_parameter.rb +3 -1
  169. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +12 -1
  170. data/lib/rubocop/cop/mixin/enforce_superclass.rb +0 -2
  171. data/lib/rubocop/cop/mixin/first_element_line_break.rb +3 -1
  172. data/lib/rubocop/cop/mixin/hash_transform_method.rb +31 -12
  173. data/lib/rubocop/cop/mixin/line_length_help.rb +1 -3
  174. data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +3 -1
  175. data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +13 -12
  176. data/lib/rubocop/cop/mixin/negative_conditional.rb +2 -2
  177. data/lib/rubocop/cop/mixin/percent_array.rb +16 -9
  178. data/lib/rubocop/cop/mixin/range_help.rb +18 -4
  179. data/lib/rubocop/cop/mixin/regexp_literal_help.rb +1 -1
  180. data/lib/rubocop/cop/mixin/rescue_node.rb +11 -1
  181. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +4 -3
  182. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +4 -3
  183. data/lib/rubocop/cop/mixin/statement_modifier.rb +12 -6
  184. data/lib/rubocop/cop/mixin/surrounding_space.rb +8 -4
  185. data/lib/rubocop/cop/mixin/trailing_comma.rb +9 -11
  186. data/lib/rubocop/cop/mixin/visibility_help.rb +4 -16
  187. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -1
  188. data/lib/rubocop/cop/naming/file_name.rb +1 -1
  189. data/lib/rubocop/cop/offense.rb +1 -0
  190. data/lib/rubocop/cop/security/eval.rb +1 -0
  191. data/lib/rubocop/cop/security/json_load.rb +1 -0
  192. data/lib/rubocop/cop/security/marshal_load.rb +1 -0
  193. data/lib/rubocop/cop/security/open.rb +1 -0
  194. data/lib/rubocop/cop/security/yaml_load.rb +1 -0
  195. data/lib/rubocop/cop/severity.rb +0 -8
  196. data/lib/rubocop/cop/style/access_modifier_declarations.rb +8 -19
  197. data/lib/rubocop/cop/style/accessor_grouping.rb +20 -20
  198. data/lib/rubocop/cop/style/alias.rb +36 -33
  199. data/lib/rubocop/cop/style/and_or.rb +9 -11
  200. data/lib/rubocop/cop/style/array_coercion.rb +4 -0
  201. data/lib/rubocop/cop/style/array_join.rb +7 -8
  202. data/lib/rubocop/cop/style/ascii_comments.rb +4 -4
  203. data/lib/rubocop/cop/style/attr.rb +12 -9
  204. data/lib/rubocop/cop/style/auto_resource_cleanup.rb +4 -5
  205. data/lib/rubocop/cop/style/bare_percent_literals.rb +10 -12
  206. data/lib/rubocop/cop/style/begin_block.rb +2 -2
  207. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +9 -12
  208. data/lib/rubocop/cop/style/block_comments.rb +14 -18
  209. data/lib/rubocop/cop/style/block_delimiters.rb +23 -23
  210. data/lib/rubocop/cop/style/case_equality.rb +11 -3
  211. data/lib/rubocop/cop/style/case_like_if.rb +37 -18
  212. data/lib/rubocop/cop/style/class_and_module_children.rb +16 -11
  213. data/lib/rubocop/cop/style/class_check.rb +6 -11
  214. data/lib/rubocop/cop/style/class_methods.rb +7 -11
  215. data/lib/rubocop/cop/style/class_methods_definitions.rb +157 -0
  216. data/lib/rubocop/cop/style/class_vars.rb +7 -12
  217. data/lib/rubocop/cop/style/collection_methods.rb +11 -17
  218. data/lib/rubocop/cop/style/colon_method_call.rb +6 -7
  219. data/lib/rubocop/cop/style/colon_method_definition.rb +6 -6
  220. data/lib/rubocop/cop/style/combinable_loops.rb +84 -0
  221. data/lib/rubocop/cop/style/command_literal.rb +23 -24
  222. data/lib/rubocop/cop/style/comment_annotation.rb +15 -15
  223. data/lib/rubocop/cop/style/commented_keyword.rb +8 -9
  224. data/lib/rubocop/cop/style/conditional_assignment.rb +50 -61
  225. data/lib/rubocop/cop/style/constant_visibility.rb +3 -2
  226. data/lib/rubocop/cop/style/copyright.rb +12 -12
  227. data/lib/rubocop/cop/style/date_time.rb +13 -2
  228. data/lib/rubocop/cop/style/def_with_parentheses.rb +8 -10
  229. data/lib/rubocop/cop/style/dir.rb +8 -10
  230. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +7 -9
  231. data/lib/rubocop/cop/style/documentation.rb +2 -4
  232. data/lib/rubocop/cop/style/documentation_method.rb +1 -1
  233. data/lib/rubocop/cop/style/double_cop_disable_directive.rb +12 -15
  234. data/lib/rubocop/cop/style/double_negation.rb +3 -2
  235. data/lib/rubocop/cop/style/each_for_simple_loop.rb +5 -8
  236. data/lib/rubocop/cop/style/each_with_object.rb +16 -17
  237. data/lib/rubocop/cop/style/empty_block_parameter.rb +9 -10
  238. data/lib/rubocop/cop/style/empty_case_condition.rb +19 -20
  239. data/lib/rubocop/cop/style/empty_else.rb +17 -19
  240. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +9 -10
  241. data/lib/rubocop/cop/style/empty_literal.rb +18 -17
  242. data/lib/rubocop/cop/style/empty_method.rb +5 -8
  243. data/lib/rubocop/cop/style/encoding.rb +5 -9
  244. data/lib/rubocop/cop/style/end_block.rb +4 -6
  245. data/lib/rubocop/cop/style/eval_with_location.rb +6 -10
  246. data/lib/rubocop/cop/style/even_odd.rb +8 -11
  247. data/lib/rubocop/cop/style/expand_path_arguments.rb +23 -26
  248. data/lib/rubocop/cop/style/explicit_block_argument.rb +1 -1
  249. data/lib/rubocop/cop/style/exponential_notation.rb +1 -1
  250. data/lib/rubocop/cop/style/float_division.rb +3 -1
  251. data/lib/rubocop/cop/style/for.rb +11 -15
  252. data/lib/rubocop/cop/style/format_string.rb +18 -23
  253. data/lib/rubocop/cop/style/format_string_token.rb +4 -7
  254. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +19 -41
  255. data/lib/rubocop/cop/style/global_vars.rb +2 -2
  256. data/lib/rubocop/cop/style/guard_clause.rb +4 -4
  257. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +24 -5
  258. data/lib/rubocop/cop/style/hash_each_methods.rb +5 -8
  259. data/lib/rubocop/cop/style/hash_syntax.rb +6 -7
  260. data/lib/rubocop/cop/style/hash_transform_keys.rb +19 -11
  261. data/lib/rubocop/cop/style/hash_transform_values.rb +18 -10
  262. data/lib/rubocop/cop/style/identical_conditional_branches.rb +1 -1
  263. data/lib/rubocop/cop/style/if_inside_else.rb +2 -2
  264. data/lib/rubocop/cop/style/if_unless_modifier.rb +11 -17
  265. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +3 -7
  266. data/lib/rubocop/cop/style/if_with_semicolon.rb +3 -6
  267. data/lib/rubocop/cop/style/implicit_runtime_error.rb +2 -1
  268. data/lib/rubocop/cop/style/infinite_loop.rb +23 -23
  269. data/lib/rubocop/cop/style/inline_comment.rb +3 -3
  270. data/lib/rubocop/cop/style/inverse_methods.rb +20 -29
  271. data/lib/rubocop/cop/style/keyword_parameters_order.rb +53 -0
  272. data/lib/rubocop/cop/style/lambda.rb +7 -12
  273. data/lib/rubocop/cop/style/lambda_call.rb +17 -14
  274. data/lib/rubocop/cop/style/line_end_concatenation.rb +19 -16
  275. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +2 -1
  276. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +11 -11
  277. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +4 -8
  278. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +7 -6
  279. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +12 -3
  280. data/lib/rubocop/cop/style/method_def_parentheses.rb +11 -16
  281. data/lib/rubocop/cop/style/min_max.rb +8 -12
  282. data/lib/rubocop/cop/style/missing_else.rb +13 -13
  283. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +1 -1
  284. data/lib/rubocop/cop/style/mixin_grouping.rb +24 -27
  285. data/lib/rubocop/cop/style/mixin_usage.rb +9 -28
  286. data/lib/rubocop/cop/style/module_function.rb +10 -13
  287. data/lib/rubocop/cop/style/multiline_block_chain.rb +2 -2
  288. data/lib/rubocop/cop/style/multiline_if_modifier.rb +3 -10
  289. data/lib/rubocop/cop/style/multiline_if_then.rb +4 -10
  290. data/lib/rubocop/cop/style/multiline_memoization.rb +12 -10
  291. data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -1
  292. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +17 -6
  293. data/lib/rubocop/cop/style/multiline_when_then.rb +10 -11
  294. data/lib/rubocop/cop/style/multiple_comparison.rb +1 -1
  295. data/lib/rubocop/cop/style/mutable_constant.rb +23 -20
  296. data/lib/rubocop/cop/style/negated_if.rb +6 -6
  297. data/lib/rubocop/cop/style/negated_unless.rb +6 -6
  298. data/lib/rubocop/cop/style/negated_while.rb +7 -15
  299. data/lib/rubocop/cop/style/nested_modifier.rb +10 -13
  300. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +14 -12
  301. data/lib/rubocop/cop/style/nested_ternary_operator.rb +14 -16
  302. data/lib/rubocop/cop/style/next.rb +10 -14
  303. data/lib/rubocop/cop/style/nil_comparison.rb +13 -11
  304. data/lib/rubocop/cop/style/non_nil_check.rb +34 -26
  305. data/lib/rubocop/cop/style/not.rb +20 -26
  306. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +4 -9
  307. data/lib/rubocop/cop/style/numeric_predicate.rb +5 -14
  308. data/lib/rubocop/cop/style/one_line_conditional.rb +73 -23
  309. data/lib/rubocop/cop/style/option_hash.rb +1 -1
  310. data/lib/rubocop/cop/style/optional_arguments.rb +1 -1
  311. data/lib/rubocop/cop/style/optional_boolean_parameter.rb +12 -1
  312. data/lib/rubocop/cop/style/or_assignment.rb +13 -10
  313. data/lib/rubocop/cop/style/parallel_assignment.rb +14 -14
  314. data/lib/rubocop/cop/style/parentheses_around_condition.rb +6 -6
  315. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +13 -19
  316. data/lib/rubocop/cop/style/percent_q_literals.rb +8 -10
  317. data/lib/rubocop/cop/style/perl_backrefs.rb +8 -10
  318. data/lib/rubocop/cop/style/preferred_hash_methods.rb +11 -14
  319. data/lib/rubocop/cop/style/proc.rb +6 -6
  320. data/lib/rubocop/cop/style/raise_args.rb +15 -24
  321. data/lib/rubocop/cop/style/random_with_offset.rb +19 -19
  322. data/lib/rubocop/cop/style/redundant_assignment.rb +8 -18
  323. data/lib/rubocop/cop/style/redundant_begin.rb +7 -9
  324. data/lib/rubocop/cop/style/redundant_capital_w.rb +6 -9
  325. data/lib/rubocop/cop/style/redundant_condition.rb +5 -6
  326. data/lib/rubocop/cop/style/redundant_conditional.rb +4 -5
  327. data/lib/rubocop/cop/style/redundant_exception.rb +1 -3
  328. data/lib/rubocop/cop/style/redundant_fetch_block.rb +3 -12
  329. data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +9 -8
  330. data/lib/rubocop/cop/style/redundant_freeze.rb +5 -7
  331. data/lib/rubocop/cop/style/redundant_interpolation.rb +25 -24
  332. data/lib/rubocop/cop/style/redundant_parentheses.rb +21 -15
  333. data/lib/rubocop/cop/style/redundant_percent_q.rb +9 -11
  334. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +6 -13
  335. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +5 -14
  336. data/lib/rubocop/cop/style/redundant_return.rb +17 -17
  337. data/lib/rubocop/cop/style/redundant_self.rb +9 -11
  338. data/lib/rubocop/cop/style/redundant_self_assignment.rb +116 -0
  339. data/lib/rubocop/cop/style/redundant_sort.rb +12 -31
  340. data/lib/rubocop/cop/style/redundant_sort_by.rb +5 -9
  341. data/lib/rubocop/cop/style/regexp_literal.rb +10 -21
  342. data/lib/rubocop/cop/style/rescue_modifier.rb +29 -9
  343. data/lib/rubocop/cop/style/rescue_standard_error.rb +20 -16
  344. data/lib/rubocop/cop/style/return_nil.rb +5 -5
  345. data/lib/rubocop/cop/style/safe_navigation.rb +22 -16
  346. data/lib/rubocop/cop/style/sample.rb +12 -14
  347. data/lib/rubocop/cop/style/self_assignment.rb +26 -22
  348. data/lib/rubocop/cop/style/semicolon.rb +6 -9
  349. data/lib/rubocop/cop/style/send.rb +4 -5
  350. data/lib/rubocop/cop/style/signal_exception.rb +23 -19
  351. data/lib/rubocop/cop/style/single_argument_dig.rb +1 -0
  352. data/lib/rubocop/cop/style/single_line_block_params.rb +4 -2
  353. data/lib/rubocop/cop/style/single_line_methods.rb +18 -17
  354. data/lib/rubocop/cop/style/slicing_with_range.rb +6 -8
  355. data/lib/rubocop/cop/style/sole_nested_conditional.rb +66 -0
  356. data/lib/rubocop/cop/style/special_global_vars.rb +10 -15
  357. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +17 -21
  358. data/lib/rubocop/cop/style/stderr_puts.rb +5 -6
  359. data/lib/rubocop/cop/style/string_concatenation.rb +16 -2
  360. data/lib/rubocop/cop/style/string_hash_keys.rb +6 -7
  361. data/lib/rubocop/cop/style/string_methods.rb +7 -17
  362. data/lib/rubocop/cop/style/strip.rb +9 -14
  363. data/lib/rubocop/cop/style/struct_inheritance.rb +3 -6
  364. data/lib/rubocop/cop/style/symbol_array.rb +5 -16
  365. data/lib/rubocop/cop/style/symbol_literal.rb +4 -6
  366. data/lib/rubocop/cop/style/symbol_proc.rb +14 -18
  367. data/lib/rubocop/cop/style/ternary_parentheses.rb +22 -22
  368. data/lib/rubocop/cop/style/trailing_body_on_class.rb +3 -6
  369. data/lib/rubocop/cop/style/trailing_body_on_method_definition.rb +4 -7
  370. data/lib/rubocop/cop/style/trailing_body_on_module.rb +3 -6
  371. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +2 -5
  372. data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +2 -5
  373. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +11 -9
  374. data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +2 -5
  375. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +8 -17
  376. data/lib/rubocop/cop/style/trivial_accessors.rb +26 -30
  377. data/lib/rubocop/cop/style/unless_else.rb +5 -8
  378. data/lib/rubocop/cop/style/unpack_first.rb +5 -8
  379. data/lib/rubocop/cop/style/variable_interpolation.rb +7 -10
  380. data/lib/rubocop/cop/style/when_then.rb +4 -6
  381. data/lib/rubocop/cop/style/while_until_do.rb +6 -16
  382. data/lib/rubocop/cop/style/while_until_modifier.rb +6 -20
  383. data/lib/rubocop/cop/style/word_array.rb +5 -23
  384. data/lib/rubocop/cop/style/yoda_condition.rb +4 -15
  385. data/lib/rubocop/cop/style/zero_length_predicate.rb +12 -18
  386. data/lib/rubocop/cop/team.rb +1 -0
  387. data/lib/rubocop/cop/util.rb +2 -1
  388. data/lib/rubocop/cop/utils/format_string.rb +3 -5
  389. data/lib/rubocop/cop/variable_force.rb +2 -0
  390. data/lib/rubocop/cops_documentation_generator.rb +5 -3
  391. data/lib/rubocop/core_ext/string.rb +2 -2
  392. data/lib/rubocop/directive_comment.rb +32 -0
  393. data/lib/rubocop/ext/regexp_node.rb +46 -0
  394. data/lib/rubocop/file_finder.rb +1 -0
  395. data/lib/rubocop/formatter/auto_gen_config_formatter.rb +2 -1
  396. data/lib/rubocop/formatter/disabled_config_formatter.rb +13 -6
  397. data/lib/rubocop/formatter/html_formatter.rb +2 -0
  398. data/lib/rubocop/formatter/junit_formatter.rb +1 -1
  399. data/lib/rubocop/formatter/progress_formatter.rb +2 -1
  400. data/lib/rubocop/formatter/quiet_formatter.rb +1 -1
  401. data/lib/rubocop/formatter/simple_text_formatter.rb +36 -6
  402. data/lib/rubocop/name_similarity.rb +1 -0
  403. data/lib/rubocop/options.rb +43 -20
  404. data/lib/rubocop/remote_config.rb +1 -0
  405. data/lib/rubocop/result_cache.rb +31 -13
  406. data/lib/rubocop/rspec/cop_helper.rb +4 -1
  407. data/lib/rubocop/rspec/expect_offense.rb +14 -9
  408. data/lib/rubocop/rspec/shared_contexts.rb +13 -5
  409. data/lib/rubocop/runner.rb +35 -15
  410. data/lib/rubocop/string_interpreter.rb +3 -0
  411. data/lib/rubocop/target_finder.rb +5 -1
  412. data/lib/rubocop/target_ruby.rb +7 -1
  413. data/lib/rubocop/version.rb +7 -1
  414. data/lib/rubocop/yaml_duplication_checker.rb +1 -0
  415. metadata +26 -14
  416. data/lib/rubocop/cop/tokens_util.rb +0 -84
@@ -5,6 +5,7 @@ require 'time'
5
5
 
6
6
  module RuboCop
7
7
  # Common methods and behaviors for dealing with remote config files.
8
+ # @api private
8
9
  class RemoteConfig
9
10
  attr_reader :uri
10
11
 
@@ -3,9 +3,11 @@
3
3
  require 'digest/sha1'
4
4
  require 'find'
5
5
  require 'etc'
6
+ require 'zlib'
6
7
 
7
8
  module RuboCop
8
9
  # Provides functionality for caching rubocop runs.
10
+ # @api private
9
11
  class ResultCache
10
12
  NON_CHANGING = %i[color format formatters out debug fail_level auto_correct
11
13
  cache fail_fast stdin parallel].freeze
@@ -29,6 +31,11 @@ module RuboCop
29
31
  end
30
32
 
31
33
  class << self
34
+ # @api private
35
+ attr_accessor :rubocop_required_features
36
+
37
+ ResultCache.rubocop_required_features = []
38
+
32
39
  private
33
40
 
34
41
  def requires_file_removal?(file_count, config_store)
@@ -60,7 +67,8 @@ module RuboCop
60
67
  end
61
68
 
62
69
  def self.cache_root(config_store)
63
- root = config_store.for_pwd.for_all_cops['CacheRootDirectory']
70
+ root = ENV['RUBOCOP_CACHE_ROOT']
71
+ root ||= config_store.for_pwd.for_all_cops['CacheRootDirectory']
64
72
  root ||= if ENV.key?('XDG_CACHE_HOME')
65
73
  # Include user ID in the path to make sure the user has write
66
74
  # access.
@@ -75,7 +83,10 @@ module RuboCop
75
83
  config_store.for_pwd.for_all_cops['AllowSymlinksInCacheRootDirectory']
76
84
  end
77
85
 
86
+ attr :path
87
+
78
88
  def initialize(file, team, options, config_store, cache_root = nil)
89
+ cache_root ||= options[:cache_root]
79
90
  cache_root ||= ResultCache.cache_root(config_store)
80
91
  @allow_symlinks_in_cache_location =
81
92
  ResultCache.allow_symlinks_in_cache_location?(config_store)
@@ -158,27 +169,34 @@ module RuboCop
158
169
  end
159
170
 
160
171
  # The checksum of the rubocop program running the inspection.
161
- # rubocop:disable Metrics/AbcSize
162
172
  def rubocop_checksum
163
173
  ResultCache.source_checksum ||=
164
174
  begin
165
- lib_root = File.join(File.dirname(__FILE__), '..')
166
- exe_root = File.join(lib_root, '..', 'exe')
167
-
168
- # These are all the files we have `require`d plus everything in the
169
- # exe directory. A change to any of them could affect the cop output
170
- # so we include them in the cache hash.
171
- source_files = $LOADED_FEATURES + Find.find(exe_root).to_a
172
-
173
175
  digest = Digest::SHA1.new
174
- source_files
176
+ rubocop_extra_features
175
177
  .select { |path| File.file?(path) }
176
178
  .sort!
177
- .each { |path| digest << File.mtime(path).to_s }
179
+ .each do |path|
180
+ content = File.open(path, 'rb', &:read)
181
+ digest << Zlib.crc32(content).to_s # mtime not reliable
182
+ end
183
+ digest << RuboCop::Version::STRING << RuboCop::AST::Version::STRING
178
184
  digest.hexdigest
179
185
  end
180
186
  end
181
- # rubocop:enable Metrics/AbcSize
187
+
188
+ def rubocop_extra_features
189
+ lib_root = File.join(File.dirname(__FILE__), '..')
190
+ exe_root = File.join(lib_root, '..', 'exe')
191
+
192
+ # These are all the files we have `require`d plus everything in the
193
+ # exe directory. A change to any of them could affect the cop output
194
+ # so we include them in the cache hash.
195
+ source_files = $LOADED_FEATURES + Find.find(exe_root).to_a
196
+ source_files -= ResultCache.rubocop_required_features # Rely on gem versions
197
+
198
+ source_files
199
+ end
182
200
 
183
201
  # Return a hash of the options given at invocation, minus the ones that have
184
202
  # no effect on which offenses and disabled line ranges are found, and thus
@@ -17,7 +17,10 @@ module CopHelper
17
17
  RuboCop::Formatter::DisabledConfigFormatter.config_to_allow_offenses = {}
18
18
  RuboCop::Formatter::DisabledConfigFormatter.detected_styles = {}
19
19
  processed_source = parse_source(source, file)
20
- raise 'Error parsing example code' unless processed_source.valid_syntax?
20
+ unless processed_source.valid_syntax?
21
+ raise 'Error parsing example code: ' \
22
+ "#{processed_source.diagnostics.map(&:render).join("\n")}"
23
+ end
21
24
 
22
25
  _investigate(cop, processed_source)
23
26
  end
@@ -128,14 +128,19 @@ module RuboCop
128
128
  @processed_source = parse_source(expected_annotations.plain_source,
129
129
  file)
130
130
 
131
- raise 'Error parsing example code' unless @processed_source.valid_syntax?
131
+ unless @processed_source.valid_syntax?
132
+ raise 'Error parsing example code: ' \
133
+ "#{@processed_source.diagnostics.map(&:render).join("\n")}"
134
+ end
132
135
 
133
- offenses = _investigate(cop, @processed_source)
136
+ @offenses = _investigate(cop, @processed_source)
134
137
  actual_annotations =
135
- expected_annotations.with_offense_annotations(offenses)
138
+ expected_annotations.with_offense_annotations(@offenses)
136
139
 
137
140
  expect(actual_annotations).to eq(expected_annotations), ''
138
- expect(offenses.map(&:severity).uniq).to eq([severity]) if severity
141
+ expect(@offenses.map(&:severity).uniq).to eq([severity]) if severity
142
+
143
+ @offenses
139
144
  end
140
145
 
141
146
  def expect_correction(correction, loop: true)
@@ -152,7 +157,7 @@ module RuboCop
152
157
  break corrected_source if corrected_source == @processed_source.buffer.source
153
158
 
154
159
  if iteration > RuboCop::Runner::MAX_ITERATIONS
155
- raise RuboCop::Runner::InfiniteCorrectionLoop.new(@processed_source.path, [])
160
+ raise RuboCop::Runner::InfiniteCorrectionLoop.new(@processed_source.path, [@offenses])
156
161
  end
157
162
 
158
163
  # Prepare for next loop
@@ -236,10 +241,10 @@ module RuboCop
236
241
  def match_annotations?(other)
237
242
  annotations.zip(other.annotations) do |(_actual_line, actual_annotation),
238
243
  (_expected_line, expected_annotation)|
239
- if expected_annotation&.end_with?(ABBREV)
240
- if actual_annotation.start_with?(expected_annotation[0...-ABBREV.length])
241
- expected_annotation.replace(actual_annotation)
242
- end
244
+ if expected_annotation&.end_with?(ABBREV) &&
245
+ actual_annotation.start_with?(expected_annotation[0...-ABBREV.length])
246
+
247
+ expected_annotation.replace(actual_annotation)
243
248
  end
244
249
  end
245
250
 
@@ -40,12 +40,22 @@ RSpec.shared_context 'isolated environment', :isolated_environment do
40
40
  end
41
41
  end
42
42
 
43
+ RSpec.shared_context 'maintain registry', :restore_registry do
44
+ around(:each) do |example|
45
+ RuboCop::Cop::Registry.with_temporary_global { example.run }
46
+ end
47
+
48
+ def stub_cop_class(name, inherit: RuboCop::Cop::Base, &block)
49
+ klass = Class.new(inherit, &block)
50
+ stub_const(name, klass)
51
+ klass
52
+ end
53
+ end
54
+
43
55
  # This context assumes nothing and defines `cop`, among others.
44
56
  RSpec.shared_context 'config', :config do # rubocop:disable Metrics/BlockLength
45
57
  ### Meant to be overridden at will
46
58
 
47
- let(:source) { 'code = {some: :ruby}' }
48
-
49
59
  let(:cop_class) do
50
60
  unless described_class.is_a?(Class) && described_class < RuboCop::Cop::Base
51
61
  raise 'Specify which cop class to use (e.g `let(:cop_class) { RuboCop::Cop::Base }`, ' \
@@ -97,9 +107,7 @@ RSpec.shared_context 'config', :config do # rubocop:disable Metrics/BlockLength
97
107
  end
98
108
 
99
109
  let(:cop) do
100
- cop_class.new(config, cop_options).tap do |cop|
101
- cop.send :begin_investigation, processed_source
102
- end
110
+ cop_class.new(config, cop_options)
103
111
  end
104
112
  end
105
113
 
@@ -11,12 +11,20 @@ module RuboCop
11
11
  class InfiniteCorrectionLoop < RuntimeError
12
12
  attr_reader :offenses
13
13
 
14
- def initialize(path, offenses)
15
- super "Infinite loop detected in #{path}."
16
- @offenses = offenses
14
+ def initialize(path, offenses_by_iteration, loop_start: -1)
15
+ @offenses = offenses_by_iteration.flatten.uniq
16
+ root_cause = offenses_by_iteration[loop_start..-1]
17
+ .map { |x| x.map(&:cop_name).uniq.join(', ') }
18
+ .join(' -> ')
19
+
20
+ message = 'Infinite loop detected'
21
+ message += " in #{path}" if path
22
+ message += " and caused by #{root_cause}" if root_cause
23
+ super message
17
24
  end
18
25
  end
19
26
 
27
+ # @api private
20
28
  MAX_ITERATIONS = 200
21
29
 
22
30
  attr_reader :errors, :warnings
@@ -80,7 +88,10 @@ module RuboCop
80
88
  # OPTIMIZE: Calling `ResultCache.cleanup` takes time. This optimization
81
89
  # mainly targets editors that integrates RuboCop. When RuboCop is run
82
90
  # by an editor, it should be inspecting only one file.
83
- ResultCache.cleanup(@config_store, @options[:debug]) if files.size > 1 && cached_run?
91
+ if files.size > 1 && cached_run?
92
+ ResultCache.cleanup(@config_store, @options[:debug], @options[:cache_root])
93
+ end
94
+
84
95
  formatter_set.finished(inspected_files.freeze)
85
96
  formatter_set.close_output_files
86
97
  end
@@ -232,18 +243,21 @@ module RuboCop
232
243
 
233
244
  def do_inspection_loop(file)
234
245
  processed_source = get_processed_source(file)
235
- offenses = []
246
+ # This variable is 2d array used to track corrected offenses after each
247
+ # inspection iteration. This is used to output meaningful infinite loop
248
+ # error message.
249
+ offenses_by_iteration = []
236
250
 
237
251
  # When running with --auto-correct, we need to inspect the file (which
238
252
  # includes writing a corrected version of it) until no more corrections
239
253
  # are made. This is because automatic corrections can introduce new
240
254
  # offenses. In the normal case the loop is only executed once.
241
- iterate_until_no_changes(processed_source, offenses) do
255
+ iterate_until_no_changes(processed_source, offenses_by_iteration) do
242
256
  # The offenses that couldn't be corrected will be found again so we
243
257
  # only keep the corrected ones in order to avoid duplicate reporting.
244
- offenses.select!(&:corrected?)
258
+ !offenses_by_iteration.empty? && offenses_by_iteration.last.select!(&:corrected?)
245
259
  new_offenses, updated_source_file = inspect_file(processed_source)
246
- offenses.concat(new_offenses).uniq!
260
+ offenses_by_iteration.push(new_offenses)
247
261
 
248
262
  # We have to reprocess the source to pickup the changes. Since the
249
263
  # change could (theoretically) introduce parsing errors, we break the
@@ -253,10 +267,12 @@ module RuboCop
253
267
  processed_source = get_processed_source(file)
254
268
  end
255
269
 
270
+ # Return summary of corrected offenses after all iterations
271
+ offenses = offenses_by_iteration.flatten.uniq
256
272
  [processed_source, offenses]
257
273
  end
258
274
 
259
- def iterate_until_no_changes(source, offenses)
275
+ def iterate_until_no_changes(source, offenses_by_iteration)
260
276
  # Keep track of the state of the source. If a cop modifies the source
261
277
  # and another cop undoes it producing identical source we have an
262
278
  # infinite loop.
@@ -268,10 +284,10 @@ module RuboCop
268
284
  iterations = 0
269
285
 
270
286
  loop do
271
- check_for_infinite_loop(source, offenses)
287
+ check_for_infinite_loop(source, offenses_by_iteration)
272
288
 
273
289
  if (iterations += 1) > MAX_ITERATIONS
274
- raise InfiniteCorrectionLoop.new(source.path, offenses)
290
+ raise InfiniteCorrectionLoop.new(source.path, offenses_by_iteration)
275
291
  end
276
292
 
277
293
  source = yield
@@ -281,11 +297,15 @@ module RuboCop
281
297
 
282
298
  # Check whether a run created source identical to a previous run, which
283
299
  # means that we definitely have an infinite loop.
284
- def check_for_infinite_loop(processed_source, offenses)
300
+ def check_for_infinite_loop(processed_source, offenses_by_iteration)
285
301
  checksum = processed_source.checksum
286
302
 
287
- if @processed_sources.include?(checksum)
288
- raise InfiniteCorrectionLoop.new(processed_source.path, offenses)
303
+ if (loop_start_index = @processed_sources.index(checksum))
304
+ raise InfiniteCorrectionLoop.new(
305
+ processed_source.path,
306
+ offenses_by_iteration,
307
+ loop_start: loop_start_index
308
+ )
289
309
  end
290
310
 
291
311
  @processed_sources << checksum
@@ -306,7 +326,7 @@ module RuboCop
306
326
  def mobilized_cop_classes(config)
307
327
  @mobilized_cop_classes ||= {}
308
328
  @mobilized_cop_classes[config.object_id] ||= begin
309
- cop_classes = Cop::Cop.all
329
+ cop_classes = Cop::Registry.all
310
330
 
311
331
  OptionsValidator.new(@options).validate_cop_options
312
332
 
@@ -17,6 +17,9 @@ module RuboCop
17
17
  u\{[^}]*\} | # extended unicode escape
18
18
  . # any other escaped char
19
19
  )/x.freeze
20
+
21
+ private_constant :STRING_ESCAPES, :STRING_ESCAPE_REGEX
22
+
20
23
  class << self
21
24
  def interpret(string)
22
25
  # We currently don't handle \cx, \C-x, and \M-x
@@ -3,7 +3,10 @@
3
3
  module RuboCop
4
4
  # This class finds target files to inspect by scanning the directory tree
5
5
  # and picking ruby files.
6
+ # @api private
6
7
  class TargetFinder
8
+ HIDDEN_PATH_SUBSTRING = "#{File::SEPARATOR}."
9
+
7
10
  def initialize(config_store, options = {})
8
11
  @config_store = config_store
9
12
  @options = options
@@ -54,7 +57,8 @@ module RuboCop
54
57
  # Support Windows: Backslashes from command-line -> forward slashes
55
58
  base_dir = base_dir.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
56
59
  all_files = find_files(base_dir, File::FNM_DOTMATCH)
57
- hidden_files = Set.new(all_files - find_files(base_dir, 0))
60
+ # use file.include? for performance optimization
61
+ hidden_files = all_files.select { |file| file.include?(HIDDEN_PATH_SUBSTRING) }
58
62
  base_dir_config = @config_store.for(base_dir)
59
63
 
60
64
  target_files = all_files.select do |file|
@@ -2,8 +2,9 @@
2
2
 
3
3
  module RuboCop
4
4
  # The kind of Ruby that code inspected by RuboCop is written in.
5
+ # @api private
5
6
  class TargetRuby
6
- KNOWN_RUBIES = [2.4, 2.5, 2.6, 2.7, 2.8].freeze
7
+ KNOWN_RUBIES = [2.4, 2.5, 2.6, 2.7, 3.0].freeze
7
8
  DEFAULT_VERSION = KNOWN_RUBIES.first
8
9
 
9
10
  OBSOLETE_RUBIES = {
@@ -12,6 +13,7 @@ module RuboCop
12
13
  private_constant :KNOWN_RUBIES, :OBSOLETE_RUBIES
13
14
 
14
15
  # A place where information about a target ruby version is found.
16
+ # @api private
15
17
  class Source
16
18
  attr_reader :version, :name
17
19
 
@@ -26,6 +28,7 @@ module RuboCop
26
28
  end
27
29
 
28
30
  # The target ruby version may be configured in RuboCop's config.
31
+ # @api private
29
32
  class RuboCopConfig < Source
30
33
  def name
31
34
  "`TargetRubyVersion` parameter (in #{@config.smart_loaded_path})"
@@ -39,6 +42,7 @@ module RuboCop
39
42
  end
40
43
 
41
44
  # The target ruby version may be found in a .ruby-version file.
45
+ # @api private
42
46
  class RubyVersionFile < Source
43
47
  FILENAME = '.ruby-version'
44
48
 
@@ -68,6 +72,7 @@ module RuboCop
68
72
  end
69
73
 
70
74
  # The lock file of Bundler may identify the target ruby version.
75
+ # @api private
71
76
  class BundlerLockFile < Source
72
77
  def name
73
78
  "`#{bundler_lock_file_path}`"
@@ -108,6 +113,7 @@ module RuboCop
108
113
  end
109
114
 
110
115
  # If all else fails, a default version will be picked.
116
+ # @api private
111
117
  class Default < Source
112
118
  def name
113
119
  'default'
@@ -3,12 +3,13 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.89.0'
6
+ STRING = '0.92.0'
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 %<ruby_platform>s)'
11
11
 
12
+ # @api private
12
13
  def self.version(debug: false)
13
14
  if debug
14
15
  format(MSG, version: STRING, parser_version: Parser::VERSION,
@@ -19,5 +20,10 @@ module RuboCop
19
20
  STRING
20
21
  end
21
22
  end
23
+
24
+ # @api private
25
+ def self.document_version
26
+ STRING.match('\d+\.\d+').to_s
27
+ end
22
28
  end
23
29
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  # Find duplicated keys from YAML.
5
+ # @api private
5
6
  module YAMLDuplicationChecker
6
7
  def self.check(yaml_string, filename, &on_duplicated)
7
8
  # Ruby 2.6+
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: 0.89.0
4
+ version: 0.92.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: 2020-08-05 00:00:00.000000000 Z
13
+ date: 2020-09-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: parallel
@@ -32,14 +32,14 @@ dependencies:
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: 2.7.1.1
35
+ version: 2.7.1.5
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 2.7.1.1
42
+ version: 2.7.1.5
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: rainbow
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -94,20 +94,14 @@ dependencies:
94
94
  requirements:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
- version: 0.1.0
98
- - - "<"
99
- - !ruby/object:Gem::Version
100
- version: '1.0'
97
+ version: 0.5.0
101
98
  type: :runtime
102
99
  prerelease: false
103
100
  version_requirements: !ruby/object:Gem::Requirement
104
101
  requirements:
105
102
  - - ">="
106
103
  - !ruby/object:Gem::Version
107
- version: 0.1.0
108
- - - "<"
109
- - !ruby/object:Gem::Version
110
- version: '1.0'
104
+ version: 0.5.0
111
105
  - !ruby/object:Gem::Dependency
112
106
  name: ruby-progressbar
113
107
  requirement: !ruby/object:Gem::Requirement
@@ -199,6 +193,7 @@ files:
199
193
  - lib/rubocop/config_loader.rb
200
194
  - lib/rubocop/config_loader_resolver.rb
201
195
  - lib/rubocop/config_obsoletion.rb
196
+ - lib/rubocop/config_regeneration.rb
202
197
  - lib/rubocop/config_store.rb
203
198
  - lib/rubocop/config_validator.rb
204
199
  - lib/rubocop/cop/autocorrect_logic.rb
@@ -226,6 +221,7 @@ files:
226
221
  - lib/rubocop/cop/correctors/space_corrector.rb
227
222
  - lib/rubocop/cop/correctors/string_literal_corrector.rb
228
223
  - lib/rubocop/cop/correctors/unused_arg_corrector.rb
224
+ - lib/rubocop/cop/documentation.rb
229
225
  - lib/rubocop/cop/force.rb
230
226
  - lib/rubocop/cop/gemspec/duplicated_assignment.rb
231
227
  - lib/rubocop/cop/gemspec/ordered_dependencies.rb
@@ -247,6 +243,7 @@ files:
247
243
  - lib/rubocop/cop/layout/argument_alignment.rb
248
244
  - lib/rubocop/cop/layout/array_alignment.rb
249
245
  - lib/rubocop/cop/layout/assignment_indentation.rb
246
+ - lib/rubocop/cop/layout/begin_end_alignment.rb
250
247
  - lib/rubocop/cop/layout/block_alignment.rb
251
248
  - lib/rubocop/cop/layout/block_end_newline.rb
252
249
  - lib/rubocop/cop/layout/case_indentation.rb
@@ -261,6 +258,7 @@ files:
261
258
  - lib/rubocop/cop/layout/empty_comment.rb
262
259
  - lib/rubocop/cop/layout/empty_line_after_guard_clause.rb
263
260
  - lib/rubocop/cop/layout/empty_line_after_magic_comment.rb
261
+ - lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb
264
262
  - lib/rubocop/cop/layout/empty_line_between_defs.rb
265
263
  - lib/rubocop/cop/layout/empty_lines.rb
266
264
  - lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb
@@ -343,6 +341,7 @@ files:
343
341
  - lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb
344
342
  - lib/rubocop/cop/lint/boolean_symbol.rb
345
343
  - lib/rubocop/cop/lint/circular_argument_reference.rb
344
+ - lib/rubocop/cop/lint/constant_definition_in_block.rb
346
345
  - lib/rubocop/cop/lint/constant_resolution.rb
347
346
  - lib/rubocop/cop/lint/debugger.rb
348
347
  - lib/rubocop/cop/lint/deprecated_class_methods.rb
@@ -352,12 +351,14 @@ files:
352
351
  - lib/rubocop/cop/lint/duplicate_elsif_condition.rb
353
352
  - lib/rubocop/cop/lint/duplicate_hash_key.rb
354
353
  - lib/rubocop/cop/lint/duplicate_methods.rb
354
+ - lib/rubocop/cop/lint/duplicate_require.rb
355
355
  - lib/rubocop/cop/lint/duplicate_rescue_exception.rb
356
356
  - lib/rubocop/cop/lint/each_with_object_argument.rb
357
357
  - lib/rubocop/cop/lint/else_layout.rb
358
358
  - lib/rubocop/cop/lint/empty_conditional_body.rb
359
359
  - lib/rubocop/cop/lint/empty_ensure.rb
360
360
  - lib/rubocop/cop/lint/empty_expression.rb
361
+ - lib/rubocop/cop/lint/empty_file.rb
361
362
  - lib/rubocop/cop/lint/empty_interpolation.rb
362
363
  - lib/rubocop/cop/lint/empty_when.rb
363
364
  - lib/rubocop/cop/lint/ensure_return.rb
@@ -367,6 +368,7 @@ files:
367
368
  - lib/rubocop/cop/lint/float_out_of_range.rb
368
369
  - lib/rubocop/cop/lint/format_parameter_mismatch.rb
369
370
  - lib/rubocop/cop/lint/heredoc_method_call_position.rb
371
+ - lib/rubocop/cop/lint/identity_comparison.rb
370
372
  - lib/rubocop/cop/lint/implicit_string_concatenation.rb
371
373
  - lib/rubocop/cop/lint/ineffective_access_modifier.rb
372
374
  - lib/rubocop/cop/lint/inherit_exception.rb
@@ -417,6 +419,7 @@ files:
417
419
  - lib/rubocop/cop/lint/syntax.rb
418
420
  - lib/rubocop/cop/lint/to_json.rb
419
421
  - lib/rubocop/cop/lint/top_level_return_with_argument.rb
422
+ - lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb
420
423
  - lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb
421
424
  - lib/rubocop/cop/lint/unified_integer.rb
422
425
  - lib/rubocop/cop/lint/unreachable_code.rb
@@ -428,7 +431,9 @@ files:
428
431
  - lib/rubocop/cop/lint/useless_access_modifier.rb
429
432
  - lib/rubocop/cop/lint/useless_assignment.rb
430
433
  - lib/rubocop/cop/lint/useless_else_without_rescue.rb
434
+ - lib/rubocop/cop/lint/useless_method_definition.rb
431
435
  - lib/rubocop/cop/lint/useless_setter_call.rb
436
+ - lib/rubocop/cop/lint/useless_times.rb
432
437
  - lib/rubocop/cop/lint/void.rb
433
438
  - lib/rubocop/cop/message_annotator.rb
434
439
  - lib/rubocop/cop/metrics/abc_size.rb
@@ -454,6 +459,7 @@ files:
454
459
  - lib/rubocop/cop/mixin/check_assignment.rb
455
460
  - lib/rubocop/cop/mixin/check_line_breakable.rb
456
461
  - lib/rubocop/cop/mixin/code_length.rb
462
+ - lib/rubocop/cop/mixin/comments_help.rb
457
463
  - lib/rubocop/cop/mixin/configurable_enforced_style.rb
458
464
  - lib/rubocop/cop/mixin/configurable_formatting.rb
459
465
  - lib/rubocop/cop/mixin/configurable_max.rb
@@ -554,10 +560,12 @@ files:
554
560
  - lib/rubocop/cop/style/class_and_module_children.rb
555
561
  - lib/rubocop/cop/style/class_check.rb
556
562
  - lib/rubocop/cop/style/class_methods.rb
563
+ - lib/rubocop/cop/style/class_methods_definitions.rb
557
564
  - lib/rubocop/cop/style/class_vars.rb
558
565
  - lib/rubocop/cop/style/collection_methods.rb
559
566
  - lib/rubocop/cop/style/colon_method_call.rb
560
567
  - lib/rubocop/cop/style/colon_method_definition.rb
568
+ - lib/rubocop/cop/style/combinable_loops.rb
561
569
  - lib/rubocop/cop/style/command_literal.rb
562
570
  - lib/rubocop/cop/style/comment_annotation.rb
563
571
  - lib/rubocop/cop/style/commented_keyword.rb
@@ -611,6 +619,7 @@ files:
611
619
  - lib/rubocop/cop/style/inline_comment.rb
612
620
  - lib/rubocop/cop/style/inverse_methods.rb
613
621
  - lib/rubocop/cop/style/ip_addresses.rb
622
+ - lib/rubocop/cop/style/keyword_parameters_order.rb
614
623
  - lib/rubocop/cop/style/lambda.rb
615
624
  - lib/rubocop/cop/style/lambda_call.rb
616
625
  - lib/rubocop/cop/style/line_end_concatenation.rb
@@ -678,6 +687,7 @@ files:
678
687
  - lib/rubocop/cop/style/redundant_regexp_escape.rb
679
688
  - lib/rubocop/cop/style/redundant_return.rb
680
689
  - lib/rubocop/cop/style/redundant_self.rb
690
+ - lib/rubocop/cop/style/redundant_self_assignment.rb
681
691
  - lib/rubocop/cop/style/redundant_sort.rb
682
692
  - lib/rubocop/cop/style/redundant_sort_by.rb
683
693
  - lib/rubocop/cop/style/regexp_literal.rb
@@ -694,6 +704,7 @@ files:
694
704
  - lib/rubocop/cop/style/single_line_block_params.rb
695
705
  - lib/rubocop/cop/style/single_line_methods.rb
696
706
  - lib/rubocop/cop/style/slicing_with_range.rb
707
+ - lib/rubocop/cop/style/sole_nested_conditional.rb
697
708
  - lib/rubocop/cop/style/special_global_vars.rb
698
709
  - lib/rubocop/cop/style/stabby_lambda_parentheses.rb
699
710
  - lib/rubocop/cop/style/stderr_puts.rb
@@ -728,7 +739,6 @@ files:
728
739
  - lib/rubocop/cop/style/yoda_condition.rb
729
740
  - lib/rubocop/cop/style/zero_length_predicate.rb
730
741
  - lib/rubocop/cop/team.rb
731
- - lib/rubocop/cop/tokens_util.rb
732
742
  - lib/rubocop/cop/util.rb
733
743
  - lib/rubocop/cop/utils/format_string.rb
734
744
  - lib/rubocop/cop/variable_force.rb
@@ -741,8 +751,10 @@ files:
741
751
  - lib/rubocop/cop/variable_force/variable_table.rb
742
752
  - lib/rubocop/cops_documentation_generator.rb
743
753
  - lib/rubocop/core_ext/string.rb
754
+ - lib/rubocop/directive_comment.rb
744
755
  - lib/rubocop/error.rb
745
756
  - lib/rubocop/ext/processed_source.rb
757
+ - lib/rubocop/ext/regexp_node.rb
746
758
  - lib/rubocop/file_finder.rb
747
759
  - lib/rubocop/formatter/auto_gen_config_formatter.rb
748
760
  - lib/rubocop/formatter/base_formatter.rb
@@ -791,7 +803,7 @@ metadata:
791
803
  homepage_uri: https://rubocop.org/
792
804
  changelog_uri: https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md
793
805
  source_code_uri: https://github.com/rubocop-hq/rubocop/
794
- documentation_uri: https://docs.rubocop.org/
806
+ documentation_uri: https://docs.rubocop.org/rubocop/0.92/
795
807
  bug_tracker_uri: https://github.com/rubocop-hq/rubocop/issues
796
808
  post_install_message:
797
809
  rdoc_options: []