rubocop 0.85.1 → 0.89.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (357) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -4
  3. data/bin/rubocop-profile +32 -0
  4. data/config/default.yml +227 -26
  5. data/lib/rubocop.rb +33 -5
  6. data/lib/rubocop/cli.rb +2 -4
  7. data/lib/rubocop/cli/command/auto_genenerate_config.rb +42 -7
  8. data/lib/rubocop/cli/command/base.rb +1 -0
  9. data/lib/rubocop/cli/command/execute_runner.rb +1 -1
  10. data/lib/rubocop/cli/command/init_dotfile.rb +1 -1
  11. data/lib/rubocop/cli/command/show_cops.rb +2 -2
  12. data/lib/rubocop/cli/command/version.rb +2 -2
  13. data/lib/rubocop/comment_config.rb +2 -2
  14. data/lib/rubocop/config.rb +20 -3
  15. data/lib/rubocop/config_loader.rb +40 -68
  16. data/lib/rubocop/config_loader_resolver.rb +4 -4
  17. data/lib/rubocop/config_obsoletion.rb +6 -2
  18. data/lib/rubocop/config_store.rb +4 -0
  19. data/lib/rubocop/config_validator.rb +1 -3
  20. data/lib/rubocop/cop/autocorrect_logic.rb +14 -24
  21. data/lib/rubocop/cop/badge.rb +1 -1
  22. data/lib/rubocop/cop/base.rb +407 -0
  23. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +10 -20
  24. data/lib/rubocop/cop/commissioner.rb +47 -50
  25. data/lib/rubocop/cop/cop.rb +85 -236
  26. data/lib/rubocop/cop/corrector.rb +38 -115
  27. data/lib/rubocop/cop/correctors/line_break_corrector.rb +3 -3
  28. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +26 -0
  29. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
  30. data/lib/rubocop/cop/correctors/punctuation_corrector.rb +1 -1
  31. data/lib/rubocop/cop/correctors/unused_arg_corrector.rb +15 -18
  32. data/lib/rubocop/cop/force.rb +1 -0
  33. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +39 -13
  34. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +1 -1
  35. data/lib/rubocop/cop/generator.rb +1 -1
  36. data/lib/rubocop/cop/generator/configuration_injector.rb +3 -3
  37. data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +4 -12
  38. data/lib/rubocop/cop/internal_affairs/node_destructuring.rb +1 -1
  39. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +11 -14
  40. data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +8 -8
  41. data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +10 -7
  42. data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +7 -8
  43. data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +2 -2
  44. data/lib/rubocop/cop/layout/block_alignment.rb +1 -1
  45. data/lib/rubocop/cop/layout/case_indentation.rb +18 -19
  46. data/lib/rubocop/cop/layout/class_structure.rb +2 -37
  47. data/lib/rubocop/cop/layout/comment_indentation.rb +3 -3
  48. data/lib/rubocop/cop/layout/empty_comment.rb +1 -1
  49. data/lib/rubocop/cop/layout/empty_lines.rb +0 -2
  50. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +1 -0
  51. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +3 -8
  52. data/lib/rubocop/cop/layout/end_alignment.rb +3 -2
  53. data/lib/rubocop/cop/layout/end_of_line.rb +1 -1
  54. data/lib/rubocop/cop/layout/extra_spacing.rb +9 -16
  55. data/lib/rubocop/cop/layout/first_argument_indentation.rb +5 -1
  56. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +1 -1
  57. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +1 -1
  58. data/lib/rubocop/cop/layout/hash_alignment.rb +2 -3
  59. data/lib/rubocop/cop/layout/heredoc_indentation.rb +2 -2
  60. data/lib/rubocop/cop/layout/indentation_style.rb +0 -2
  61. data/lib/rubocop/cop/layout/multiline_block_layout.rb +17 -7
  62. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +1 -1
  63. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +0 -2
  64. data/lib/rubocop/cop/layout/space_after_colon.rb +1 -1
  65. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +22 -27
  66. data/lib/rubocop/cop/layout/space_around_keyword.rb +2 -2
  67. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +33 -66
  68. data/lib/rubocop/cop/layout/space_around_operators.rb +1 -1
  69. data/lib/rubocop/cop/layout/space_before_block_braces.rb +14 -0
  70. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +4 -3
  71. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -1
  72. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +2 -2
  73. data/lib/rubocop/cop/legacy/corrections_proxy.rb +49 -0
  74. data/lib/rubocop/cop/legacy/corrector.rb +29 -0
  75. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +7 -4
  76. data/lib/rubocop/cop/lint/ambiguous_operator.rb +15 -10
  77. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +11 -13
  78. data/lib/rubocop/cop/lint/assignment_in_condition.rb +2 -2
  79. data/lib/rubocop/cop/lint/big_decimal_new.rb +10 -10
  80. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +49 -0
  81. data/lib/rubocop/cop/lint/boolean_symbol.rb +16 -11
  82. data/lib/rubocop/cop/lint/circular_argument_reference.rb +1 -1
  83. data/lib/rubocop/cop/lint/constant_resolution.rb +89 -0
  84. data/lib/rubocop/cop/lint/debugger.rb +7 -1
  85. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +9 -10
  86. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +21 -17
  87. data/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb +8 -2
  88. data/lib/rubocop/cop/lint/duplicate_case_condition.rb +1 -1
  89. data/lib/rubocop/cop/lint/duplicate_elsif_condition.rb +39 -0
  90. data/lib/rubocop/cop/lint/duplicate_hash_key.rb +1 -1
  91. data/lib/rubocop/cop/lint/duplicate_methods.rb +9 -6
  92. data/lib/rubocop/cop/lint/duplicate_rescue_exception.rb +60 -0
  93. data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -1
  94. data/lib/rubocop/cop/lint/else_layout.rb +1 -1
  95. data/lib/rubocop/cop/lint/empty_conditional_body.rb +67 -0
  96. data/lib/rubocop/cop/lint/empty_ensure.rb +5 -5
  97. data/lib/rubocop/cop/lint/empty_expression.rb +2 -2
  98. data/lib/rubocop/cop/lint/empty_interpolation.rb +5 -6
  99. data/lib/rubocop/cop/lint/empty_when.rb +2 -2
  100. data/lib/rubocop/cop/lint/ensure_return.rb +27 -29
  101. data/lib/rubocop/cop/lint/erb_new_arguments.rb +11 -10
  102. data/lib/rubocop/cop/lint/flip_flop.rb +1 -1
  103. data/lib/rubocop/cop/lint/float_comparison.rb +93 -0
  104. data/lib/rubocop/cop/lint/float_out_of_range.rb +2 -2
  105. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +11 -5
  106. data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +13 -14
  107. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +5 -4
  108. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +8 -8
  109. data/lib/rubocop/cop/lint/inherit_exception.rb +12 -7
  110. data/lib/rubocop/cop/lint/interpolation_check.rb +21 -5
  111. data/lib/rubocop/cop/lint/literal_as_condition.rb +14 -2
  112. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +7 -7
  113. data/lib/rubocop/cop/lint/loop.rb +23 -2
  114. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +6 -5
  115. data/lib/rubocop/cop/lint/missing_super.rb +99 -0
  116. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +1 -1
  117. data/lib/rubocop/cop/lint/multiple_comparison.rb +6 -9
  118. data/lib/rubocop/cop/lint/nested_method_definition.rb +15 -21
  119. data/lib/rubocop/cop/lint/nested_percent_literal.rb +1 -1
  120. data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
  121. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +84 -13
  122. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +2 -2
  123. data/lib/rubocop/cop/lint/number_conversion.rb +6 -9
  124. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +11 -13
  125. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +61 -0
  126. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +12 -13
  127. data/lib/rubocop/cop/lint/percent_string_array.rb +14 -13
  128. data/lib/rubocop/cop/lint/percent_symbol_array.rb +14 -13
  129. data/lib/rubocop/cop/lint/raise_exception.rb +15 -5
  130. data/lib/rubocop/cop/lint/rand_one.rb +3 -3
  131. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +31 -25
  132. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +7 -11
  133. data/lib/rubocop/cop/lint/redundant_require_statement.rb +4 -7
  134. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +15 -11
  135. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +6 -13
  136. data/lib/rubocop/cop/lint/redundant_with_index.rb +11 -14
  137. data/lib/rubocop/cop/lint/redundant_with_object.rb +11 -14
  138. data/lib/rubocop/cop/lint/regexp_as_condition.rb +6 -2
  139. data/lib/rubocop/cop/lint/require_parentheses.rb +2 -2
  140. data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
  141. data/lib/rubocop/cop/lint/rescue_type.rb +8 -8
  142. data/lib/rubocop/cop/lint/return_in_void_context.rb +2 -4
  143. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +3 -6
  144. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +14 -10
  145. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +10 -2
  146. data/lib/rubocop/cop/lint/script_permission.rb +10 -7
  147. data/lib/rubocop/cop/lint/self_assignment.rb +78 -0
  148. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +5 -11
  149. data/lib/rubocop/cop/lint/shadowed_argument.rb +3 -3
  150. data/lib/rubocop/cop/lint/shadowed_exception.rb +2 -2
  151. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +3 -3
  152. data/lib/rubocop/cop/lint/struct_new_override.rb +1 -1
  153. data/lib/rubocop/cop/lint/suppressed_exception.rb +4 -7
  154. data/lib/rubocop/cop/lint/syntax.rb +11 -26
  155. data/lib/rubocop/cop/lint/to_json.rb +4 -6
  156. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +34 -0
  157. data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +4 -4
  158. data/lib/rubocop/cop/lint/unified_integer.rb +4 -6
  159. data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
  160. data/lib/rubocop/cop/lint/unreachable_loop.rb +174 -0
  161. data/lib/rubocop/cop/lint/unused_block_argument.rb +8 -3
  162. data/lib/rubocop/cop/lint/unused_method_argument.rb +9 -4
  163. data/lib/rubocop/cop/lint/uri_escape_unescape.rb +1 -1
  164. data/lib/rubocop/cop/lint/uri_regexp.rb +11 -31
  165. data/lib/rubocop/cop/lint/useless_access_modifier.rb +26 -16
  166. data/lib/rubocop/cop/lint/useless_assignment.rb +4 -4
  167. data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +6 -15
  168. data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -6
  169. data/lib/rubocop/cop/lint/void.rb +3 -7
  170. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  171. data/lib/rubocop/cop/metrics/block_length.rb +24 -2
  172. data/lib/rubocop/cop/metrics/block_nesting.rb +2 -2
  173. data/lib/rubocop/cop/metrics/class_length.rb +26 -3
  174. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +37 -4
  175. data/lib/rubocop/cop/metrics/method_length.rb +25 -2
  176. data/lib/rubocop/cop/metrics/module_length.rb +26 -3
  177. data/lib/rubocop/cop/metrics/parameter_lists.rb +2 -6
  178. data/lib/rubocop/cop/metrics/perceived_complexity.rb +7 -8
  179. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +47 -4
  180. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +157 -0
  181. data/lib/rubocop/cop/metrics/utils/iterating_block.rb +61 -0
  182. data/lib/rubocop/cop/metrics/utils/repeated_csend_discount.rb +37 -0
  183. data/lib/rubocop/cop/migration/department_name.rb +13 -15
  184. data/lib/rubocop/cop/mixin/allowed_methods.rb +19 -0
  185. data/lib/rubocop/cop/mixin/array_min_size.rb +1 -1
  186. data/lib/rubocop/cop/mixin/auto_corrector.rb +12 -0
  187. data/lib/rubocop/cop/mixin/check_line_breakable.rb +1 -1
  188. data/lib/rubocop/cop/mixin/code_length.rb +26 -5
  189. data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -1
  190. data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
  191. data/lib/rubocop/cop/mixin/documentation_comment.rb +2 -2
  192. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
  193. data/lib/rubocop/cop/mixin/enforce_superclass.rb +5 -1
  194. data/lib/rubocop/cop/mixin/first_element_line_break.rb +1 -1
  195. data/lib/rubocop/cop/mixin/method_complexity.rb +10 -2
  196. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -1
  197. data/lib/rubocop/cop/mixin/nil_methods.rb +3 -5
  198. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +6 -1
  199. data/lib/rubocop/cop/mixin/parentheses.rb +1 -2
  200. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
  201. data/lib/rubocop/cop/mixin/range_help.rb +1 -1
  202. data/lib/rubocop/cop/mixin/regexp_literal_help.rb +27 -0
  203. data/lib/rubocop/cop/mixin/statement_modifier.rb +38 -9
  204. data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -1
  205. data/lib/rubocop/cop/mixin/surrounding_space.rb +7 -27
  206. data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
  207. data/lib/rubocop/cop/mixin/uncommunicative_name.rb +12 -17
  208. data/lib/rubocop/cop/mixin/unused_argument.rb +4 -6
  209. data/lib/rubocop/cop/mixin/visibility_help.rb +50 -0
  210. data/lib/rubocop/cop/naming/accessor_method_name.rb +4 -2
  211. data/lib/rubocop/cop/naming/ascii_identifiers.rb +29 -6
  212. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +4 -4
  213. data/lib/rubocop/cop/naming/block_parameter_name.rb +1 -1
  214. data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +2 -2
  215. data/lib/rubocop/cop/naming/constant_name.rb +2 -2
  216. data/lib/rubocop/cop/naming/file_name.rb +4 -6
  217. data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +2 -2
  218. data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +3 -3
  219. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +2 -2
  220. data/lib/rubocop/cop/naming/method_name.rb +1 -1
  221. data/lib/rubocop/cop/naming/method_parameter_name.rb +2 -2
  222. data/lib/rubocop/cop/naming/predicate_name.rb +6 -10
  223. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +12 -11
  224. data/lib/rubocop/cop/naming/variable_name.rb +1 -1
  225. data/lib/rubocop/cop/naming/variable_number.rb +1 -1
  226. data/lib/rubocop/cop/offense.rb +16 -2
  227. data/lib/rubocop/cop/registry.rb +3 -3
  228. data/lib/rubocop/cop/security/eval.rb +2 -2
  229. data/lib/rubocop/cop/security/json_load.rb +6 -8
  230. data/lib/rubocop/cop/security/marshal_load.rb +2 -4
  231. data/lib/rubocop/cop/security/open.rb +2 -2
  232. data/lib/rubocop/cop/security/yaml_load.rb +6 -6
  233. data/lib/rubocop/cop/style/access_modifier_declarations.rb +11 -1
  234. data/lib/rubocop/cop/style/accessor_grouping.rb +149 -0
  235. data/lib/rubocop/cop/style/alias.rb +7 -3
  236. data/lib/rubocop/cop/style/array_coercion.rb +63 -0
  237. data/lib/rubocop/cop/style/auto_resource_cleanup.rb +3 -2
  238. data/lib/rubocop/cop/style/bare_percent_literals.rb +1 -1
  239. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +144 -0
  240. data/lib/rubocop/cop/style/block_delimiters.rb +2 -4
  241. data/lib/rubocop/cop/style/case_equality.rb +22 -3
  242. data/lib/rubocop/cop/style/case_like_if.rb +217 -0
  243. data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
  244. data/lib/rubocop/cop/style/class_vars.rb +21 -0
  245. data/lib/rubocop/cop/style/colon_method_call.rb +3 -3
  246. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  247. data/lib/rubocop/cop/style/commented_keyword.rb +5 -2
  248. data/lib/rubocop/cop/style/conditional_assignment.rb +11 -2
  249. data/lib/rubocop/cop/style/copyright.rb +3 -3
  250. data/lib/rubocop/cop/style/date_time.rb +1 -1
  251. data/lib/rubocop/cop/style/dir.rb +2 -2
  252. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +1 -1
  253. data/lib/rubocop/cop/style/documentation.rb +6 -6
  254. data/lib/rubocop/cop/style/each_with_object.rb +0 -2
  255. data/lib/rubocop/cop/style/empty_case_condition.rb +8 -6
  256. data/lib/rubocop/cop/style/empty_literal.rb +5 -5
  257. data/lib/rubocop/cop/style/empty_method.rb +5 -5
  258. data/lib/rubocop/cop/style/encoding.rb +1 -1
  259. data/lib/rubocop/cop/style/eval_with_location.rb +4 -0
  260. data/lib/rubocop/cop/style/expand_path_arguments.rb +6 -2
  261. data/lib/rubocop/cop/style/explicit_block_argument.rb +102 -0
  262. data/lib/rubocop/cop/style/exponential_notation.rb +8 -10
  263. data/lib/rubocop/cop/style/float_division.rb +7 -10
  264. data/lib/rubocop/cop/style/format_string.rb +4 -0
  265. data/lib/rubocop/cop/style/format_string_token.rb +6 -5
  266. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
  267. data/lib/rubocop/cop/style/global_std_stream.rb +65 -0
  268. data/lib/rubocop/cop/style/guard_clause.rb +2 -2
  269. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +69 -0
  270. data/lib/rubocop/cop/style/hash_like_case.rb +76 -0
  271. data/lib/rubocop/cop/style/hash_syntax.rb +6 -3
  272. data/lib/rubocop/cop/style/identical_conditional_branches.rb +1 -1
  273. data/lib/rubocop/cop/style/if_unless_modifier.rb +8 -28
  274. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +12 -0
  275. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  276. data/lib/rubocop/cop/style/inverse_methods.rb +3 -4
  277. data/lib/rubocop/cop/style/ip_addresses.rb +1 -1
  278. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +5 -0
  279. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +1 -1
  280. data/lib/rubocop/cop/style/missing_else.rb +1 -11
  281. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +9 -2
  282. data/lib/rubocop/cop/style/multiline_block_chain.rb +10 -1
  283. data/lib/rubocop/cop/style/multiline_if_then.rb +1 -1
  284. data/lib/rubocop/cop/style/multiline_memoization.rb +2 -2
  285. data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -1
  286. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +17 -6
  287. data/lib/rubocop/cop/style/mutable_constant.rb +4 -4
  288. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +2 -5
  289. data/lib/rubocop/cop/style/nested_ternary_operator.rb +27 -0
  290. data/lib/rubocop/cop/style/next.rb +2 -2
  291. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +2 -2
  292. data/lib/rubocop/cop/style/numeric_predicate.rb +7 -4
  293. data/lib/rubocop/cop/style/optional_boolean_parameter.rb +42 -0
  294. data/lib/rubocop/cop/style/parallel_assignment.rb +5 -5
  295. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -2
  296. data/lib/rubocop/cop/style/proc.rb +1 -1
  297. data/lib/rubocop/cop/style/random_with_offset.rb +5 -10
  298. data/lib/rubocop/cop/style/redundant_assignment.rb +117 -0
  299. data/lib/rubocop/cop/style/redundant_condition.rb +15 -3
  300. data/lib/rubocop/cop/style/redundant_exception.rb +18 -10
  301. data/lib/rubocop/cop/style/redundant_fetch_block.rb +122 -0
  302. data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +50 -0
  303. data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
  304. data/lib/rubocop/cop/style/redundant_parentheses.rb +8 -2
  305. data/lib/rubocop/cop/style/redundant_percent_q.rb +2 -2
  306. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +4 -3
  307. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +23 -32
  308. data/lib/rubocop/cop/style/redundant_self.rb +6 -9
  309. data/lib/rubocop/cop/style/redundant_sort.rb +28 -12
  310. data/lib/rubocop/cop/style/rescue_standard_error.rb +1 -1
  311. data/lib/rubocop/cop/style/sample.rb +1 -1
  312. data/lib/rubocop/cop/style/semicolon.rb +1 -1
  313. data/lib/rubocop/cop/style/signal_exception.rb +3 -1
  314. data/lib/rubocop/cop/style/single_argument_dig.rb +54 -0
  315. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +3 -2
  316. data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
  317. data/lib/rubocop/cop/style/string_concatenation.rb +92 -0
  318. data/lib/rubocop/cop/style/struct_inheritance.rb +23 -2
  319. data/lib/rubocop/cop/style/symbol_array.rb +6 -6
  320. data/lib/rubocop/cop/style/symbol_proc.rb +2 -2
  321. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
  322. data/lib/rubocop/cop/style/trailing_method_end_statement.rb +9 -32
  323. data/lib/rubocop/cop/style/trivial_accessors.rb +8 -7
  324. data/lib/rubocop/cop/style/word_array.rb +1 -1
  325. data/lib/rubocop/cop/style/yoda_condition.rb +18 -1
  326. data/lib/rubocop/cop/style/zero_length_predicate.rb +12 -8
  327. data/lib/rubocop/cop/team.rb +98 -82
  328. data/lib/rubocop/cop/tokens_util.rb +84 -0
  329. data/lib/rubocop/cop/util.rb +3 -15
  330. data/lib/rubocop/cop/utils/format_string.rb +2 -3
  331. data/lib/rubocop/cop/variable_force.rb +0 -2
  332. data/lib/rubocop/cop/variable_force/branch.rb +1 -0
  333. data/lib/rubocop/cop/variable_force/variable.rb +7 -5
  334. data/lib/rubocop/cops_documentation_generator.rb +282 -0
  335. data/lib/rubocop/error.rb +1 -0
  336. data/lib/rubocop/file_finder.rb +12 -12
  337. data/lib/rubocop/formatter/disabled_config_formatter.rb +2 -2
  338. data/lib/rubocop/formatter/formatter_set.rb +2 -1
  339. data/lib/rubocop/name_similarity.rb +7 -3
  340. data/lib/rubocop/options.rb +15 -8
  341. data/lib/rubocop/path_util.rb +19 -19
  342. data/lib/rubocop/platform.rb +1 -1
  343. data/lib/rubocop/rake_task.rb +7 -9
  344. data/lib/rubocop/result_cache.rb +12 -8
  345. data/lib/rubocop/rspec/cop_helper.rb +4 -4
  346. data/lib/rubocop/rspec/expect_offense.rb +63 -22
  347. data/lib/rubocop/rspec/shared_contexts.rb +19 -16
  348. data/lib/rubocop/runner.rb +34 -33
  349. data/lib/rubocop/target_finder.rb +14 -11
  350. data/lib/rubocop/target_ruby.rb +2 -2
  351. data/lib/rubocop/version.rb +2 -2
  352. metadata +49 -11
  353. data/lib/rubocop/cop/lint/useless_comparison.rb +0 -28
  354. data/lib/rubocop/cop/mixin/classish_length.rb +0 -37
  355. data/lib/rubocop/cop/mixin/parser_diagnostic.rb +0 -37
  356. data/lib/rubocop/cop/mixin/too_many_lines.rb +0 -35
  357. data/lib/rubocop/cop/style/method_missing_super.rb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86b240fb0a653934db99c6ca12a1c53976c01f3d6de666842e9f7146f207f725
4
- data.tar.gz: 606ea84dc8c148971ba8a2dc17ef2a03bbb48802e6053f5042d180e0f6c7c15f
3
+ metadata.gz: 220e683b0838a3b02076023d5a65ff57267b1eff2c250bb8fa65d03db9ff09ec
4
+ data.tar.gz: 8fd50157ec4a8a007ab30cfb5ea34dd9b30bf4d6fa8c3d475268f73e2937bd99
5
5
  SHA512:
6
- metadata.gz: 4e6a817ec287b216c15e8820e29192fe1152fa77bb9b6fb9377f7a9b1bc22faef07e15c1f025691107914ae211f401549ef831c755fbf6b9c21bd04198388742
7
- data.tar.gz: 2e3a6b4d35e5b24a9542ac5749247537ae2a47db242e86a189d3f719f7b1d35568eb22deaf491b2f5d1408de8415b2ee86fadfe8a56f229fbce89686744cc5e4
6
+ metadata.gz: fb33582bad5b4b07308a11670c8fc173db0261e384160727057e8714f2dfb24d552663e0e14a5be1ad537bc269919e0182b2a1ca63f6ee13f471a422cae98fff
7
+ data.tar.gz: 214a09139a2a0c85438e2724d289e3fb5e8e1b4d81e6a42231143803842423795867c9da4e0347df1b26e5dfaeaf108d347a1e4758a8604484e370a3e1343a74
data/README.md CHANGED
@@ -3,12 +3,12 @@
3
3
  </p>
4
4
 
5
5
  ----------
6
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
6
7
  [![Gem Version](https://badge.fury.io/rb/rubocop.svg)](https://badge.fury.io/rb/rubocop)
7
8
  [![CircleCI Status](https://circleci.com/gh/rubocop-hq/rubocop/tree/master.svg?style=svg)](https://circleci.com/gh/rubocop-hq/rubocop/tree/master)
8
9
  [![Actions Status](https://github.com/rubocop-hq/rubocop/workflows/CI/badge.svg?branch=master)](https://github.com/rubocop-hq/rubocop/actions?query=workflow%3ACI)
9
- [![Coverage Status](https://api.codeclimate.com/v1/badges/ad6e76460499c8c99697/test_coverage)](https://codeclimate.com/github/bbatsov/rubocop)
10
- [![Code Climate](https://codeclimate.com/github/bbatsov/rubocop/badges/gpa.svg)](https://codeclimate.com/github/bbatsov/rubocop)
11
- [![Inline docs](https://inch-ci.org/github/bbatsov/rubocop.svg)](https://inch-ci.org/github/bbatsov/rubocop)
10
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/test_coverage)](https://codeclimate.com/github/rubocop-hq/rubocop/test_coverage)
11
+ [![Maintainability](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/maintainability)](https://codeclimate.com/github/rubocop-hq/rubocop/maintainability)
12
12
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=rubocop&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=rubocop&package-manager=bundler&version-scheme=semver)
13
13
 
14
14
  [![Patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://www.patreon.com/bbatsov)
@@ -49,7 +49,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
49
49
  might want to use a conservative version lock in your `Gemfile`:
50
50
 
51
51
  ```rb
52
- gem 'rubocop', '~> 0.85.1', require: false
52
+ gem 'rubocop', '~> 0.89.0', require: false
53
53
  ```
54
54
 
55
55
  ## Quickstart
@@ -72,6 +72,16 @@ RuboCop supports the following Ruby implementations:
72
72
  * MRI 2.4+
73
73
  * JRuby 9.2+
74
74
 
75
+ See [compatibility](https://docs.rubocop.org/rubocop/compatibility.html) for further details.
76
+
77
+ ## Readme Badge
78
+
79
+ If you use RuboCop in your project, you can include one of these badges in your readme to let people know that your code is written following the community Ruby Style Guide.
80
+
81
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
82
+
83
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)
84
+
75
85
  ## Team
76
86
 
77
87
  Here's a list of RuboCop's core developers:
@@ -84,6 +94,8 @@ Here's a list of RuboCop's core developers:
84
94
  * [Masataka Kuwabara](https://github.com/pocke)
85
95
  * [Koichi Ito](https://github.com/koic)
86
96
  * [Maxim Krizhanovski](https://github.com/darhazer)
97
+ * [Benjamin Quorning](https://github.com/bquorning)
98
+ * [Marc-André Lafortune](https://github.com/marcandre)
87
99
 
88
100
  ## Logo
89
101
 
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ if ARGV.include?('-h') || ARGV.include?('--help')
5
+ puts "Usage: same as main `rubocop` command but gathers profiling info"
6
+ puts "Additional option: `--memory` to print memory usage"
7
+ exit(0)
8
+ end
9
+ with_mem = ARGV.delete('--memory')
10
+ ARGV.unshift '--cache', 'false' unless ARGV.include?('--cache')
11
+
12
+ require 'stackprof'
13
+ if with_mem
14
+ require 'memory_profiler'
15
+ MemoryProfiler.start
16
+ end
17
+ StackProf.start
18
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
19
+ begin
20
+ load "#{__dir__}/../exe/rubocop"
21
+ ensure
22
+ delta = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
23
+ puts "Finished in #{delta.round(1)} seconds"
24
+ StackProf.stop
25
+ if with_mem
26
+ puts "Building memory report..."
27
+ report = MemoryProfiler.stop
28
+ end
29
+ Dir.mkdir('tmp') unless File.exist?('tmp')
30
+ StackProf.results('tmp/stackprof.dump')
31
+ report&.pretty_print(scale_bytes: true)
32
+ end
@@ -180,6 +180,9 @@ Bundler/OrderedGems:
180
180
  VersionAdded: '0.46'
181
181
  VersionChanged: '0.47'
182
182
  TreatCommentsAsGroupSeparators: true
183
+ # By default, "-" and "_" are ignored for order purposes.
184
+ # This can be overridden by setting this parameter to true.
185
+ ConsiderPunctuation: false
183
186
  Include:
184
187
  - '**/*.gemfile'
185
188
  - '**/Gemfile'
@@ -200,13 +203,17 @@ Gemspec/OrderedDependencies:
200
203
  Enabled: true
201
204
  VersionAdded: '0.51'
202
205
  TreatCommentsAsGroupSeparators: true
206
+ # By default, "-" and "_" are ignored for order purposes.
207
+ # This can be overridden by setting this parameter to true.
208
+ ConsiderPunctuation: false
203
209
  Include:
204
210
  - '**/*.gemspec'
205
211
 
206
212
  Gemspec/RequiredRubyVersion:
207
- Description: 'Checks that `required_ruby_version` of gemspec and `TargetRubyVersion` of .rubocop.yml are equal.'
213
+ Description: 'Checks that `required_ruby_version` of gemspec is specified and equal to `TargetRubyVersion` of .rubocop.yml.'
208
214
  Enabled: true
209
215
  VersionAdded: '0.52'
216
+ VersionChanged: '0.89'
210
217
  Include:
211
218
  - '**/*.gemspec'
212
219
 
@@ -1228,7 +1235,7 @@ Layout/SpaceInsideBlockBraces:
1228
1235
 
1229
1236
  Layout/SpaceInsideHashLiteralBraces:
1230
1237
  Description: "Use spaces inside hash literal braces - or don't."
1231
- StyleGuide: '#spaces-operators'
1238
+ StyleGuide: '#spaces-braces'
1232
1239
  Enabled: true
1233
1240
  VersionAdded: '0.49'
1234
1241
  EnforcedStyle: space
@@ -1349,6 +1356,12 @@ Lint/BigDecimalNew:
1349
1356
  Enabled: true
1350
1357
  VersionAdded: '0.53'
1351
1358
 
1359
+ Lint/BinaryOperatorWithIdenticalOperands:
1360
+ Description: 'This cop checks for places where binary operator has identical operands.'
1361
+ Enabled: pending
1362
+ Safe: false
1363
+ VersionAdded: '0.89'
1364
+
1352
1365
  Lint/BooleanSymbol:
1353
1366
  Description: 'Check for `:true` and `:false` symbols.'
1354
1367
  Enabled: true
@@ -1361,6 +1374,15 @@ Lint/CircularArgumentReference:
1361
1374
  Enabled: true
1362
1375
  VersionAdded: '0.33'
1363
1376
 
1377
+ Lint/ConstantResolution:
1378
+ Description: 'Check that constants are fully qualified with `::`.'
1379
+ Enabled: false
1380
+ VersionAdded: '0.86'
1381
+ # Restrict this cop to only looking at certain names
1382
+ Only: []
1383
+ # Restrict this cop from only looking at certain names
1384
+ Ignore: []
1385
+
1364
1386
  Lint/Debugger:
1365
1387
  Description: 'Check for debugger calls.'
1366
1388
  Enabled: true
@@ -1382,12 +1404,18 @@ Lint/DisjunctiveAssignmentInConstructor:
1382
1404
  Enabled: true
1383
1405
  Safe: false
1384
1406
  VersionAdded: '0.62'
1407
+ VersionChanged: '0.88'
1385
1408
 
1386
1409
  Lint/DuplicateCaseCondition:
1387
1410
  Description: 'Do not repeat values in case conditionals.'
1388
1411
  Enabled: true
1389
1412
  VersionAdded: '0.45'
1390
1413
 
1414
+ Lint/DuplicateElsifCondition:
1415
+ Description: 'Do not repeat conditions used in if `elsif`.'
1416
+ Enabled: 'pending'
1417
+ VersionAdded: '0.88'
1418
+
1391
1419
  Lint/DuplicateHashKey:
1392
1420
  Description: 'Check for duplicate keys in hash literals.'
1393
1421
  Enabled: true
@@ -1399,6 +1427,11 @@ Lint/DuplicateMethods:
1399
1427
  Enabled: true
1400
1428
  VersionAdded: '0.29'
1401
1429
 
1430
+ Lint/DuplicateRescueException:
1431
+ Description: 'Checks that there are no repeated exceptions used in `rescue` expressions.'
1432
+ Enabled: pending
1433
+ VersionAdded: '0.89'
1434
+
1402
1435
  Lint/EachWithObjectArgument:
1403
1436
  Description: 'Check for immutable argument given to each_with_object.'
1404
1437
  Enabled: true
@@ -1409,6 +1442,12 @@ Lint/ElseLayout:
1409
1442
  Enabled: true
1410
1443
  VersionAdded: '0.17'
1411
1444
 
1445
+ Lint/EmptyConditionalBody:
1446
+ Description: 'This cop checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1447
+ Enabled: 'pending'
1448
+ AllowComments: true
1449
+ VersionAdded: '0.89'
1450
+
1412
1451
  Lint/EmptyEnsure:
1413
1452
  Description: 'Checks for empty ensure block.'
1414
1453
  Enabled: true
@@ -1452,6 +1491,12 @@ Lint/FlipFlop:
1452
1491
  Enabled: true
1453
1492
  VersionAdded: '0.16'
1454
1493
 
1494
+ Lint/FloatComparison:
1495
+ Description: 'Checks for the presence of precise comparison of floating point numbers.'
1496
+ StyleGuide: '#float-comparison'
1497
+ Enabled: pending
1498
+ VersionAdded: '0.89'
1499
+
1455
1500
  Lint/FloatOutOfRange:
1456
1501
  Description: >-
1457
1502
  Catches floating-point literals too large or small for Ruby to
@@ -1499,7 +1544,9 @@ Lint/InheritException:
1499
1544
  Lint/InterpolationCheck:
1500
1545
  Description: 'Raise warning for interpolation in single q strs.'
1501
1546
  Enabled: true
1547
+ Safe: false
1502
1548
  VersionAdded: '0.50'
1549
+ VersionChanged: '0.87'
1503
1550
 
1504
1551
  Lint/LiteralAsCondition:
1505
1552
  Description: 'Checks of literals used in conditions.'
@@ -1519,6 +1566,7 @@ Lint/Loop:
1519
1566
  StyleGuide: '#loop-with-break'
1520
1567
  Enabled: true
1521
1568
  VersionAdded: '0.9'
1569
+ VersionChanged: '0.89'
1522
1570
 
1523
1571
  Lint/MissingCopEnableDirective:
1524
1572
  Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
@@ -1533,6 +1581,13 @@ Lint/MissingCopEnableDirective:
1533
1581
  # .inf for any size
1534
1582
  MaximumRangeSize: .inf
1535
1583
 
1584
+ Lint/MissingSuper:
1585
+ Description: >-
1586
+ This cop checks for the presence of constructors and lifecycle callbacks
1587
+ without calls to `super`'.
1588
+ Enabled: pending
1589
+ VersionAdded: '0.89'
1590
+
1536
1591
  Lint/MixedRegexpCaptureTypes:
1537
1592
  Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
1538
1593
  Enabled: pending
@@ -1585,6 +1640,12 @@ Lint/OrderedMagicComments:
1585
1640
  Enabled: true
1586
1641
  VersionAdded: '0.53'
1587
1642
 
1643
+ Lint/OutOfRangeRegexpRef:
1644
+ Description: 'Checks for out of range reference for Regexp because it always returns nil.'
1645
+ Enabled: pending
1646
+ Safe: false
1647
+ VersionAdded: '0.89'
1648
+
1588
1649
  Lint/ParenthesesAsGroupedExpression:
1589
1650
  Description: >-
1590
1651
  Checks for method calls with a space before the opening
@@ -1611,7 +1672,9 @@ Lint/RaiseException:
1611
1672
  Description: Checks for `raise` or `fail` statements which are raising `Exception` class.
1612
1673
  StyleGuide: '#raise-exception'
1613
1674
  Enabled: pending
1675
+ Safe: false
1614
1676
  VersionAdded: '0.81'
1677
+ VersionChanged: '0.86'
1615
1678
  AllowedImplicitNamespaces:
1616
1679
  - 'Gem'
1617
1680
 
@@ -1668,6 +1731,7 @@ Lint/RegexpAsCondition:
1668
1731
  The regexp literal matches `$_` implicitly.
1669
1732
  Enabled: true
1670
1733
  VersionAdded: '0.51'
1734
+ VersionChanged: '0.86'
1671
1735
 
1672
1736
  Lint/RequireParentheses:
1673
1737
  Description: >-
@@ -1724,6 +1788,7 @@ Lint/SafeNavigationWithEmpty:
1724
1788
  Description: 'Avoid `foo&.empty?` in conditionals.'
1725
1789
  Enabled: true
1726
1790
  VersionAdded: '0.62'
1791
+ VersionChanged: '0.87'
1727
1792
 
1728
1793
  Lint/ScriptPermission:
1729
1794
  Description: 'Grant script file execute permission.'
@@ -1731,6 +1796,11 @@ Lint/ScriptPermission:
1731
1796
  VersionAdded: '0.49'
1732
1797
  VersionChanged: '0.50'
1733
1798
 
1799
+ Lint/SelfAssignment:
1800
+ Description: 'Checks for self-assignments.'
1801
+ Enabled: pending
1802
+ VersionAdded: '0.89'
1803
+
1734
1804
  Lint/SendWithMixinArgument:
1735
1805
  Description: 'Checks for `send` method when using mixin.'
1736
1806
  Enabled: true
@@ -1781,6 +1851,11 @@ Lint/ToJSON:
1781
1851
  Enabled: true
1782
1852
  VersionAdded: '0.66'
1783
1853
 
1854
+ Lint/TopLevelReturnWithArgument:
1855
+ Description: 'This cop detects top level return statements with argument.'
1856
+ Enabled: 'pending'
1857
+ VersionAdded: '0.89'
1858
+
1784
1859
  Lint/UnderscorePrefixedVariableName:
1785
1860
  Description: 'Do not use prefix `_` for a variable that is used.'
1786
1861
  Enabled: true
@@ -1797,6 +1872,11 @@ Lint/UnreachableCode:
1797
1872
  Enabled: true
1798
1873
  VersionAdded: '0.9'
1799
1874
 
1875
+ Lint/UnreachableLoop:
1876
+ Description: 'This cop checks for loops that will have at most one iteration.'
1877
+ Enabled: pending
1878
+ VersionAdded: '0.89'
1879
+
1800
1880
  Lint/UnusedBlockArgument:
1801
1881
  Description: 'Checks for unused block arguments.'
1802
1882
  StyleGuide: '#underscore-unused-vars'
@@ -1846,11 +1926,6 @@ Lint/UselessAssignment:
1846
1926
  Enabled: true
1847
1927
  VersionAdded: '0.11'
1848
1928
 
1849
- Lint/UselessComparison:
1850
- Description: 'Checks for comparison of something with itself.'
1851
- Enabled: true
1852
- VersionAdded: '0.11'
1853
-
1854
1929
  Lint/UselessElseWithoutRescue:
1855
1930
  Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
1856
1931
  Enabled: true
@@ -1884,15 +1959,16 @@ Metrics/AbcSize:
1884
1959
  # The ABC size is a calculated magnitude, so this number can be an Integer or
1885
1960
  # a Float.
1886
1961
  IgnoredMethods: []
1887
- Max: 15
1962
+ Max: 17
1888
1963
 
1889
1964
  Metrics/BlockLength:
1890
1965
  Description: 'Avoid long blocks with many lines.'
1891
1966
  Enabled: true
1892
1967
  VersionAdded: '0.44'
1893
- VersionChanged: '0.66'
1968
+ VersionChanged: '0.87'
1894
1969
  CountComments: false # count full line comments?
1895
1970
  Max: 25
1971
+ CountAsOne: []
1896
1972
  ExcludedMethods:
1897
1973
  # By default, exclude the `#refine` method, as it tends to have larger
1898
1974
  # associated blocks.
@@ -1913,8 +1989,10 @@ Metrics/ClassLength:
1913
1989
  Description: 'Avoid classes longer than 100 lines of code.'
1914
1990
  Enabled: true
1915
1991
  VersionAdded: '0.25'
1992
+ VersionChanged: '0.87'
1916
1993
  CountComments: false # count full line comments?
1917
1994
  Max: 100
1995
+ CountAsOne: []
1918
1996
 
1919
1997
  # Avoid complex methods.
1920
1998
  Metrics/CyclomaticComplexity:
@@ -1925,24 +2003,27 @@ Metrics/CyclomaticComplexity:
1925
2003
  VersionAdded: '0.25'
1926
2004
  VersionChanged: '0.81'
1927
2005
  IgnoredMethods: []
1928
- Max: 6
2006
+ Max: 7
1929
2007
 
1930
2008
  Metrics/MethodLength:
1931
2009
  Description: 'Avoid methods longer than 10 lines of code.'
1932
2010
  StyleGuide: '#short-methods'
1933
2011
  Enabled: true
1934
2012
  VersionAdded: '0.25'
1935
- VersionChanged: '0.59.2'
2013
+ VersionChanged: '0.87'
1936
2014
  CountComments: false # count full line comments?
1937
2015
  Max: 10
2016
+ CountAsOne: []
1938
2017
  ExcludedMethods: []
1939
2018
 
1940
2019
  Metrics/ModuleLength:
1941
2020
  Description: 'Avoid modules longer than 100 lines of code.'
1942
2021
  Enabled: true
1943
2022
  VersionAdded: '0.31'
2023
+ VersionChanged: '0.87'
1944
2024
  CountComments: false # count full line comments?
1945
2025
  Max: 100
2026
+ CountAsOne: []
1946
2027
 
1947
2028
  Metrics/ParameterLists:
1948
2029
  Description: 'Avoid parameter lists longer than three or four parameters.'
@@ -1960,7 +2041,7 @@ Metrics/PerceivedComplexity:
1960
2041
  VersionAdded: '0.25'
1961
2042
  VersionChanged: '0.81'
1962
2043
  IgnoredMethods: []
1963
- Max: 7
2044
+ Max: 8
1964
2045
 
1965
2046
  ################## Migration #############################
1966
2047
 
@@ -1980,10 +2061,12 @@ Naming/AccessorMethodName:
1980
2061
  VersionAdded: '0.50'
1981
2062
 
1982
2063
  Naming/AsciiIdentifiers:
1983
- Description: 'Use only ascii symbols in identifiers.'
2064
+ Description: 'Use only ascii symbols in identifiers and constants.'
1984
2065
  StyleGuide: '#english-identifiers'
1985
2066
  Enabled: true
1986
2067
  VersionAdded: '0.50'
2068
+ VersionChanged: '0.87'
2069
+ AsciiConstants: true
1987
2070
 
1988
2071
  Naming/BinaryOperatorParameterName:
1989
2072
  Description: 'When defining binary operators, name the argument other.'
@@ -2150,17 +2233,18 @@ Naming/MethodParameterName:
2150
2233
  AllowNamesEndingInNumbers: true
2151
2234
  # Allowed names that will not register an offense
2152
2235
  AllowedNames:
2153
- - io
2154
- - id
2155
- - to
2236
+ - at
2156
2237
  - by
2157
- - 'on'
2238
+ - db
2239
+ - id
2158
2240
  - in
2159
- - at
2241
+ - io
2160
2242
  - ip
2161
- - db
2243
+ - of
2244
+ - 'on'
2162
2245
  - os
2163
2246
  - pp
2247
+ - to
2164
2248
  # Forbidden names that will register an offense
2165
2249
  ForbiddenNames: []
2166
2250
 
@@ -2276,6 +2360,17 @@ Style/AccessModifierDeclarations:
2276
2360
  - group
2277
2361
  AllowModifiersOnSymbols: true
2278
2362
 
2363
+ Style/AccessorGrouping:
2364
+ Description: 'Checks for grouping of accessors in `class` and `module` bodies.'
2365
+ Enabled: 'pending'
2366
+ VersionAdded: '0.87'
2367
+ EnforcedStyle: grouped
2368
+ SupportedStyles:
2369
+ # separated: each accessor goes in a separate statement.
2370
+ # grouped: accessors are grouped into a single statement.
2371
+ - separated
2372
+ - grouped
2373
+
2279
2374
  Style/Alias:
2280
2375
  Description: 'Use alias instead of alias_method.'
2281
2376
  StyleGuide: '#alias-method-lexically'
@@ -2300,6 +2395,15 @@ Style/AndOr:
2300
2395
  - always
2301
2396
  - conditionals
2302
2397
 
2398
+ Style/ArrayCoercion:
2399
+ Description: >-
2400
+ Use Array() instead of explicit Array check or [*var], when dealing
2401
+ with a variable you want to treat as an Array, but you're not certain it's an array.
2402
+ StyleGuide: '#array-coercion'
2403
+ Safe: false
2404
+ Enabled: 'pending'
2405
+ VersionAdded: '0.88'
2406
+
2303
2407
  Style/ArrayJoin:
2304
2408
  Description: 'Use Array#join instead of Array#*.'
2305
2409
  StyleGuide: '#array-join'
@@ -2343,6 +2447,13 @@ Style/BeginBlock:
2343
2447
  Enabled: true
2344
2448
  VersionAdded: '0.9'
2345
2449
 
2450
+ Style/BisectedAttrAccessor:
2451
+ Description: >-
2452
+ Checks for places where `attr_reader` and `attr_writer`
2453
+ for the same method can be combined into single `attr_accessor`.
2454
+ Enabled: 'pending'
2455
+ VersionAdded: '0.87'
2456
+
2346
2457
  Style/BlockComments:
2347
2458
  Description: 'Do not use block comments.'
2348
2459
  StyleGuide: '#no-block-comments'
@@ -2465,6 +2576,7 @@ Style/CaseEquality:
2465
2576
  StyleGuide: '#no-case-equality'
2466
2577
  Enabled: true
2467
2578
  VersionAdded: '0.9'
2579
+ VersionChanged: '0.89'
2468
2580
  # If AllowOnConstant is enabled, the cop will ignore violations when the receiver of
2469
2581
  # the case equality operator is a constant.
2470
2582
  #
@@ -2475,6 +2587,12 @@ Style/CaseEquality:
2475
2587
  # String === "string"
2476
2588
  AllowOnConstant: false
2477
2589
 
2590
+ Style/CaseLikeIf:
2591
+ Description: 'This cop identifies places where `if-elsif` constructions can be replaced with `case-when`.'
2592
+ StyleGuide: '#case-vs-if-else'
2593
+ Enabled: 'pending'
2594
+ VersionAdded: '0.88'
2595
+
2478
2596
  Style/CharacterLiteral:
2479
2597
  Description: 'Checks for uses of character literals.'
2480
2598
  StyleGuide: '#no-character-literals'
@@ -2717,6 +2835,7 @@ Style/DoubleNegation:
2717
2835
  VersionAdded: '0.19'
2718
2836
  VersionChanged: '0.84'
2719
2837
  EnforcedStyle: allowed_in_returns
2838
+ SafeAutoCorrect: false
2720
2839
  SupportedStyles:
2721
2840
  - allowed_in_returns
2722
2841
  - forbidden
@@ -2811,6 +2930,16 @@ Style/ExpandPathArguments:
2811
2930
  Enabled: true
2812
2931
  VersionAdded: '0.53'
2813
2932
 
2933
+ Style/ExplicitBlockArgument:
2934
+ Description: >-
2935
+ Consider using explicit block argument to avoid writing block literal
2936
+ that just passes its arguments to another block.
2937
+ StyleGuide: '#block-argument'
2938
+ Enabled: pending
2939
+ # May change the yielding arity.
2940
+ Safe: false
2941
+ VersionAdded: '0.89'
2942
+
2814
2943
  Style/ExponentialNotation:
2815
2944
  Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
2816
2945
  StyleGuide: '#exponential-notation'
@@ -2894,6 +3023,12 @@ Style/FrozenStringLiteralComment:
2894
3023
  - never
2895
3024
  Safe: false
2896
3025
 
3026
+ Style/GlobalStdStream:
3027
+ Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
3028
+ StyleGuide: '#global-stdout'
3029
+ Enabled: pending
3030
+ VersionAdded: '0.89'
3031
+
2897
3032
  Style/GlobalVars:
2898
3033
  Description: 'Do not introduce global variables.'
2899
3034
  StyleGuide: '#instance-vars'
@@ -2913,6 +3048,18 @@ Style/GuardClause:
2913
3048
  # needs to have to trigger this cop
2914
3049
  MinBodyLength: 1
2915
3050
 
3051
+ Style/HashAsLastArrayItem:
3052
+ Description: >-
3053
+ Checks for presence or absence of braces around hash literal as a last
3054
+ array item depending on configuration.
3055
+ StyleGuide: '#hash-literal-as-last-array-item'
3056
+ Enabled: 'pending'
3057
+ VersionAdded: '0.88'
3058
+ EnforcedStyle: braces
3059
+ SupportedStyles:
3060
+ - braces
3061
+ - no_braces
3062
+
2916
3063
  Style/HashEachMethods:
2917
3064
  Description: 'Use Hash#each_key and Hash#each_value.'
2918
3065
  StyleGuide: '#hash-each'
@@ -2920,6 +3067,16 @@ Style/HashEachMethods:
2920
3067
  VersionAdded: '0.80'
2921
3068
  Safe: false
2922
3069
 
3070
+ Style/HashLikeCase:
3071
+ Description: >-
3072
+ Checks for places where `case-when` represents a simple 1:1
3073
+ mapping and can be replaced with a hash lookup.
3074
+ Enabled: 'pending'
3075
+ VersionAdded: '0.88'
3076
+ # `MinBranchesCount` defines the number of branches `case` needs to have
3077
+ # to trigger this cop
3078
+ MinBranchesCount: 3
3079
+
2923
3080
  Style/HashSyntax:
2924
3081
  Description: >-
2925
3082
  Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
@@ -2983,6 +3140,7 @@ Style/IfUnlessModifierOfIfUnless:
2983
3140
  Avoid modifier if/unless usage on conditionals.
2984
3141
  Enabled: true
2985
3142
  VersionAdded: '0.39'
3143
+ VersionChanged: '0.87'
2986
3144
 
2987
3145
  Style/IfWithSemicolon:
2988
3146
  Description: 'Do not use if x; .... Use the ternary operator instead.'
@@ -3126,12 +3284,6 @@ Style/MethodDefParentheses:
3126
3284
  - require_no_parentheses
3127
3285
  - require_no_parentheses_except_multiline
3128
3286
 
3129
- Style/MethodMissingSuper:
3130
- Description: Checks for `method_missing` to call `super`.
3131
- StyleGuide: '#no-method-missing'
3132
- Enabled: true
3133
- VersionAdded: '0.56'
3134
-
3135
3287
  Style/MinMax:
3136
3288
  Description: >-
3137
3289
  Use `Enumerable#minmax` instead of `Enumerable#min`
@@ -3239,6 +3391,7 @@ Style/MultilineTernaryOperator:
3239
3391
  StyleGuide: '#no-multiline-ternary'
3240
3392
  Enabled: true
3241
3393
  VersionAdded: '0.9'
3394
+ VersionChanged: '0.86'
3242
3395
 
3243
3396
  Style/MultilineWhenThen:
3244
3397
  Description: 'Do not use then for multi-line when statement.'
@@ -3343,6 +3496,7 @@ Style/NestedTernaryOperator:
3343
3496
  StyleGuide: '#no-nested-ternary'
3344
3497
  Enabled: true
3345
3498
  VersionAdded: '0.9'
3499
+ VersionChanged: '0.86'
3346
3500
 
3347
3501
  Style/Next:
3348
3502
  Description: 'Use `next` to skip iteration instead of a condition at the end.'
@@ -3471,6 +3625,13 @@ Style/OptionalArguments:
3471
3625
  VersionAdded: '0.33'
3472
3626
  VersionChanged: '0.83'
3473
3627
 
3628
+ Style/OptionalBooleanParameter:
3629
+ Description: 'Use keyword arguments when defining method with boolean argument.'
3630
+ StyleGuide: '#boolean-keyword-arguments'
3631
+ Enabled: pending
3632
+ Safe: false
3633
+ VersionAdded: '0.89'
3634
+
3474
3635
  Style/OrAssignment:
3475
3636
  Description: 'Recommend usage of double pipe equals (||=) where applicable.'
3476
3637
  StyleGuide: '#double-pipe-for-uninit'
@@ -3567,6 +3728,11 @@ Style/RandomWithOffset:
3567
3728
  Enabled: true
3568
3729
  VersionAdded: '0.52'
3569
3730
 
3731
+ Style/RedundantAssignment:
3732
+ Description: 'Checks for redundant assignment before returning.'
3733
+ Enabled: 'pending'
3734
+ VersionAdded: '0.87'
3735
+
3570
3736
  Style/RedundantBegin:
3571
3737
  Description: "Don't use begin blocks when they are not needed."
3572
3738
  StyleGuide: '#begin-implicit'
@@ -3596,6 +3762,27 @@ Style/RedundantException:
3596
3762
  VersionAdded: '0.14'
3597
3763
  VersionChanged: '0.29'
3598
3764
 
3765
+ Style/RedundantFetchBlock:
3766
+ Description: >-
3767
+ Use `fetch(key, value)` instead of `fetch(key) { value }`
3768
+ when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
3769
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
3770
+ Enabled: 'pending'
3771
+ Safe: false
3772
+ # If enabled, this cop will autocorrect usages of
3773
+ # `fetch` being called with block returning a constant.
3774
+ # This can be dangerous since constants will not be defined at that moment.
3775
+ SafeForConstants: false
3776
+ VersionAdded: '0.86'
3777
+
3778
+ Style/RedundantFileExtensionInRequire:
3779
+ Description: >-
3780
+ Checks for the presence of superfluous `.rb` extension in
3781
+ the filename provided to `require` and `require_relative`.
3782
+ StyleGuide: '#no-explicit-rb-to-require'
3783
+ Enabled: 'pending'
3784
+ VersionAdded: '0.88'
3785
+
3599
3786
  Style/RedundantFreeze:
3600
3787
  Description: "Checks usages of Object#freeze on immutable objects."
3601
3788
  Enabled: true
@@ -3763,6 +3950,12 @@ Style/SignalException:
3763
3950
  - only_fail
3764
3951
  - semantic
3765
3952
 
3953
+ Style/SingleArgumentDig:
3954
+ Description: 'Avoid using single argument dig method.'
3955
+ Enabled: pending
3956
+ VersionAdded: '0.89'
3957
+ Safe: false
3958
+
3766
3959
  Style/SingleLineBlockParams:
3767
3960
  Description: 'Enforces the names of some block params.'
3768
3961
  Enabled: false
@@ -3818,6 +4011,13 @@ Style/StderrPuts:
3818
4011
  Enabled: true
3819
4012
  VersionAdded: '0.51'
3820
4013
 
4014
+ Style/StringConcatenation:
4015
+ Description: 'Checks for places where string concatenation can be replaced with string interpolation.'
4016
+ StyleGuide: '#string-interpolation'
4017
+ Enabled: pending
4018
+ Safe: false
4019
+ VersionAdded: '0.89'
4020
+
3821
4021
  Style/StringHashKeys:
3822
4022
  Description: 'Prefer symbols instead of strings as hash keys.'
3823
4023
  StyleGuide: '#symbols-as-keys'
@@ -3875,6 +4075,7 @@ Style/StructInheritance:
3875
4075
  StyleGuide: '#no-extend-struct-new'
3876
4076
  Enabled: true
3877
4077
  VersionAdded: '0.29'
4078
+ VersionChanged: '0.86'
3878
4079
 
3879
4080
  Style/SymbolArray:
3880
4081
  Description: 'Use %i or %I for arrays of symbols.'
@@ -3896,7 +4097,7 @@ Style/SymbolLiteral:
3896
4097
  Style/SymbolProc:
3897
4098
  Description: 'Use symbols as procs instead of blocks when possible.'
3898
4099
  Enabled: true
3899
- SafeAutoCorrect: false
4100
+ Safe: false
3900
4101
  VersionAdded: '0.26'
3901
4102
  VersionChanged: '0.64'
3902
4103
  # A list of method names to be ignored by the check.