rubocop 1.8.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -13
  3. data/assets/output.html.erb +1 -1
  4. data/config/default.yml +89 -22
  5. data/config/obsoletion.yml +4 -0
  6. data/lib/rubocop.rb +9 -0
  7. data/lib/rubocop/cli/command/auto_genenerate_config.rb +5 -4
  8. data/lib/rubocop/cli/command/execute_runner.rb +1 -1
  9. data/lib/rubocop/cli/command/suggest_extensions.rb +1 -1
  10. data/lib/rubocop/config.rb +5 -2
  11. data/lib/rubocop/config_loader.rb +7 -14
  12. data/lib/rubocop/config_store.rb +12 -1
  13. data/lib/rubocop/cop/base.rb +2 -1
  14. data/lib/rubocop/cop/bundler/duplicated_gem.rb +2 -1
  15. data/lib/rubocop/cop/bundler/gem_comment.rb +1 -0
  16. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -0
  17. data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -0
  18. data/lib/rubocop/cop/exclude_limit.rb +26 -0
  19. data/lib/rubocop/cop/gemspec/date_assignment.rb +57 -0
  20. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -0
  21. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -0
  22. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +2 -0
  23. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +2 -0
  24. data/lib/rubocop/cop/generator.rb +3 -5
  25. data/lib/rubocop/cop/internal_affairs.rb +6 -1
  26. data/lib/rubocop/cop/internal_affairs/empty_line_between_expect_offense_and_correction.rb +68 -0
  27. data/lib/rubocop/cop/internal_affairs/example_description.rb +90 -0
  28. data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +1 -0
  29. data/lib/rubocop/cop/internal_affairs/node_destructuring.rb +2 -0
  30. data/lib/rubocop/cop/internal_affairs/node_matcher_directive.rb +151 -0
  31. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -0
  32. data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +2 -0
  33. data/lib/rubocop/cop/internal_affairs/redundant_described_class_as_subject.rb +62 -0
  34. data/lib/rubocop/cop/internal_affairs/redundant_let_rubocop_config_new.rb +65 -0
  35. data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -0
  36. data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +3 -0
  37. data/lib/rubocop/cop/internal_affairs/style_detected_api_use.rb +4 -0
  38. data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +2 -0
  39. data/lib/rubocop/cop/layout/block_alignment.rb +1 -0
  40. data/lib/rubocop/cop/layout/class_structure.rb +8 -2
  41. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +37 -17
  42. data/lib/rubocop/cop/layout/extra_spacing.rb +2 -2
  43. data/lib/rubocop/cop/layout/first_argument_indentation.rb +22 -3
  44. data/lib/rubocop/cop/layout/indentation_width.rb +1 -0
  45. data/lib/rubocop/cop/layout/line_length.rb +2 -1
  46. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +26 -0
  47. data/lib/rubocop/cop/layout/space_before_block_braces.rb +1 -1
  48. data/lib/rubocop/cop/layout/space_before_brackets.rb +9 -4
  49. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -1
  50. data/lib/rubocop/cop/lint/big_decimal_new.rb +1 -0
  51. data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -0
  52. data/lib/rubocop/cop/lint/constant_definition_in_block.rb +2 -0
  53. data/lib/rubocop/cop/lint/constant_resolution.rb +1 -0
  54. data/lib/rubocop/cop/lint/debugger.rb +60 -14
  55. data/lib/rubocop/cop/lint/deprecated_constants.rb +5 -0
  56. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +14 -4
  57. data/lib/rubocop/cop/lint/duplicate_branch.rb +1 -1
  58. data/lib/rubocop/cop/lint/duplicate_methods.rb +3 -0
  59. data/lib/rubocop/cop/lint/duplicate_require.rb +3 -2
  60. data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -0
  61. data/lib/rubocop/cop/lint/else_layout.rb +1 -1
  62. data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -0
  63. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -0
  64. data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +1 -0
  65. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -0
  66. data/lib/rubocop/cop/lint/inherit_exception.rb +1 -0
  67. data/lib/rubocop/cop/lint/multiple_comparison.rb +5 -4
  68. data/lib/rubocop/cop/lint/nested_method_definition.rb +3 -0
  69. data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -0
  70. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +7 -0
  71. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +3 -0
  72. data/lib/rubocop/cop/lint/number_conversion.rb +43 -6
  73. data/lib/rubocop/cop/lint/numbered_parameter_assignment.rb +47 -0
  74. data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +39 -0
  75. data/lib/rubocop/cop/lint/raise_exception.rb +2 -0
  76. data/lib/rubocop/cop/lint/rand_one.rb +1 -0
  77. data/lib/rubocop/cop/lint/redundant_dir_glob_sort.rb +5 -3
  78. data/lib/rubocop/cop/lint/redundant_require_statement.rb +1 -0
  79. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +1 -0
  80. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +7 -3
  81. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -0
  82. data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -0
  83. data/lib/rubocop/cop/lint/redundant_with_object.rb +1 -0
  84. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -0
  85. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -0
  86. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +1 -0
  87. data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -0
  88. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +1 -0
  89. data/lib/rubocop/cop/lint/struct_new_override.rb +1 -0
  90. data/lib/rubocop/cop/lint/symbol_conversion.rb +103 -0
  91. data/lib/rubocop/cop/lint/to_enum_arguments.rb +3 -0
  92. data/lib/rubocop/cop/lint/triple_quotes.rb +71 -0
  93. data/lib/rubocop/cop/lint/unified_integer.rb +1 -0
  94. data/lib/rubocop/cop/lint/unmodified_reduce_accumulator.rb +5 -0
  95. data/lib/rubocop/cop/lint/unreachable_code.rb +1 -0
  96. data/lib/rubocop/cop/lint/unreachable_loop.rb +1 -0
  97. data/lib/rubocop/cop/lint/unused_method_argument.rb +1 -0
  98. data/lib/rubocop/cop/lint/uri_escape_unescape.rb +1 -0
  99. data/lib/rubocop/cop/lint/useless_access_modifier.rb +4 -0
  100. data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -0
  101. data/lib/rubocop/cop/lint/useless_times.rb +3 -0
  102. data/lib/rubocop/cop/message_annotator.rb +4 -1
  103. data/lib/rubocop/cop/metrics/block_nesting.rb +2 -2
  104. data/lib/rubocop/cop/metrics/module_length.rb +1 -0
  105. data/lib/rubocop/cop/metrics/parameter_lists.rb +6 -2
  106. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +6 -4
  107. data/lib/rubocop/cop/metrics/utils/repeated_attribute_discount.rb +2 -0
  108. data/lib/rubocop/cop/mixin/check_line_breakable.rb +5 -0
  109. data/lib/rubocop/cop/mixin/code_length.rb +3 -1
  110. data/lib/rubocop/cop/mixin/comments_help.rb +0 -1
  111. data/lib/rubocop/cop/mixin/configurable_max.rb +1 -0
  112. data/lib/rubocop/cop/mixin/def_node.rb +1 -0
  113. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +3 -0
  114. data/lib/rubocop/cop/mixin/empty_parameter.rb +1 -0
  115. data/lib/rubocop/cop/mixin/enforce_superclass.rb +2 -0
  116. data/lib/rubocop/cop/mixin/hash_transform_method.rb +1 -0
  117. data/lib/rubocop/cop/mixin/method_complexity.rb +4 -1
  118. data/lib/rubocop/cop/mixin/negative_conditional.rb +3 -0
  119. data/lib/rubocop/cop/mixin/preferred_delimiters.rb +3 -3
  120. data/lib/rubocop/cop/mixin/rational_literal.rb +1 -0
  121. data/lib/rubocop/cop/mixin/safe_assignment.rb +5 -0
  122. data/lib/rubocop/cop/mixin/uncommunicative_name.rb +5 -1
  123. data/lib/rubocop/cop/mixin/visibility_help.rb +1 -0
  124. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -0
  125. data/lib/rubocop/cop/naming/constant_name.rb +2 -0
  126. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +2 -0
  127. data/lib/rubocop/cop/naming/method_name.rb +3 -0
  128. data/lib/rubocop/cop/naming/predicate_name.rb +1 -0
  129. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +38 -5
  130. data/lib/rubocop/cop/naming/variable_number.rb +1 -1
  131. data/lib/rubocop/cop/registry.rb +1 -1
  132. data/lib/rubocop/cop/security/eval.rb +1 -0
  133. data/lib/rubocop/cop/security/json_load.rb +1 -0
  134. data/lib/rubocop/cop/security/marshal_load.rb +1 -0
  135. data/lib/rubocop/cop/security/open.rb +1 -0
  136. data/lib/rubocop/cop/security/yaml_load.rb +1 -0
  137. data/lib/rubocop/cop/severity.rb +3 -3
  138. data/lib/rubocop/cop/style/access_modifier_declarations.rb +1 -0
  139. data/lib/rubocop/cop/style/alias.rb +1 -0
  140. data/lib/rubocop/cop/style/arguments_forwarding.rb +3 -0
  141. data/lib/rubocop/cop/style/array_coercion.rb +2 -0
  142. data/lib/rubocop/cop/style/array_join.rb +1 -0
  143. data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
  144. data/lib/rubocop/cop/style/attr.rb +1 -0
  145. data/lib/rubocop/cop/style/case_equality.rb +2 -1
  146. data/lib/rubocop/cop/style/class_equality_comparison.rb +1 -0
  147. data/lib/rubocop/cop/style/collection_compact.rb +2 -0
  148. data/lib/rubocop/cop/style/colon_method_call.rb +1 -0
  149. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  150. data/lib/rubocop/cop/style/conditional_assignment.rb +2 -0
  151. data/lib/rubocop/cop/style/constant_visibility.rb +28 -0
  152. data/lib/rubocop/cop/style/date_time.rb +3 -0
  153. data/lib/rubocop/cop/style/dir.rb +1 -0
  154. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +49 -9
  155. data/lib/rubocop/cop/style/documentation.rb +5 -0
  156. data/lib/rubocop/cop/style/documentation_method.rb +1 -0
  157. data/lib/rubocop/cop/style/double_negation.rb +3 -2
  158. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -0
  159. data/lib/rubocop/cop/style/each_with_object.rb +1 -0
  160. data/lib/rubocop/cop/style/empty_literal.rb +9 -0
  161. data/lib/rubocop/cop/style/endless_method.rb +1 -0
  162. data/lib/rubocop/cop/style/eval_with_location.rb +140 -49
  163. data/lib/rubocop/cop/style/even_odd.rb +1 -0
  164. data/lib/rubocop/cop/style/expand_path_arguments.rb +3 -0
  165. data/lib/rubocop/cop/style/explicit_block_argument.rb +12 -1
  166. data/lib/rubocop/cop/style/exponential_notation.rb +6 -7
  167. data/lib/rubocop/cop/style/float_division.rb +7 -0
  168. data/lib/rubocop/cop/style/format_string.rb +2 -0
  169. data/lib/rubocop/cop/style/format_string_token.rb +19 -2
  170. data/lib/rubocop/cop/style/global_std_stream.rb +1 -0
  171. data/lib/rubocop/cop/style/hash_conversion.rb +105 -0
  172. data/lib/rubocop/cop/style/hash_each_methods.rb +1 -0
  173. data/lib/rubocop/cop/style/hash_except.rb +1 -0
  174. data/lib/rubocop/cop/style/hash_like_case.rb +1 -0
  175. data/lib/rubocop/cop/style/hash_transform_keys.rb +4 -0
  176. data/lib/rubocop/cop/style/hash_transform_values.rb +4 -0
  177. data/lib/rubocop/cop/style/if_inside_else.rb +14 -7
  178. data/lib/rubocop/cop/style/if_with_boolean_literal_branches.rb +122 -0
  179. data/lib/rubocop/cop/style/implicit_runtime_error.rb +1 -0
  180. data/lib/rubocop/cop/style/inverse_methods.rb +2 -0
  181. data/lib/rubocop/cop/style/min_max.rb +1 -0
  182. data/lib/rubocop/cop/style/mixin_usage.rb +2 -0
  183. data/lib/rubocop/cop/style/module_function.rb +5 -0
  184. data/lib/rubocop/cop/style/multiple_comparison.rb +21 -2
  185. data/lib/rubocop/cop/style/mutable_constant.rb +3 -0
  186. data/lib/rubocop/cop/style/negated_if_else_condition.rb +1 -0
  187. data/lib/rubocop/cop/style/nil_comparison.rb +6 -0
  188. data/lib/rubocop/cop/style/nil_lambda.rb +1 -0
  189. data/lib/rubocop/cop/style/non_nil_check.rb +30 -13
  190. data/lib/rubocop/cop/style/numeric_literals.rb +6 -9
  191. data/lib/rubocop/cop/style/numeric_predicate.rb +4 -1
  192. data/lib/rubocop/cop/style/option_hash.rb +1 -0
  193. data/lib/rubocop/cop/style/or_assignment.rb +2 -0
  194. data/lib/rubocop/cop/style/parallel_assignment.rb +6 -0
  195. data/lib/rubocop/cop/style/parentheses_around_condition.rb +1 -0
  196. data/lib/rubocop/cop/style/proc.rb +1 -0
  197. data/lib/rubocop/cop/style/random_with_offset.rb +5 -0
  198. data/lib/rubocop/cop/style/redundant_assignment.rb +1 -0
  199. data/lib/rubocop/cop/style/redundant_begin.rb +7 -1
  200. data/lib/rubocop/cop/style/redundant_conditional.rb +2 -0
  201. data/lib/rubocop/cop/style/redundant_exception.rb +2 -0
  202. data/lib/rubocop/cop/style/redundant_fetch_block.rb +2 -0
  203. data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +1 -0
  204. data/lib/rubocop/cop/style/redundant_freeze.rb +1 -0
  205. data/lib/rubocop/cop/style/redundant_parentheses.rb +13 -0
  206. data/lib/rubocop/cop/style/redundant_self_assignment.rb +2 -0
  207. data/lib/rubocop/cop/style/redundant_sort.rb +1 -0
  208. data/lib/rubocop/cop/style/redundant_sort_by.rb +1 -0
  209. data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
  210. data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -0
  211. data/lib/rubocop/cop/style/return_nil.rb +6 -0
  212. data/lib/rubocop/cop/style/safe_navigation.rb +2 -0
  213. data/lib/rubocop/cop/style/sample.rb +1 -0
  214. data/lib/rubocop/cop/style/signal_exception.rb +3 -0
  215. data/lib/rubocop/cop/style/single_argument_dig.rb +1 -0
  216. data/lib/rubocop/cop/style/single_line_methods.rb +5 -2
  217. data/lib/rubocop/cop/style/slicing_with_range.rb +1 -0
  218. data/lib/rubocop/cop/style/sole_nested_conditional.rb +28 -4
  219. data/lib/rubocop/cop/style/special_global_vars.rb +3 -3
  220. data/lib/rubocop/cop/style/stderr_puts.rb +1 -0
  221. data/lib/rubocop/cop/style/string_concatenation.rb +2 -1
  222. data/lib/rubocop/cop/style/string_hash_keys.rb +2 -0
  223. data/lib/rubocop/cop/style/strip.rb +1 -0
  224. data/lib/rubocop/cop/style/struct_inheritance.rb +1 -0
  225. data/lib/rubocop/cop/style/symbol_proc.rb +25 -1
  226. data/lib/rubocop/cop/style/ternary_parentheses.rb +2 -1
  227. data/lib/rubocop/cop/style/trailing_body_on_method_definition.rb +1 -0
  228. data/lib/rubocop/cop/style/trailing_method_end_statement.rb +1 -1
  229. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -0
  230. data/lib/rubocop/cop/style/unless_logical_operators.rb +99 -0
  231. data/lib/rubocop/cop/style/unpack_first.rb +1 -0
  232. data/lib/rubocop/cop/style/while_until_modifier.rb +2 -4
  233. data/lib/rubocop/cop/style/yoda_condition.rb +1 -0
  234. data/lib/rubocop/cop/style/zero_length_predicate.rb +5 -0
  235. data/lib/rubocop/formatter/git_hub_actions_formatter.rb +1 -0
  236. data/lib/rubocop/formatter/offense_count_formatter.rb +1 -1
  237. data/lib/rubocop/formatter/simple_text_formatter.rb +2 -1
  238. data/lib/rubocop/formatter/worst_offenders_formatter.rb +1 -1
  239. data/lib/rubocop/magic_comment.rb +30 -1
  240. data/lib/rubocop/name_similarity.rb +1 -1
  241. data/lib/rubocop/options.rb +1 -1
  242. data/lib/rubocop/rspec/expect_offense.rb +5 -2
  243. data/lib/rubocop/runner.rb +1 -0
  244. data/lib/rubocop/target_ruby.rb +21 -13
  245. data/lib/rubocop/version.rb +2 -2
  246. metadata +21 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e14b02ef2156539b9acbf92f0a131cbf5459cccdbb799cf96116f51b61e45c3
4
- data.tar.gz: 2322dcababa13d2dbc001fc4a6fb8fe8c39e39b0d27869f4b1b5c59aceefa577
3
+ metadata.gz: dac7fff2f013c47a104cadfc9ca1a02a9f0996c13da30cf53c96f9c427f528bf
4
+ data.tar.gz: 55120478bfcd4ff14e326c6be7af570852b226ad27a02e9b2835ddda7d8e4324
5
5
  SHA512:
6
- metadata.gz: afc301f47f48f46587318215a0d64a246ac9f4007f7c2396867a1c26cff2a467d59ebd30531adaf5dd3eebcaea001f19b34ab4737bebfe4b51dda7f329a0b4f9
7
- data.tar.gz: ee54178b27d0dc5e058f004a27ea53d581583bf3386bf2fc572b4b16ad6099d849720935a6c632aaade0a3c71ca92129c0b3c9dc4dff80e00977d5141bc02615
6
+ metadata.gz: 8b47ab24450c94098487e2efcaf3c6c45314e07523ca7272356908792f06689f95ab4032eed06f9a55a1f68ad75432c599f6bbcec83b5a3ce3e611dab9e2f608
7
+ data.tar.gz: 1ba4a1fef00d332d644f242d97954cad9ad4cbcb2cf7cad1d2a2bec48540a2ae12d895a107283aac1933dd34230a45b02cb0470290f0c502bae2c5d3e762662f
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  <p align="center">
2
- <img src="https://raw.githubusercontent.com/rubocop-hq/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
2
+ <img src="https://raw.githubusercontent.com/rubocop/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
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
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
7
7
  [![Gem Version](https://badge.fury.io/rb/rubocop.svg)](https://badge.fury.io/rb/rubocop)
8
- [![CircleCI Status](https://circleci.com/gh/rubocop-hq/rubocop/tree/master.svg?style=svg)](https://circleci.com/gh/rubocop-hq/rubocop/tree/master)
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)
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)
8
+ [![CircleCI Status](https://circleci.com/gh/rubocop/rubocop/tree/master.svg?style=svg)](https://circleci.com/gh/rubocop/rubocop/tree/master)
9
+ [![Actions Status](https://github.com/rubocop/rubocop/workflows/CI/badge.svg?branch=master)](https://github.com/rubocop/rubocop/actions?query=workflow%3ACI)
10
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/test_coverage)](https://codeclimate.com/github/rubocop/rubocop/test_coverage)
11
+ [![Maintainability](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/maintainability)](https://codeclimate.com/github/rubocop/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
  > Role models are important. <br/>
@@ -20,7 +20,7 @@ Guide](https://rubystyle.guide). Apart from reporting the problems discovered in
20
20
  RuboCop can also automatically fix many of them for you.
21
21
 
22
22
  RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various
23
- [configuration options](https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml).
23
+ [configuration options](https://github.com/rubocop/rubocop/blob/master/config/default.yml).
24
24
 
25
25
  ----------
26
26
  [![Patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://www.patreon.com/bbatsov)
@@ -45,13 +45,13 @@ gem 'rubocop', require: false
45
45
  ```
46
46
 
47
47
  RuboCop is stable between major versions, both in terms of API and cop configuration.
48
- We aim the ease the maintenance of RuboCop extensions and the upgrades between RuboCop
48
+ We aim to ease the maintenance of RuboCop extensions and the upgrades between RuboCop
49
49
  releases. All big changes are reserved for major releases.
50
50
  To prevent an unwanted RuboCop update you might want to use a conservative version lock
51
51
  in your `Gemfile`:
52
52
 
53
53
  ```rb
54
- gem 'rubocop', '~> 1.8', require: false
54
+ gem 'rubocop', '~> 1.11', require: false
55
55
  ```
56
56
 
57
57
  See [versioning](https://docs.rubocop.org/rubocop/1.0/versioning.html) for further details.
@@ -82,7 +82,7 @@ See the [compatibility documentation](https://docs.rubocop.org/rubocop/compatibi
82
82
 
83
83
  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.
84
84
 
85
- [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
85
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
86
86
 
87
87
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)
88
88
 
@@ -90,7 +90,7 @@ If you use RuboCop in your project, you can include one of these badges in your
90
90
  Here are the Markdown snippets for the two badges:
91
91
 
92
92
  ``` markdown
93
- [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
93
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
94
94
 
95
95
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)
96
96
  ```
@@ -109,20 +109,21 @@ Here's a list of RuboCop's core developers:
109
109
  * [Maxim Krizhanovski](https://github.com/darhazer)
110
110
  * [Benjamin Quorning](https://github.com/bquorning)
111
111
  * [Marc-André Lafortune](https://github.com/marcandre)
112
+ * [Daniel Vandersluis](https://github.com/dvandersluis)
112
113
 
113
114
  See the [team page](https://docs.rubocop.org/rubocop/about/team.html) for more details.
114
115
 
115
116
  ## Logo
116
117
 
117
118
  RuboCop's logo was created by [Dimiter Petrov](https://www.chadomoto.com/). You can find the logo in various
118
- formats [here](https://github.com/rubocop-hq/rubocop/tree/master/logo).
119
+ formats [here](https://github.com/rubocop/rubocop/tree/master/logo).
119
120
 
120
121
  The logo is licensed under a
121
122
  [Creative Commons Attribution-NonCommercial 4.0 International License](https://creativecommons.org/licenses/by-nc/4.0/deed.en_GB).
122
123
 
123
124
  ## Contributors
124
125
 
125
- Here's a [list](https://github.com/rubocop-hq/rubocop/graphs/contributors) of
126
+ Here's a [list](https://github.com/rubocop/rubocop/graphs/contributors) of
126
127
  all the people who have contributed to the development of RuboCop.
127
128
 
128
129
  I'm extremely grateful to each and every one of them!
@@ -254,7 +254,7 @@
254
254
  <% end %>
255
255
  </div>
256
256
  <footer>
257
- Generated by <a href="https://github.com/rubocop-hq/rubocop">RuboCop</a>
257
+ Generated by <a href="https://github.com/rubocop/rubocop">RuboCop</a>
258
258
  <span class="version"><%= RuboCop::Version::STRING %></span>
259
259
  </footer>
260
260
  </body>
data/config/default.yml CHANGED
@@ -203,6 +203,13 @@ Bundler/OrderedGems:
203
203
 
204
204
  #################### Gemspec ###############################
205
205
 
206
+ Gemspec/DateAssignment:
207
+ Description: 'Checks that `date =` is not used in gemspec file, it is set automatically when the gem is packaged.'
208
+ Enabled: pending
209
+ VersionAdded: '1.10'
210
+ Include:
211
+ - '**/*.gemspec'
212
+
206
213
  Gemspec/DuplicatedAssignment:
207
214
  Description: 'An attribute assignment method calls should be listed only once in a gemspec.'
208
215
  Enabled: true
@@ -1446,23 +1453,31 @@ Lint/Debugger:
1446
1453
  Description: 'Check for debugger calls.'
1447
1454
  Enabled: true
1448
1455
  VersionAdded: '0.14'
1449
- VersionChanged: '0.49'
1450
- DebuggerReceivers:
1451
- - binding
1452
- - Kernel
1453
- - Pry
1456
+ VersionChanged: '1.10'
1457
+ DebuggerReceivers: [] # deprecated
1454
1458
  DebuggerMethods:
1455
- - debugger
1456
- - byebug
1457
- - remote_byebug
1458
- - pry
1459
- - remote_pry
1460
- - pry_remote
1461
- - console
1462
- - rescue
1463
- - save_and_open_page
1464
- - save_and_open_screenshot
1465
- - irb
1459
+ # Groups are available so that a specific group can be disabled in
1460
+ # a user's configuration, but are otherwise not significant.
1461
+ Kernel:
1462
+ - binding.irb
1463
+ Byebug:
1464
+ - byebug
1465
+ - remote_byebug
1466
+ - Kernel.byebug
1467
+ - Kernel.remote_byebug
1468
+ Capybara:
1469
+ - save_and_open_page
1470
+ - save_and_open_screenshot
1471
+ Pry:
1472
+ - binding.pry
1473
+ - binding.remote_pry
1474
+ - binding.pry_remote
1475
+ - Pry.rescue
1476
+ Rails:
1477
+ - debugger
1478
+ - Kernel.debugger
1479
+ WebConsole:
1480
+ - binding.console
1466
1481
 
1467
1482
  Lint/DeprecatedClassMethods:
1468
1483
  Description: 'Check for deprecated class method calls.'
@@ -1806,6 +1821,17 @@ Lint/NumberConversion:
1806
1821
  - Time
1807
1822
  - DateTime
1808
1823
 
1824
+ Lint/NumberedParameterAssignment:
1825
+ Description: 'Checks for uses of numbered parameter assignment.'
1826
+ Enabled: pending
1827
+ VersionAdded: '1.9'
1828
+
1829
+ Lint/OrAssignmentToConstant:
1830
+ Description: 'Checks unintended or-assignment to constant.'
1831
+ Enabled: pending
1832
+ Safe: false
1833
+ VersionAdded: '1.9'
1834
+
1809
1835
  Lint/OrderedMagicComments:
1810
1836
  Description: 'Checks the proper ordering of magic comments and whether a magic comment is not placed before a shebang.'
1811
1837
  Enabled: true
@@ -2032,12 +2058,16 @@ Lint/SuppressedException:
2032
2058
  VersionAdded: '0.9'
2033
2059
  VersionChanged: '0.81'
2034
2060
 
2061
+ Lint/SymbolConversion:
2062
+ Description: 'Checks for unnecessary symbol conversions.'
2063
+ Enabled: pending
2064
+ VersionAdded: '1.9'
2065
+
2035
2066
  Lint/Syntax:
2036
- Description: 'Checks syntax error.'
2067
+ Description: 'Checks for syntax errors.'
2037
2068
  Enabled: true
2038
2069
  VersionAdded: '0.9'
2039
2070
 
2040
-
2041
2071
  Lint/ToEnumArguments:
2042
2072
  Description: 'This cop ensures that `to_enum`/`enum_for`, called for the current method, has correct arguments.'
2043
2073
  Enabled: pending
@@ -2058,6 +2088,11 @@ Lint/TrailingCommaInAttributeDeclaration:
2058
2088
  Enabled: true
2059
2089
  VersionAdded: '0.90'
2060
2090
 
2091
+ Lint/TripleQuotes:
2092
+ Description: 'Checks for useless triple quote constructs.'
2093
+ Enabled: pending
2094
+ VersionAdded: '1.9'
2095
+
2061
2096
  Lint/UnderscorePrefixedVariableName:
2062
2097
  Description: 'Do not use prefix `_` for a variable that is used.'
2063
2098
  Enabled: true
@@ -2689,7 +2724,8 @@ Style/AsciiComments:
2689
2724
  Enabled: true
2690
2725
  VersionAdded: '0.9'
2691
2726
  VersionChanged: '0.52'
2692
- AllowedChars: []
2727
+ AllowedChars:
2728
+ - ©
2693
2729
 
2694
2730
  Style/Attr:
2695
2731
  Description: 'Checks for uses of Module#attr.'
@@ -3066,6 +3102,8 @@ Style/ConstantVisibility:
3066
3102
  visibility declarations.
3067
3103
  Enabled: false
3068
3104
  VersionAdded: '0.66'
3105
+ VersionChanged: '1.10'
3106
+ IgnoreModules: false
3069
3107
 
3070
3108
  # Checks that you have put a copyright in a comment before any code.
3071
3109
  #
@@ -3120,6 +3158,8 @@ Style/DisableCopsWithinSourceCodeDirective:
3120
3158
  Forbids disabling/enabling cops within source code.
3121
3159
  Enabled: false
3122
3160
  VersionAdded: '0.82'
3161
+ VersionChanged: '1.9'
3162
+ AllowedCops: []
3123
3163
 
3124
3164
  Style/DocumentDynamicEvalDefinition:
3125
3165
  Description: >-
@@ -3271,9 +3311,8 @@ Style/ExplicitBlockArgument:
3271
3311
  that just passes its arguments to another block.
3272
3312
  StyleGuide: '#block-argument'
3273
3313
  Enabled: true
3274
- # May change the yielding arity.
3275
- Safe: false
3276
3314
  VersionAdded: '0.89'
3315
+ VersionChanged: '1.8'
3277
3316
 
3278
3317
  Style/ExponentialNotation:
3279
3318
  Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
@@ -3292,7 +3331,8 @@ Style/FloatDivision:
3292
3331
  Reference: 'https://blog.rubystyle.guide/ruby/2019/06/21/float-division.html'
3293
3332
  Enabled: true
3294
3333
  VersionAdded: '0.72'
3295
- VersionChanged: '1.6'
3334
+ VersionChanged: '1.9'
3335
+ Safe: false
3296
3336
  EnforcedStyle: single_coerce
3297
3337
  SupportedStyles:
3298
3338
  - left_coerce
@@ -3340,6 +3380,7 @@ Style/FormatStringToken:
3340
3380
  MaxUnannotatedPlaceholdersAllowed: 1
3341
3381
  VersionAdded: '0.49'
3342
3382
  VersionChanged: '1.0'
3383
+ IgnoredMethods: []
3343
3384
 
3344
3385
  Style/FrozenStringLiteralComment:
3345
3386
  Description: >-
@@ -3401,6 +3442,13 @@ Style/HashAsLastArrayItem:
3401
3442
  - braces
3402
3443
  - no_braces
3403
3444
 
3445
+ Style/HashConversion:
3446
+ Description: 'Avoid Hash[] in favor of ary.to_h or literal hashes.'
3447
+ Enabled: pending
3448
+ VersionAdded: '1.10'
3449
+ VersionChanged: '1.11'
3450
+ AllowSplatArgument: true
3451
+
3404
3452
  Style/HashEachMethods:
3405
3453
  Description: 'Use Hash#each_key and Hash#each_value.'
3406
3454
  StyleGuide: '#hash-each'
@@ -3493,6 +3541,14 @@ Style/IfUnlessModifierOfIfUnless:
3493
3541
  VersionAdded: '0.39'
3494
3542
  VersionChanged: '0.87'
3495
3543
 
3544
+ Style/IfWithBooleanLiteralBranches:
3545
+ Description: 'Checks for redundant `if` with boolean literal branches.'
3546
+ Enabled: pending
3547
+ VersionAdded: '1.9'
3548
+ SafeAutoCorrect: false
3549
+ AllowedMethods:
3550
+ - nonzero?
3551
+
3496
3552
  Style/IfWithSemicolon:
3497
3553
  Description: 'Do not use if x; .... Use the ternary operator instead.'
3498
3554
  StyleGuide: '#no-semicolon-ifs'
@@ -4532,6 +4588,7 @@ Style/SymbolProc:
4532
4588
  Safe: false
4533
4589
  VersionAdded: '0.26'
4534
4590
  VersionChanged: '1.5'
4591
+ AllowMethodsWithArguments: false
4535
4592
  # A list of method names to be ignored by the check.
4536
4593
  # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
4537
4594
  IgnoredMethods:
@@ -4684,6 +4741,16 @@ Style/UnlessElse:
4684
4741
  Enabled: true
4685
4742
  VersionAdded: '0.9'
4686
4743
 
4744
+ Style/UnlessLogicalOperators:
4745
+ Description: >-
4746
+ Checks for use of logical operators in an unless condition.
4747
+ Enabled: false
4748
+ VersionAdded: '1.11'
4749
+ EnforcedStyle: forbid_mixed_logical_operators
4750
+ SupportedStyles:
4751
+ - forbid_mixed_logical_operators
4752
+ - forbid_logical_operators
4753
+
4687
4754
  Style/UnpackFirst:
4688
4755
  Description: >-
4689
4756
  Checks for accessing the first element of `String#unpack`
@@ -187,6 +187,10 @@ changed_parameters:
187
187
  parameters: ExcludedMethods
188
188
  alternative: IgnoredMethods
189
189
  severity: warning
190
+ - cops: Lint/Debugger
191
+ parameters: DebuggerReceivers
192
+ reason: "`DebuggerReceivers` is no longer necessary, method receivers should be specified in `DebuggerMethods` instead."
193
+ severity: warning
190
194
 
191
195
  # Enforced styles that have been removed or replaced
192
196
  changed_enforced_styles:
data/lib/rubocop.rb CHANGED
@@ -35,6 +35,7 @@ require_relative 'rubocop/cop/offense'
35
35
  require_relative 'rubocop/cop/message_annotator'
36
36
  require_relative 'rubocop/cop/ignored_node'
37
37
  require_relative 'rubocop/cop/autocorrect_logic'
38
+ require_relative 'rubocop/cop/exclude_limit'
38
39
  require_relative 'rubocop/cop/badge'
39
40
  require_relative 'rubocop/cop/registry'
40
41
  require_relative 'rubocop/cop/base'
@@ -151,6 +152,7 @@ require_relative 'rubocop/cop/bundler/gem_comment'
151
152
  require_relative 'rubocop/cop/bundler/insecure_protocol_source'
152
153
  require_relative 'rubocop/cop/bundler/ordered_gems'
153
154
 
155
+ require_relative 'rubocop/cop/gemspec/date_assignment'
154
156
  require_relative 'rubocop/cop/gemspec/duplicated_assignment'
155
157
  require_relative 'rubocop/cop/gemspec/ordered_dependencies'
156
158
  require_relative 'rubocop/cop/gemspec/required_ruby_version'
@@ -312,6 +314,8 @@ require_relative 'rubocop/cop/lint/no_return_in_begin_end_blocks'
312
314
  require_relative 'rubocop/cop/lint/non_deterministic_require_order'
313
315
  require_relative 'rubocop/cop/lint/non_local_exit_from_iterator'
314
316
  require_relative 'rubocop/cop/lint/number_conversion'
317
+ require_relative 'rubocop/cop/lint/numbered_parameter_assignment'
318
+ require_relative 'rubocop/cop/lint/or_assignment_to_constant'
315
319
  require_relative 'rubocop/cop/lint/ordered_magic_comments'
316
320
  require_relative 'rubocop/cop/lint/out_of_range_regexp_ref'
317
321
  require_relative 'rubocop/cop/lint/parentheses_as_grouped_expression'
@@ -344,11 +348,13 @@ require_relative 'rubocop/cop/lint/shadowed_exception'
344
348
  require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
345
349
  require_relative 'rubocop/cop/lint/struct_new_override'
346
350
  require_relative 'rubocop/cop/lint/suppressed_exception'
351
+ require_relative 'rubocop/cop/lint/symbol_conversion'
347
352
  require_relative 'rubocop/cop/lint/syntax'
348
353
  require_relative 'rubocop/cop/lint/to_enum_arguments'
349
354
  require_relative 'rubocop/cop/lint/to_json'
350
355
  require_relative 'rubocop/cop/lint/top_level_return_with_argument'
351
356
  require_relative 'rubocop/cop/lint/trailing_comma_in_attribute_declaration'
357
+ require_relative 'rubocop/cop/lint/triple_quotes'
352
358
  require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
353
359
  require_relative 'rubocop/cop/lint/unexpected_block_arity'
354
360
  require_relative 'rubocop/cop/lint/unified_integer'
@@ -467,6 +473,7 @@ require_relative 'rubocop/cop/style/global_std_stream'
467
473
  require_relative 'rubocop/cop/style/global_vars'
468
474
  require_relative 'rubocop/cop/style/guard_clause'
469
475
  require_relative 'rubocop/cop/style/hash_as_last_array_item'
476
+ require_relative 'rubocop/cop/style/hash_conversion'
470
477
  require_relative 'rubocop/cop/style/hash_each_methods'
471
478
  require_relative 'rubocop/cop/style/hash_except'
472
479
  require_relative 'rubocop/cop/style/hash_like_case'
@@ -477,6 +484,7 @@ require_relative 'rubocop/cop/style/identical_conditional_branches'
477
484
  require_relative 'rubocop/cop/style/if_inside_else'
478
485
  require_relative 'rubocop/cop/style/if_unless_modifier'
479
486
  require_relative 'rubocop/cop/style/if_unless_modifier_of_if_unless'
487
+ require_relative 'rubocop/cop/style/if_with_boolean_literal_branches'
480
488
  require_relative 'rubocop/cop/style/if_with_semicolon'
481
489
  require_relative 'rubocop/cop/style/implicit_runtime_error'
482
490
  require_relative 'rubocop/cop/style/infinite_loop'
@@ -597,6 +605,7 @@ require_relative 'rubocop/cop/style/trailing_method_end_statement'
597
605
  require_relative 'rubocop/cop/style/trailing_underscore_variable'
598
606
  require_relative 'rubocop/cop/style/trivial_accessors'
599
607
  require_relative 'rubocop/cop/style/unless_else'
608
+ require_relative 'rubocop/cop/style/unless_logical_operators'
600
609
  require_relative 'rubocop/cop/style/unpack_first'
601
610
  require_relative 'rubocop/cop/style/variable_interpolation'
602
611
  require_relative 'rubocop/cop/style/when_then'
@@ -9,6 +9,7 @@ module RuboCop
9
9
  self.command_name = :auto_gen_config
10
10
 
11
11
  AUTO_GENERATED_FILE = '.rubocop_todo.yml'
12
+ YAML_OPTIONAL_DOC_START = /\A---(\s+#|\s*\z)/.freeze
12
13
 
13
14
  PHASE_1 = 'Phase 1 of 2: run Layout/LineLength cop'
14
15
  PHASE_2 = 'Phase 2 of 2: run all cops'
@@ -130,10 +131,10 @@ module RuboCop
130
131
  end
131
132
 
132
133
  def write_config_file(file_name, file_string, rubocop_yml_contents)
133
- File.open(file_name, 'w') do |f|
134
- f.write "inherit_from:#{file_string}\n"
135
- f.write "\n#{rubocop_yml_contents}" if /\S/.match?(rubocop_yml_contents)
136
- end
134
+ lines = /\S/.match?(rubocop_yml_contents) ? rubocop_yml_contents.split("\n", -1) : []
135
+ doc_start_index = lines.index { |line| YAML_OPTIONAL_DOC_START.match?(line) } || -1
136
+ lines.insert(doc_start_index + 1, "inherit_from:#{file_string}\n")
137
+ File.open(file_name, 'w') { |f| f.write lines.join("\n") }
137
138
  end
138
139
  end
139
140
  end
@@ -86,7 +86,7 @@ module RuboCop
86
86
  def maybe_print_corrected_source
87
87
  # Integration tools (like RubyMine) expect to have only the JSON result
88
88
  # when specifying JSON format. Similar HTML and JUnit are targeted as well.
89
- # See: https://github.com/rubocop-hq/rubocop/issues/8673
89
+ # See: https://github.com/rubocop/rubocop/issues/8673
90
90
  return if INTEGRATION_FORMATTERS.include?(@options[:format])
91
91
 
92
92
  return unless @options[:stdin] && @options[:auto_correct]
@@ -22,7 +22,7 @@ module RuboCop
22
22
  'RuboCop extension libraries might be helpful:'
23
23
 
24
24
  extensions.sort.each do |extension|
25
- puts " * #{extension} (http://github.com/rubocop-hq/#{extension})"
25
+ puts " * #{extension} (http://github.com/rubocop/#{extension})"
26
26
  end
27
27
 
28
28
  puts
@@ -33,8 +33,11 @@ module RuboCop
33
33
  @validator = ConfigValidator.new(self)
34
34
  end
35
35
 
36
- def self.create(hash, path)
37
- new(hash, path).check
36
+ def self.create(hash, path, check: true)
37
+ config = new(hash, path)
38
+ config.check if check
39
+
40
+ config
38
41
  end
39
42
 
40
43
  def loaded_features