rubocop 0.85.0 → 0.88.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -17
  3. data/bin/rubocop-profile +31 -0
  4. data/config/default.yml +132 -11
  5. data/lib/rubocop.rb +17 -1
  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/init_dotfile.rb +1 -1
  9. data/lib/rubocop/cli/command/show_cops.rb +1 -1
  10. data/lib/rubocop/config.rb +1 -1
  11. data/lib/rubocop/config_loader.rb +39 -67
  12. data/lib/rubocop/config_loader_resolver.rb +1 -1
  13. data/lib/rubocop/config_obsoletion.rb +0 -1
  14. data/lib/rubocop/config_store.rb +4 -0
  15. data/lib/rubocop/cop/autocorrect_logic.rb +14 -24
  16. data/lib/rubocop/cop/badge.rb +1 -1
  17. data/lib/rubocop/cop/base.rb +407 -0
  18. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +10 -20
  19. data/lib/rubocop/cop/commissioner.rb +48 -50
  20. data/lib/rubocop/cop/cop.rb +91 -235
  21. data/lib/rubocop/cop/corrector.rb +38 -115
  22. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +26 -0
  23. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +7 -2
  24. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +1 -1
  25. data/lib/rubocop/cop/generator.rb +1 -1
  26. data/lib/rubocop/cop/generator/configuration_injector.rb +1 -1
  27. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +11 -14
  28. data/lib/rubocop/cop/layout/case_indentation.rb +18 -19
  29. data/lib/rubocop/cop/layout/class_structure.rb +2 -37
  30. data/lib/rubocop/cop/layout/comment_indentation.rb +3 -3
  31. data/lib/rubocop/cop/layout/empty_comment.rb +1 -1
  32. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +1 -0
  33. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +3 -8
  34. data/lib/rubocop/cop/layout/end_alignment.rb +3 -2
  35. data/lib/rubocop/cop/layout/end_of_line.rb +1 -1
  36. data/lib/rubocop/cop/layout/first_argument_indentation.rb +5 -1
  37. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +1 -1
  38. data/lib/rubocop/cop/layout/hash_alignment.rb +2 -3
  39. data/lib/rubocop/cop/layout/heredoc_indentation.rb +1 -1
  40. data/lib/rubocop/cop/layout/multiline_block_layout.rb +17 -7
  41. data/lib/rubocop/cop/layout/space_after_colon.rb +1 -1
  42. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +22 -27
  43. data/lib/rubocop/cop/layout/space_around_keyword.rb +2 -2
  44. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +27 -68
  45. data/lib/rubocop/cop/layout/space_around_operators.rb +1 -1
  46. data/lib/rubocop/cop/layout/space_before_block_braces.rb +14 -0
  47. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +4 -3
  48. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -1
  49. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +2 -2
  50. data/lib/rubocop/cop/legacy/corrections_proxy.rb +49 -0
  51. data/lib/rubocop/cop/legacy/corrector.rb +29 -0
  52. data/lib/rubocop/cop/lint/constant_resolution.rb +89 -0
  53. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +4 -4
  54. data/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb +8 -2
  55. data/lib/rubocop/cop/lint/duplicate_elsif_condition.rb +39 -0
  56. data/lib/rubocop/cop/lint/duplicate_methods.rb +2 -2
  57. data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -1
  58. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +38 -2
  59. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +3 -2
  60. data/lib/rubocop/cop/lint/interpolation_check.rb +13 -0
  61. data/lib/rubocop/cop/lint/literal_as_condition.rb +11 -1
  62. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +8 -1
  63. data/lib/rubocop/cop/lint/nested_method_definition.rb +14 -20
  64. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +69 -2
  65. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +8 -3
  66. data/lib/rubocop/cop/lint/percent_string_array.rb +1 -1
  67. data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
  68. data/lib/rubocop/cop/lint/raise_exception.rb +12 -4
  69. data/lib/rubocop/cop/lint/rand_one.rb +1 -1
  70. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +31 -25
  71. data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +2 -2
  72. data/lib/rubocop/cop/lint/regexp_as_condition.rb +6 -0
  73. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +9 -1
  74. data/lib/rubocop/cop/lint/suppressed_exception.rb +1 -1
  75. data/lib/rubocop/cop/lint/syntax.rb +11 -26
  76. data/lib/rubocop/cop/lint/unused_method_argument.rb +1 -1
  77. data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -1
  78. data/lib/rubocop/cop/metrics/block_length.rb +22 -0
  79. data/lib/rubocop/cop/metrics/class_length.rb +25 -2
  80. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +35 -3
  81. data/lib/rubocop/cop/metrics/method_length.rb +23 -0
  82. data/lib/rubocop/cop/metrics/module_length.rb +25 -2
  83. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +1 -1
  84. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +129 -0
  85. data/lib/rubocop/cop/metrics/utils/iterating_block.rb +61 -0
  86. data/lib/rubocop/cop/mixin/allowed_methods.rb +19 -0
  87. data/lib/rubocop/cop/mixin/auto_corrector.rb +12 -0
  88. data/lib/rubocop/cop/mixin/code_length.rb +4 -0
  89. data/lib/rubocop/cop/mixin/configurable_formatting.rb +1 -1
  90. data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
  91. data/lib/rubocop/cop/mixin/documentation_comment.rb +2 -2
  92. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
  93. data/lib/rubocop/cop/mixin/enforce_superclass.rb +3 -1
  94. data/lib/rubocop/cop/mixin/first_element_line_break.rb +1 -1
  95. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +1 -1
  96. data/lib/rubocop/cop/mixin/nil_methods.rb +3 -5
  97. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +6 -1
  98. data/lib/rubocop/cop/mixin/parentheses.rb +1 -2
  99. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +1 -1
  100. data/lib/rubocop/cop/mixin/range_help.rb +1 -1
  101. data/lib/rubocop/cop/mixin/regexp_literal_help.rb +27 -0
  102. data/lib/rubocop/cop/mixin/statement_modifier.rb +3 -3
  103. data/lib/rubocop/cop/mixin/string_literals_help.rb +1 -1
  104. data/lib/rubocop/cop/mixin/surrounding_space.rb +10 -5
  105. data/lib/rubocop/cop/mixin/too_many_lines.rb +3 -13
  106. data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
  107. data/lib/rubocop/cop/mixin/uncommunicative_name.rb +6 -4
  108. data/lib/rubocop/cop/mixin/visibility_help.rb +50 -0
  109. data/lib/rubocop/cop/naming/ascii_identifiers.rb +27 -4
  110. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +3 -3
  111. data/lib/rubocop/cop/naming/file_name.rb +1 -3
  112. data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +1 -1
  113. data/lib/rubocop/cop/naming/method_name.rb +1 -1
  114. data/lib/rubocop/cop/naming/method_parameter_name.rb +1 -1
  115. data/lib/rubocop/cop/naming/predicate_name.rb +3 -5
  116. data/lib/rubocop/cop/naming/variable_name.rb +1 -1
  117. data/lib/rubocop/cop/naming/variable_number.rb +1 -1
  118. data/lib/rubocop/cop/offense.rb +16 -2
  119. data/lib/rubocop/cop/registry.rb +62 -7
  120. data/lib/rubocop/cop/style/accessor_grouping.rb +147 -0
  121. data/lib/rubocop/cop/style/array_coercion.rb +63 -0
  122. data/lib/rubocop/cop/style/auto_resource_cleanup.rb +3 -2
  123. data/lib/rubocop/cop/style/bare_percent_literals.rb +1 -1
  124. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +146 -0
  125. data/lib/rubocop/cop/style/block_delimiters.rb +2 -4
  126. data/lib/rubocop/cop/style/case_like_if.rb +217 -0
  127. data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
  128. data/lib/rubocop/cop/style/class_vars.rb +21 -0
  129. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  130. data/lib/rubocop/cop/style/commented_keyword.rb +5 -2
  131. data/lib/rubocop/cop/style/conditional_assignment.rb +2 -2
  132. data/lib/rubocop/cop/style/copyright.rb +3 -3
  133. data/lib/rubocop/cop/style/date_time.rb +1 -1
  134. data/lib/rubocop/cop/style/dir.rb +2 -2
  135. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +1 -1
  136. data/lib/rubocop/cop/style/documentation.rb +2 -2
  137. data/lib/rubocop/cop/style/empty_case_condition.rb +8 -6
  138. data/lib/rubocop/cop/style/empty_literal.rb +5 -5
  139. data/lib/rubocop/cop/style/encoding.rb +1 -1
  140. data/lib/rubocop/cop/style/expand_path_arguments.rb +2 -2
  141. data/lib/rubocop/cop/style/exponential_notation.rb +8 -10
  142. data/lib/rubocop/cop/style/float_division.rb +7 -10
  143. data/lib/rubocop/cop/style/format_string_token.rb +5 -5
  144. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
  145. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +62 -0
  146. data/lib/rubocop/cop/style/hash_like_case.rb +76 -0
  147. data/lib/rubocop/cop/style/identical_conditional_branches.rb +1 -1
  148. data/lib/rubocop/cop/style/if_inside_else.rb +1 -1
  149. data/lib/rubocop/cop/style/if_unless_modifier.rb +11 -11
  150. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +12 -0
  151. data/lib/rubocop/cop/style/inverse_methods.rb +1 -1
  152. data/lib/rubocop/cop/style/ip_addresses.rb +1 -1
  153. data/lib/rubocop/cop/style/missing_else.rb +1 -11
  154. data/lib/rubocop/cop/style/multiline_block_chain.rb +10 -1
  155. data/lib/rubocop/cop/style/multiline_if_then.rb +1 -1
  156. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +17 -6
  157. data/lib/rubocop/cop/style/mutable_constant.rb +4 -4
  158. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +2 -5
  159. data/lib/rubocop/cop/style/nested_ternary_operator.rb +27 -0
  160. data/lib/rubocop/cop/style/next.rb +2 -2
  161. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +2 -2
  162. data/lib/rubocop/cop/style/numeric_predicate.rb +3 -4
  163. data/lib/rubocop/cop/style/parallel_assignment.rb +3 -3
  164. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
  165. data/lib/rubocop/cop/style/proc.rb +1 -1
  166. data/lib/rubocop/cop/style/random_with_offset.rb +4 -10
  167. data/lib/rubocop/cop/style/redundant_assignment.rb +117 -0
  168. data/lib/rubocop/cop/style/redundant_conditional.rb +4 -3
  169. data/lib/rubocop/cop/style/redundant_exception.rb +14 -10
  170. data/lib/rubocop/cop/style/redundant_fetch_block.rb +122 -0
  171. data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +50 -0
  172. data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
  173. data/lib/rubocop/cop/style/redundant_parentheses.rb +8 -2
  174. data/lib/rubocop/cop/style/redundant_percent_q.rb +2 -2
  175. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +4 -3
  176. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +14 -23
  177. data/lib/rubocop/cop/style/redundant_self.rb +6 -9
  178. data/lib/rubocop/cop/style/redundant_sort.rb +3 -2
  179. data/lib/rubocop/cop/style/rescue_standard_error.rb +1 -1
  180. data/lib/rubocop/cop/style/sample.rb +1 -1
  181. data/lib/rubocop/cop/style/semicolon.rb +1 -1
  182. data/lib/rubocop/cop/style/signal_exception.rb +1 -1
  183. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +3 -2
  184. data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
  185. data/lib/rubocop/cop/style/struct_inheritance.rb +23 -2
  186. data/lib/rubocop/cop/style/symbol_array.rb +5 -5
  187. data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
  188. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
  189. data/lib/rubocop/cop/style/trailing_method_end_statement.rb +9 -32
  190. data/lib/rubocop/cop/style/trivial_accessors.rb +8 -7
  191. data/lib/rubocop/cop/style/word_array.rb +1 -1
  192. data/lib/rubocop/cop/style/yoda_condition.rb +18 -1
  193. data/lib/rubocop/cop/style/zero_length_predicate.rb +2 -2
  194. data/lib/rubocop/cop/team.rb +105 -81
  195. data/lib/rubocop/cop/util.rb +2 -2
  196. data/lib/rubocop/cop/utils/format_string.rb +19 -2
  197. data/lib/rubocop/cop/variable_force/variable.rb +5 -3
  198. data/lib/rubocop/file_finder.rb +12 -12
  199. data/lib/rubocop/formatter/disabled_config_formatter.rb +2 -2
  200. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  201. data/lib/rubocop/name_similarity.rb +7 -3
  202. data/lib/rubocop/options.rb +15 -8
  203. data/lib/rubocop/path_util.rb +4 -19
  204. data/lib/rubocop/platform.rb +1 -1
  205. data/lib/rubocop/rake_task.rb +6 -9
  206. data/lib/rubocop/result_cache.rb +12 -8
  207. data/lib/rubocop/rspec/cop_helper.rb +4 -4
  208. data/lib/rubocop/rspec/expect_offense.rb +65 -21
  209. data/lib/rubocop/rspec/shared_contexts.rb +19 -16
  210. data/lib/rubocop/runner.rb +34 -33
  211. data/lib/rubocop/target_finder.rb +3 -3
  212. data/lib/rubocop/target_ruby.rb +2 -2
  213. data/lib/rubocop/version.rb +1 -1
  214. metadata +34 -9
  215. data/lib/rubocop/cop/mixin/classish_length.rb +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: edfaa1a180e5c318e672651ae7e4c75625a41a4c247d3ce378f6e25e809a4277
4
- data.tar.gz: 8ce15a32ddd8181b7b5117214d00a795f8824cbd13282120545fc7dd58548137
3
+ metadata.gz: f95eb2bcf68a27cd9069d1e7cf4fa1b9f4eb499649ccb8c60dcc7327b8bad6b1
4
+ data.tar.gz: 693a6483669b3c11ba0c181b5c1d502c937f34ea73b44710062f9a2a58b34c09
5
5
  SHA512:
6
- metadata.gz: 57f80040236ae265d1478fecbbe20ebfd27905d52cd2c06d83202d2a8d7fe426feb774d63788fd38942872a12c18c247896e89f21c7010259ab1902cb5034177
7
- data.tar.gz: b86dcfcaa1839b9f3a7d532d87c1574e712df8018bfb3f85f06e4d2ecc1bb174018458fd2ee5f853def55f2312da8ab8b3037ea3be0defff4c16f4bbbeb6cf5d
6
+ metadata.gz: a49ca9e1823323f4478552d8217eb924d42e451b909169893e74ce3164c4438a6fce3d2222b1cfc08dc8f88131eae488dee6a98865887e561a8f298a3456dc07
7
+ data.tar.gz: 516d28b2f1d612e9e5a0abfd364ecab6940ef68ec0c2e755b170c43e1961621041b6346478fb59f044494e9d5c9300bfa1307bd580968468586b755b40fc161e
data/README.md CHANGED
@@ -1,9 +1,14 @@
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/rubocop-hq/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
3
+ </p>
4
+
5
+ ----------
6
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
1
7
  [![Gem Version](https://badge.fury.io/rb/rubocop.svg)](https://badge.fury.io/rb/rubocop)
2
8
  [![CircleCI Status](https://circleci.com/gh/rubocop-hq/rubocop/tree/master.svg?style=svg)](https://circleci.com/gh/rubocop-hq/rubocop/tree/master)
3
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)
4
- [![Coverage Status](https://api.codeclimate.com/v1/badges/ad6e76460499c8c99697/test_coverage)](https://codeclimate.com/github/bbatsov/rubocop)
5
- [![Code Climate](https://codeclimate.com/github/bbatsov/rubocop/badges/gpa.svg)](https://codeclimate.com/github/bbatsov/rubocop)
6
- [![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)
7
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)
8
13
 
9
14
  [![Patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://www.patreon.com/bbatsov)
@@ -11,26 +16,17 @@
11
16
  [![OpenCollective](https://opencollective.com/rubocop/sponsors/badge.svg)](#open-collective-sponsors)
12
17
  [![Tidelift](https://tidelift.com/badges/package/rubygems/rubocop)](https://tidelift.com/subscription/pkg/rubygems-rubocop?utm_source=rubygems-rubocop&utm_medium=referral&utm_campaign=readme)
13
18
 
14
- <p align="center">
15
- <img src="https://raw.githubusercontent.com/rubocop-hq/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
16
- </p>
17
-
18
19
  > Role models are important. <br/>
19
20
  > -- Officer Alex J. Murphy / RoboCop
20
21
 
21
- **RuboCop** is a Ruby static code analyzer and code formatter. Out of
22
- the box it will enforce many of the guidelines outlined in the
23
- community [Ruby Style
24
- Guide](https://rubystyle.guide).
22
+ **RuboCop** is a Ruby static code analyzer (a.k.a. `linter`) and code formatter. Out of the box it
23
+ will enforce many of the guidelines outlined in the community [Ruby Style
24
+ Guide](https://rubystyle.guide). Apart from reporting the problems discovered in your code,
25
+ RuboCop can also automatically fix many of them you.
25
26
 
26
27
  RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various
27
28
  [configuration options](https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml).
28
29
 
29
- Apart from reporting problems in your code, RuboCop can also
30
- automatically fix some of the problems for you.
31
-
32
- [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bbatsov/rubocop?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
33
-
34
30
  **Please consider [financially supporting its ongoing development](#funding).**
35
31
 
36
32
  ## Installation
@@ -53,7 +49,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
53
49
  might want to use a conservative version lock in your `Gemfile`:
54
50
 
55
51
  ```rb
56
- gem 'rubocop', '~> 0.85.0', require: false
52
+ gem 'rubocop', '~> 0.88.0', require: false
57
53
  ```
58
54
 
59
55
  ## Quickstart
@@ -76,6 +72,16 @@ RuboCop supports the following Ruby implementations:
76
72
  * MRI 2.4+
77
73
  * JRuby 9.2+
78
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
+
79
85
  ## Team
80
86
 
81
87
  Here's a list of RuboCop's core developers:
@@ -88,6 +94,8 @@ Here's a list of RuboCop's core developers:
88
94
  * [Masataka Kuwabara](https://github.com/pocke)
89
95
  * [Koichi Ito](https://github.com/koic)
90
96
  * [Maxim Krizhanovski](https://github.com/darhazer)
97
+ * [Benjamin Quorning](https://github.com/bquorning)
98
+ * [Marc-André Lafortune](https://github.com/marcandre)
91
99
 
92
100
  ## Logo
93
101
 
@@ -0,0 +1,31 @@
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
+
11
+ require 'stackprof'
12
+ if with_mem
13
+ require 'memory_profiler'
14
+ MemoryProfiler.start
15
+ end
16
+ StackProf.start
17
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
18
+ begin
19
+ load "#{__dir__}/../exe/rubocop"
20
+ ensure
21
+ delta = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
22
+ puts "Finished in #{delta.round(1)} seconds"
23
+ StackProf.stop
24
+ if with_mem
25
+ puts "Building memory report..."
26
+ report = MemoryProfiler.stop
27
+ end
28
+ Dir.mkdir('tmp') unless File.exist?('tmp')
29
+ StackProf.results('tmp/stackprof.dump')
30
+ report&.pretty_print(scale_bytes: true)
31
+ 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,6 +203,9 @@ 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
 
@@ -1361,6 +1367,15 @@ Lint/CircularArgumentReference:
1361
1367
  Enabled: true
1362
1368
  VersionAdded: '0.33'
1363
1369
 
1370
+ Lint/ConstantResolution:
1371
+ Description: 'Check that constants are fully qualified with `::`.'
1372
+ Enabled: false
1373
+ VersionAdded: '0.86'
1374
+ # Restrict this cop to only looking at certain names
1375
+ Only: []
1376
+ # Restrict this cop from only looking at certain names
1377
+ Ignore: []
1378
+
1364
1379
  Lint/Debugger:
1365
1380
  Description: 'Check for debugger calls.'
1366
1381
  Enabled: true
@@ -1382,12 +1397,18 @@ Lint/DisjunctiveAssignmentInConstructor:
1382
1397
  Enabled: true
1383
1398
  Safe: false
1384
1399
  VersionAdded: '0.62'
1400
+ VersionChanged: '0.88'
1385
1401
 
1386
1402
  Lint/DuplicateCaseCondition:
1387
1403
  Description: 'Do not repeat values in case conditionals.'
1388
1404
  Enabled: true
1389
1405
  VersionAdded: '0.45'
1390
1406
 
1407
+ Lint/DuplicateElsifCondition:
1408
+ Description: 'Do not repeat conditions used in if `elsif`.'
1409
+ Enabled: 'pending'
1410
+ VersionAdded: '0.88'
1411
+
1391
1412
  Lint/DuplicateHashKey:
1392
1413
  Description: 'Check for duplicate keys in hash literals.'
1393
1414
  Enabled: true
@@ -1499,7 +1520,9 @@ Lint/InheritException:
1499
1520
  Lint/InterpolationCheck:
1500
1521
  Description: 'Raise warning for interpolation in single q strs.'
1501
1522
  Enabled: true
1523
+ SafeAutoCorrect: false
1502
1524
  VersionAdded: '0.50'
1525
+ VersionChanged: '0.87'
1503
1526
 
1504
1527
  Lint/LiteralAsCondition:
1505
1528
  Description: 'Checks of literals used in conditions.'
@@ -1611,7 +1634,9 @@ Lint/RaiseException:
1611
1634
  Description: Checks for `raise` or `fail` statements which are raising `Exception` class.
1612
1635
  StyleGuide: '#raise-exception'
1613
1636
  Enabled: pending
1637
+ Safe: false
1614
1638
  VersionAdded: '0.81'
1639
+ VersionChanged: '0.86'
1615
1640
  AllowedImplicitNamespaces:
1616
1641
  - 'Gem'
1617
1642
 
@@ -1668,6 +1693,7 @@ Lint/RegexpAsCondition:
1668
1693
  The regexp literal matches `$_` implicitly.
1669
1694
  Enabled: true
1670
1695
  VersionAdded: '0.51'
1696
+ VersionChanged: '0.86'
1671
1697
 
1672
1698
  Lint/RequireParentheses:
1673
1699
  Description: >-
@@ -1724,6 +1750,7 @@ Lint/SafeNavigationWithEmpty:
1724
1750
  Description: 'Avoid `foo&.empty?` in conditionals.'
1725
1751
  Enabled: true
1726
1752
  VersionAdded: '0.62'
1753
+ VersionChanged: '0.87'
1727
1754
 
1728
1755
  Lint/ScriptPermission:
1729
1756
  Description: 'Grant script file execute permission.'
@@ -1890,9 +1917,10 @@ Metrics/BlockLength:
1890
1917
  Description: 'Avoid long blocks with many lines.'
1891
1918
  Enabled: true
1892
1919
  VersionAdded: '0.44'
1893
- VersionChanged: '0.66'
1920
+ VersionChanged: '0.87'
1894
1921
  CountComments: false # count full line comments?
1895
1922
  Max: 25
1923
+ CountAsOne: []
1896
1924
  ExcludedMethods:
1897
1925
  # By default, exclude the `#refine` method, as it tends to have larger
1898
1926
  # associated blocks.
@@ -1913,8 +1941,10 @@ Metrics/ClassLength:
1913
1941
  Description: 'Avoid classes longer than 100 lines of code.'
1914
1942
  Enabled: true
1915
1943
  VersionAdded: '0.25'
1944
+ VersionChanged: '0.87'
1916
1945
  CountComments: false # count full line comments?
1917
1946
  Max: 100
1947
+ CountAsOne: []
1918
1948
 
1919
1949
  # Avoid complex methods.
1920
1950
  Metrics/CyclomaticComplexity:
@@ -1925,24 +1955,27 @@ Metrics/CyclomaticComplexity:
1925
1955
  VersionAdded: '0.25'
1926
1956
  VersionChanged: '0.81'
1927
1957
  IgnoredMethods: []
1928
- Max: 6
1958
+ Max: 7
1929
1959
 
1930
1960
  Metrics/MethodLength:
1931
1961
  Description: 'Avoid methods longer than 10 lines of code.'
1932
1962
  StyleGuide: '#short-methods'
1933
1963
  Enabled: true
1934
1964
  VersionAdded: '0.25'
1935
- VersionChanged: '0.59.2'
1965
+ VersionChanged: '0.87'
1936
1966
  CountComments: false # count full line comments?
1937
1967
  Max: 10
1968
+ CountAsOne: []
1938
1969
  ExcludedMethods: []
1939
1970
 
1940
1971
  Metrics/ModuleLength:
1941
1972
  Description: 'Avoid modules longer than 100 lines of code.'
1942
1973
  Enabled: true
1943
1974
  VersionAdded: '0.31'
1975
+ VersionChanged: '0.87'
1944
1976
  CountComments: false # count full line comments?
1945
1977
  Max: 100
1978
+ CountAsOne: []
1946
1979
 
1947
1980
  Metrics/ParameterLists:
1948
1981
  Description: 'Avoid parameter lists longer than three or four parameters.'
@@ -1980,10 +2013,12 @@ Naming/AccessorMethodName:
1980
2013
  VersionAdded: '0.50'
1981
2014
 
1982
2015
  Naming/AsciiIdentifiers:
1983
- Description: 'Use only ascii symbols in identifiers.'
2016
+ Description: 'Use only ascii symbols in identifiers and constants.'
1984
2017
  StyleGuide: '#english-identifiers'
1985
2018
  Enabled: true
1986
2019
  VersionAdded: '0.50'
2020
+ VersionChanged: '0.87'
2021
+ AsciiConstants: true
1987
2022
 
1988
2023
  Naming/BinaryOperatorParameterName:
1989
2024
  Description: 'When defining binary operators, name the argument other.'
@@ -2150,17 +2185,18 @@ Naming/MethodParameterName:
2150
2185
  AllowNamesEndingInNumbers: true
2151
2186
  # Allowed names that will not register an offense
2152
2187
  AllowedNames:
2153
- - io
2154
- - id
2155
- - to
2188
+ - at
2156
2189
  - by
2157
- - 'on'
2190
+ - db
2191
+ - id
2158
2192
  - in
2159
- - at
2193
+ - io
2160
2194
  - ip
2161
- - db
2195
+ - of
2196
+ - 'on'
2162
2197
  - os
2163
2198
  - pp
2199
+ - to
2164
2200
  # Forbidden names that will register an offense
2165
2201
  ForbiddenNames: []
2166
2202
 
@@ -2276,6 +2312,17 @@ Style/AccessModifierDeclarations:
2276
2312
  - group
2277
2313
  AllowModifiersOnSymbols: true
2278
2314
 
2315
+ Style/AccessorGrouping:
2316
+ Description: 'Checks for grouping of accessors in `class` and `module` bodies.'
2317
+ Enabled: 'pending'
2318
+ VersionAdded: '0.87'
2319
+ EnforcedStyle: grouped
2320
+ SupportedStyles:
2321
+ # separated: each accessor goes in a separate statement.
2322
+ # grouped: accessors are grouped into a single statement.
2323
+ - separated
2324
+ - grouped
2325
+
2279
2326
  Style/Alias:
2280
2327
  Description: 'Use alias instead of alias_method.'
2281
2328
  StyleGuide: '#alias-method-lexically'
@@ -2300,6 +2347,14 @@ Style/AndOr:
2300
2347
  - always
2301
2348
  - conditionals
2302
2349
 
2350
+ Style/ArrayCoercion:
2351
+ Description: >-
2352
+ Use Array() instead of explicit Array check or [*var], when dealing
2353
+ with a variable you want to treat as an Array, but you're not certain it's an array.
2354
+ StyleGuide: '#array-coercion'
2355
+ Enabled: 'pending'
2356
+ VersionAdded: '0.88'
2357
+
2303
2358
  Style/ArrayJoin:
2304
2359
  Description: 'Use Array#join instead of Array#*.'
2305
2360
  StyleGuide: '#array-join'
@@ -2343,6 +2398,13 @@ Style/BeginBlock:
2343
2398
  Enabled: true
2344
2399
  VersionAdded: '0.9'
2345
2400
 
2401
+ Style/BisectedAttrAccessor:
2402
+ Description: >-
2403
+ Checks for places where `attr_reader` and `attr_writer`
2404
+ for the same method can be combined into single `attr_accessor`.
2405
+ Enabled: 'pending'
2406
+ VersionAdded: '0.87'
2407
+
2346
2408
  Style/BlockComments:
2347
2409
  Description: 'Do not use block comments.'
2348
2410
  StyleGuide: '#no-block-comments'
@@ -2475,6 +2537,12 @@ Style/CaseEquality:
2475
2537
  # String === "string"
2476
2538
  AllowOnConstant: false
2477
2539
 
2540
+ Style/CaseLikeIf:
2541
+ Description: 'This cop identifies places where `if-elsif` constructions can be replaced with `case-when`.'
2542
+ StyleGuide: '#case-vs-if-else'
2543
+ Enabled: 'pending'
2544
+ VersionAdded: '0.88'
2545
+
2478
2546
  Style/CharacterLiteral:
2479
2547
  Description: 'Checks for uses of character literals.'
2480
2548
  StyleGuide: '#no-character-literals'
@@ -2717,6 +2785,7 @@ Style/DoubleNegation:
2717
2785
  VersionAdded: '0.19'
2718
2786
  VersionChanged: '0.84'
2719
2787
  EnforcedStyle: allowed_in_returns
2788
+ SafeAutoCorrect: false
2720
2789
  SupportedStyles:
2721
2790
  - allowed_in_returns
2722
2791
  - forbidden
@@ -2913,6 +2982,18 @@ Style/GuardClause:
2913
2982
  # needs to have to trigger this cop
2914
2983
  MinBodyLength: 1
2915
2984
 
2985
+ Style/HashAsLastArrayItem:
2986
+ Description: >-
2987
+ Checks for presence or absence of braces around hash literal as a last
2988
+ array item depending on configuration.
2989
+ StyleGuide: '#hash-literal-as-last-array-item'
2990
+ Enabled: 'pending'
2991
+ VersionAdded: '0.88'
2992
+ EnforcedStyle: braces
2993
+ SupportedStyles:
2994
+ - braces
2995
+ - no_braces
2996
+
2916
2997
  Style/HashEachMethods:
2917
2998
  Description: 'Use Hash#each_key and Hash#each_value.'
2918
2999
  StyleGuide: '#hash-each'
@@ -2920,6 +3001,16 @@ Style/HashEachMethods:
2920
3001
  VersionAdded: '0.80'
2921
3002
  Safe: false
2922
3003
 
3004
+ Style/HashLikeCase:
3005
+ Description: >-
3006
+ Checks for places where `case-when` represents a simple 1:1
3007
+ mapping and can be replaced with a hash lookup.
3008
+ Enabled: 'pending'
3009
+ VersionAdded: '0.88'
3010
+ # `MinBranchesCount` defines the number of branches `case` needs to have
3011
+ # to trigger this cop
3012
+ MinBranchesCount: 3
3013
+
2923
3014
  Style/HashSyntax:
2924
3015
  Description: >-
2925
3016
  Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
@@ -2983,6 +3074,7 @@ Style/IfUnlessModifierOfIfUnless:
2983
3074
  Avoid modifier if/unless usage on conditionals.
2984
3075
  Enabled: true
2985
3076
  VersionAdded: '0.39'
3077
+ VersionChanged: '0.87'
2986
3078
 
2987
3079
  Style/IfWithSemicolon:
2988
3080
  Description: 'Do not use if x; .... Use the ternary operator instead.'
@@ -3239,6 +3331,7 @@ Style/MultilineTernaryOperator:
3239
3331
  StyleGuide: '#no-multiline-ternary'
3240
3332
  Enabled: true
3241
3333
  VersionAdded: '0.9'
3334
+ VersionChanged: '0.86'
3242
3335
 
3243
3336
  Style/MultilineWhenThen:
3244
3337
  Description: 'Do not use then for multi-line when statement.'
@@ -3343,6 +3436,7 @@ Style/NestedTernaryOperator:
3343
3436
  StyleGuide: '#no-nested-ternary'
3344
3437
  Enabled: true
3345
3438
  VersionAdded: '0.9'
3439
+ VersionChanged: '0.86'
3346
3440
 
3347
3441
  Style/Next:
3348
3442
  Description: 'Use `next` to skip iteration instead of a condition at the end.'
@@ -3567,6 +3661,11 @@ Style/RandomWithOffset:
3567
3661
  Enabled: true
3568
3662
  VersionAdded: '0.52'
3569
3663
 
3664
+ Style/RedundantAssignment:
3665
+ Description: 'Checks for redundant assignment before returning.'
3666
+ Enabled: 'pending'
3667
+ VersionAdded: '0.87'
3668
+
3570
3669
  Style/RedundantBegin:
3571
3670
  Description: "Don't use begin blocks when they are not needed."
3572
3671
  StyleGuide: '#begin-implicit'
@@ -3596,6 +3695,27 @@ Style/RedundantException:
3596
3695
  VersionAdded: '0.14'
3597
3696
  VersionChanged: '0.29'
3598
3697
 
3698
+ Style/RedundantFetchBlock:
3699
+ Description: >-
3700
+ Use `fetch(key, value)` instead of `fetch(key) { value }`
3701
+ when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
3702
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
3703
+ Enabled: 'pending'
3704
+ Safe: false
3705
+ # If enabled, this cop will autocorrect usages of
3706
+ # `fetch` being called with block returning a constant.
3707
+ # This can be dangerous since constants will not be defined at that moment.
3708
+ SafeForConstants: false
3709
+ VersionAdded: '0.86'
3710
+
3711
+ Style/RedundantFileExtensionInRequire:
3712
+ Description: >-
3713
+ Checks for the presence of superfluous `.rb` extension in
3714
+ the filename provided to `require` and `require_relative`.
3715
+ StyleGuide: '#no-explicit-rb-to-require'
3716
+ Enabled: 'pending'
3717
+ VersionAdded: '0.88'
3718
+
3599
3719
  Style/RedundantFreeze:
3600
3720
  Description: "Checks usages of Object#freeze on immutable objects."
3601
3721
  Enabled: true
@@ -3875,6 +3995,7 @@ Style/StructInheritance:
3875
3995
  StyleGuide: '#no-extend-struct-new'
3876
3996
  Enabled: true
3877
3997
  VersionAdded: '0.29'
3998
+ VersionChanged: '0.86'
3878
3999
 
3879
4000
  Style/SymbolArray:
3880
4001
  Description: 'Use %i or %I for arrays of symbols.'
@@ -3896,7 +4017,7 @@ Style/SymbolLiteral:
3896
4017
  Style/SymbolProc:
3897
4018
  Description: 'Use symbols as procs instead of blocks when possible.'
3898
4019
  Enabled: true
3899
- SafeAutoCorrect: false
4020
+ Safe: false
3900
4021
  VersionAdded: '0.26'
3901
4022
  VersionChanged: '0.64'
3902
4023
  # A list of method names to be ignored by the check.