rubocop 0.78.0 → 0.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +4 -4
  4. data/config/default.yml +158 -48
  5. data/lib/rubocop.rb +19 -4
  6. data/lib/rubocop/ast/builder.rb +45 -42
  7. data/lib/rubocop/ast/node.rb +12 -19
  8. data/lib/rubocop/ast/node/array_node.rb +13 -0
  9. data/lib/rubocop/ast/node/block_node.rb +5 -1
  10. data/lib/rubocop/ast/node/case_match_node.rb +56 -0
  11. data/lib/rubocop/ast/node/def_node.rb +11 -0
  12. data/lib/rubocop/ast/node/forward_args_node.rb +18 -0
  13. data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +8 -0
  14. data/lib/rubocop/ast/node/regexp_node.rb +2 -4
  15. data/lib/rubocop/ast/traversal.rb +29 -10
  16. data/lib/rubocop/cli.rb +10 -4
  17. data/lib/rubocop/cli/command/show_cops.rb +11 -4
  18. data/lib/rubocop/comment_config.rb +6 -1
  19. data/lib/rubocop/config.rb +36 -10
  20. data/lib/rubocop/config_loader.rb +42 -33
  21. data/lib/rubocop/config_loader_resolver.rb +1 -1
  22. data/lib/rubocop/config_obsoletion.rb +4 -1
  23. data/lib/rubocop/config_validator.rb +66 -92
  24. data/lib/rubocop/cop/autocorrect_logic.rb +6 -3
  25. data/lib/rubocop/cop/badge.rb +5 -5
  26. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
  27. data/lib/rubocop/cop/corrector.rb +48 -24
  28. data/lib/rubocop/cop/correctors/alignment_corrector.rb +2 -2
  29. data/lib/rubocop/cop/correctors/condition_corrector.rb +1 -2
  30. data/lib/rubocop/cop/correctors/empty_line_corrector.rb +1 -1
  31. data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +3 -3
  32. data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -2
  33. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
  34. data/lib/rubocop/cop/correctors/string_literal_corrector.rb +2 -2
  35. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
  36. data/lib/rubocop/cop/generator.rb +3 -4
  37. data/lib/rubocop/cop/generator/configuration_injector.rb +1 -1
  38. data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +1 -1
  39. data/lib/rubocop/cop/layout/array_alignment.rb +53 -10
  40. data/lib/rubocop/cop/layout/block_end_newline.rb +5 -3
  41. data/lib/rubocop/cop/layout/dot_position.rb +1 -1
  42. data/lib/rubocop/cop/layout/else_alignment.rb +8 -0
  43. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +2 -1
  44. data/lib/rubocop/cop/layout/end_of_line.rb +2 -2
  45. data/lib/rubocop/cop/layout/first_array_element_indentation.rb +16 -10
  46. data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +1 -1
  47. data/lib/rubocop/cop/layout/hash_alignment.rb +8 -4
  48. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
  49. data/lib/rubocop/cop/layout/heredoc_indentation.rb +2 -2
  50. data/lib/rubocop/cop/layout/{tab.rb → indentation_style.rb} +48 -6
  51. data/lib/rubocop/cop/layout/leading_comment_space.rb +34 -3
  52. data/lib/rubocop/cop/layout/line_length.rb +32 -3
  53. data/lib/rubocop/cop/layout/multiline_block_layout.rb +15 -6
  54. data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +0 -4
  55. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +1 -1
  56. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +3 -3
  57. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +133 -0
  58. data/lib/rubocop/cop/layout/space_around_operators.rb +19 -1
  59. data/lib/rubocop/cop/layout/space_before_block_braces.rb +2 -2
  60. data/lib/rubocop/cop/layout/space_before_first_arg.rb +8 -0
  61. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +1 -1
  62. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +2 -2
  63. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +2 -9
  64. data/lib/rubocop/cop/layout/space_inside_range_literal.rb +2 -2
  65. data/lib/rubocop/cop/lint/boolean_symbol.rb +12 -0
  66. data/lib/rubocop/cop/lint/debugger.rb +2 -2
  67. data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -1
  68. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
  69. data/lib/rubocop/cop/lint/inherit_exception.rb +1 -1
  70. data/lib/rubocop/cop/lint/interpolation_check.rb +1 -1
  71. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
  72. data/lib/rubocop/cop/lint/loop.rb +6 -4
  73. data/lib/rubocop/cop/lint/multiple_comparison.rb +1 -1
  74. data/lib/rubocop/cop/lint/nested_method_definition.rb +2 -2
  75. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +2 -2
  76. data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
  77. data/lib/rubocop/cop/lint/percent_string_array.rb +2 -2
  78. data/lib/rubocop/cop/lint/raise_exception.rb +75 -0
  79. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +1 -1
  80. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +12 -7
  81. data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -1
  82. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -1
  83. data/lib/rubocop/cop/lint/struct_new_override.rb +58 -0
  84. data/lib/rubocop/cop/lint/suppressed_exception.rb +12 -22
  85. data/lib/rubocop/cop/lint/unified_integer.rb +0 -2
  86. data/lib/rubocop/cop/lint/unused_method_argument.rb +32 -6
  87. data/lib/rubocop/cop/lint/uri_regexp.rb +4 -4
  88. data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -0
  89. data/lib/rubocop/cop/migration/department_name.rb +47 -6
  90. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +4 -0
  91. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +6 -1
  92. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +7 -7
  93. data/lib/rubocop/cop/mixin/hash_transform_method.rb +171 -0
  94. data/lib/rubocop/cop/mixin/line_length_help.rb +1 -1
  95. data/lib/rubocop/cop/mixin/method_complexity.rb +5 -0
  96. data/lib/rubocop/cop/mixin/statement_modifier.rb +4 -3
  97. data/lib/rubocop/cop/mixin/trailing_comma.rb +3 -10
  98. data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +1 -1
  99. data/lib/rubocop/cop/naming/constant_name.rb +2 -1
  100. data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +1 -1
  101. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
  102. data/lib/rubocop/cop/naming/method_name.rb +30 -0
  103. data/lib/rubocop/cop/naming/method_parameter_name.rb +1 -1
  104. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
  105. data/lib/rubocop/cop/registry.rb +15 -3
  106. data/lib/rubocop/cop/style/access_modifier_declarations.rb +26 -6
  107. data/lib/rubocop/cop/style/alias.rb +4 -4
  108. data/lib/rubocop/cop/style/and_or.rb +5 -6
  109. data/lib/rubocop/cop/style/array_join.rb +1 -1
  110. data/lib/rubocop/cop/style/block_delimiters.rb +60 -1
  111. data/lib/rubocop/cop/style/case_equality.rb +24 -1
  112. data/lib/rubocop/cop/style/character_literal.rb +2 -2
  113. data/lib/rubocop/cop/style/collection_methods.rb +2 -0
  114. data/lib/rubocop/cop/style/conditional_assignment.rb +8 -8
  115. data/lib/rubocop/cop/style/copyright.rb +1 -1
  116. data/lib/rubocop/cop/style/dir.rb +1 -1
  117. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +49 -0
  118. data/lib/rubocop/cop/style/documentation.rb +43 -5
  119. data/lib/rubocop/cop/style/double_cop_disable_directive.rb +1 -1
  120. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  121. data/lib/rubocop/cop/style/each_with_object.rb +3 -3
  122. data/lib/rubocop/cop/style/empty_method.rb +1 -1
  123. data/lib/rubocop/cop/style/end_block.rb +6 -0
  124. data/lib/rubocop/cop/style/even_odd.rb +1 -1
  125. data/lib/rubocop/cop/style/expand_path_arguments.rb +3 -3
  126. data/lib/rubocop/cop/style/exponential_notation.rb +119 -0
  127. data/lib/rubocop/cop/style/format_string.rb +2 -2
  128. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +89 -11
  129. data/lib/rubocop/cop/style/hash_each_methods.rb +89 -0
  130. data/lib/rubocop/cop/style/hash_syntax.rb +3 -5
  131. data/lib/rubocop/cop/style/hash_transform_keys.rb +83 -0
  132. data/lib/rubocop/cop/style/hash_transform_values.rb +80 -0
  133. data/lib/rubocop/cop/style/if_unless_modifier.rb +23 -3
  134. data/lib/rubocop/cop/style/inverse_methods.rb +9 -5
  135. data/lib/rubocop/cop/style/lambda.rb +3 -2
  136. data/lib/rubocop/cop/style/lambda_call.rb +2 -2
  137. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +7 -205
  138. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +169 -0
  139. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +54 -0
  140. data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
  141. data/lib/rubocop/cop/style/module_function.rb +58 -12
  142. data/lib/rubocop/cop/style/multiline_if_modifier.rb +1 -1
  143. data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
  144. data/lib/rubocop/cop/style/multiline_when_then.rb +5 -1
  145. data/lib/rubocop/cop/style/mutable_constant.rb +2 -4
  146. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +4 -4
  147. data/lib/rubocop/cop/style/next.rb +2 -2
  148. data/lib/rubocop/cop/style/nil_comparison.rb +1 -1
  149. data/lib/rubocop/cop/style/non_nil_check.rb +4 -4
  150. data/lib/rubocop/cop/style/not.rb +1 -1
  151. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
  152. data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
  153. data/lib/rubocop/cop/style/numeric_predicate.rb +5 -4
  154. data/lib/rubocop/cop/style/one_line_conditional.rb +4 -3
  155. data/lib/rubocop/cop/style/or_assignment.rb +4 -3
  156. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +7 -7
  157. data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
  158. data/lib/rubocop/cop/style/perl_backrefs.rb +2 -2
  159. data/lib/rubocop/cop/style/proc.rb +1 -1
  160. data/lib/rubocop/cop/style/raise_args.rb +1 -1
  161. data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
  162. data/lib/rubocop/cop/style/redundant_condition.rb +18 -6
  163. data/lib/rubocop/cop/style/redundant_conditional.rb +1 -1
  164. data/lib/rubocop/cop/style/redundant_exception.rb +3 -3
  165. data/lib/rubocop/cop/style/redundant_interpolation.rb +2 -2
  166. data/lib/rubocop/cop/style/redundant_percent_q.rb +2 -2
  167. data/lib/rubocop/cop/style/redundant_return.rb +5 -7
  168. data/lib/rubocop/cop/style/redundant_self.rb +1 -1
  169. data/lib/rubocop/cop/style/redundant_sort.rb +2 -2
  170. data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
  171. data/lib/rubocop/cop/style/return_nil.rb +1 -1
  172. data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
  173. data/lib/rubocop/cop/style/self_assignment.rb +1 -1
  174. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  175. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -4
  176. data/lib/rubocop/cop/style/string_hash_keys.rb +1 -1
  177. data/lib/rubocop/cop/style/symbol_array.rb +3 -3
  178. data/lib/rubocop/cop/style/symbol_literal.rb +2 -2
  179. data/lib/rubocop/cop/style/ternary_parentheses.rb +2 -3
  180. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +35 -22
  181. data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +41 -0
  182. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +88 -0
  183. data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +44 -0
  184. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  185. data/lib/rubocop/cop/style/unpack_first.rb +0 -4
  186. data/lib/rubocop/cop/style/variable_interpolation.rb +1 -1
  187. data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
  188. data/lib/rubocop/cop/style/word_array.rb +1 -1
  189. data/lib/rubocop/cop/style/yoda_condition.rb +16 -1
  190. data/lib/rubocop/cop/style/zero_length_predicate.rb +1 -1
  191. data/lib/rubocop/cop/variable_force.rb +4 -1
  192. data/lib/rubocop/formatter/clang_style_formatter.rb +1 -1
  193. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  194. data/lib/rubocop/formatter/junit_formatter.rb +74 -0
  195. data/lib/rubocop/formatter/pacman_formatter.rb +1 -1
  196. data/lib/rubocop/formatter/tap_formatter.rb +1 -1
  197. data/lib/rubocop/node_pattern.rb +96 -10
  198. data/lib/rubocop/options.rb +7 -1
  199. data/lib/rubocop/processed_source.rb +1 -4
  200. data/lib/rubocop/rspec/cop_helper.rb +1 -1
  201. data/lib/rubocop/rspec/expect_offense.rb +1 -1
  202. data/lib/rubocop/rspec/shared_contexts.rb +5 -4
  203. data/lib/rubocop/runner.rb +1 -1
  204. data/lib/rubocop/target_ruby.rb +151 -0
  205. data/lib/rubocop/version.rb +1 -1
  206. metadata +39 -12
  207. data/lib/rubocop/cop/lint/end_in_method.rb +0 -40
  208. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +0 -209
  209. data/lib/rubocop/formatter/disabled_lines_formatter.rb +0 -57
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.78.0'
6
+ STRING = '0.82.0'
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, running on ' \
9
9
  '%<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.78.0
4
+ version: 0.82.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2019-12-18 00:00:00.000000000 Z
13
+ date: 2020-04-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jaro_winkler
@@ -46,14 +46,14 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '2.6'
49
+ version: 2.7.0.1
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: '2.6'
56
+ version: 2.7.0.1
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: rainbow
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -74,6 +74,20 @@ dependencies:
74
74
  - - "<"
75
75
  - !ruby/object:Gem::Version
76
76
  version: '4.0'
77
+ - !ruby/object:Gem::Dependency
78
+ name: rexml
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ type: :runtime
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
77
91
  - !ruby/object:Gem::Dependency
78
92
  name: ruby-progressbar
79
93
  requirement: !ruby/object:Gem::Requirement
@@ -97,7 +111,7 @@ dependencies:
97
111
  version: 1.4.0
98
112
  - - "<"
99
113
  - !ruby/object:Gem::Version
100
- version: '1.7'
114
+ version: '2.0'
101
115
  type: :runtime
102
116
  prerelease: false
103
117
  version_requirements: !ruby/object:Gem::Requirement
@@ -107,7 +121,7 @@ dependencies:
107
121
  version: 1.4.0
108
122
  - - "<"
109
123
  - !ruby/object:Gem::Version
110
- version: '1.7'
124
+ version: '2.0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: bundler
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -156,6 +170,7 @@ files:
156
170
  - lib/rubocop/ast/node/array_node.rb
157
171
  - lib/rubocop/ast/node/block_node.rb
158
172
  - lib/rubocop/ast/node/break_node.rb
173
+ - lib/rubocop/ast/node/case_match_node.rb
159
174
  - lib/rubocop/ast/node/case_node.rb
160
175
  - lib/rubocop/ast/node/class_node.rb
161
176
  - lib/rubocop/ast/node/def_node.rb
@@ -163,6 +178,7 @@ files:
163
178
  - lib/rubocop/ast/node/ensure_node.rb
164
179
  - lib/rubocop/ast/node/float_node.rb
165
180
  - lib/rubocop/ast/node/for_node.rb
181
+ - lib/rubocop/ast/node/forward_args_node.rb
166
182
  - lib/rubocop/ast/node/hash_node.rb
167
183
  - lib/rubocop/ast/node/if_node.rb
168
184
  - lib/rubocop/ast/node/int_node.rb
@@ -298,6 +314,7 @@ files:
298
314
  - lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb
299
315
  - lib/rubocop/cop/layout/heredoc_indentation.rb
300
316
  - lib/rubocop/cop/layout/indentation_consistency.rb
317
+ - lib/rubocop/cop/layout/indentation_style.rb
301
318
  - lib/rubocop/cop/layout/indentation_width.rb
302
319
  - lib/rubocop/cop/layout/initial_indentation.rb
303
320
  - lib/rubocop/cop/layout/leading_comment_space.rb
@@ -324,6 +341,7 @@ files:
324
341
  - lib/rubocop/cop/layout/space_around_block_parameters.rb
325
342
  - lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb
326
343
  - lib/rubocop/cop/layout/space_around_keyword.rb
344
+ - lib/rubocop/cop/layout/space_around_method_call_operator.rb
327
345
  - lib/rubocop/cop/layout/space_around_operators.rb
328
346
  - lib/rubocop/cop/layout/space_before_block_braces.rb
329
347
  - lib/rubocop/cop/layout/space_before_comma.rb
@@ -340,7 +358,6 @@ files:
340
358
  - lib/rubocop/cop/layout/space_inside_range_literal.rb
341
359
  - lib/rubocop/cop/layout/space_inside_reference_brackets.rb
342
360
  - lib/rubocop/cop/layout/space_inside_string_interpolation.rb
343
- - lib/rubocop/cop/layout/tab.rb
344
361
  - lib/rubocop/cop/layout/trailing_empty_lines.rb
345
362
  - lib/rubocop/cop/layout/trailing_whitespace.rb
346
363
  - lib/rubocop/cop/lint/ambiguous_block_association.rb
@@ -362,7 +379,6 @@ files:
362
379
  - lib/rubocop/cop/lint/empty_expression.rb
363
380
  - lib/rubocop/cop/lint/empty_interpolation.rb
364
381
  - lib/rubocop/cop/lint/empty_when.rb
365
- - lib/rubocop/cop/lint/end_in_method.rb
366
382
  - lib/rubocop/cop/lint/ensure_return.rb
367
383
  - lib/rubocop/cop/lint/erb_new_arguments.rb
368
384
  - lib/rubocop/cop/lint/flip_flop.rb
@@ -388,6 +404,7 @@ files:
388
404
  - lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb
389
405
  - lib/rubocop/cop/lint/percent_string_array.rb
390
406
  - lib/rubocop/cop/lint/percent_symbol_array.rb
407
+ - lib/rubocop/cop/lint/raise_exception.rb
391
408
  - lib/rubocop/cop/lint/rand_one.rb
392
409
  - lib/rubocop/cop/lint/redundant_cop_disable_directive.rb
393
410
  - lib/rubocop/cop/lint/redundant_cop_enable_directive.rb
@@ -409,6 +426,7 @@ files:
409
426
  - lib/rubocop/cop/lint/shadowed_argument.rb
410
427
  - lib/rubocop/cop/lint/shadowed_exception.rb
411
428
  - lib/rubocop/cop/lint/shadowing_outer_local_variable.rb
429
+ - lib/rubocop/cop/lint/struct_new_override.rb
412
430
  - lib/rubocop/cop/lint/suppressed_exception.rb
413
431
  - lib/rubocop/cop/lint/syntax.rb
414
432
  - lib/rubocop/cop/lint/to_json.rb
@@ -460,6 +478,7 @@ files:
460
478
  - lib/rubocop/cop/mixin/first_element_line_break.rb
461
479
  - lib/rubocop/cop/mixin/frozen_string_literal.rb
462
480
  - lib/rubocop/cop/mixin/hash_alignment_styles.rb
481
+ - lib/rubocop/cop/mixin/hash_transform_method.rb
463
482
  - lib/rubocop/cop/mixin/heredoc.rb
464
483
  - lib/rubocop/cop/mixin/ignored_methods.rb
465
484
  - lib/rubocop/cop/mixin/ignored_pattern.rb
@@ -535,7 +554,6 @@ files:
535
554
  - lib/rubocop/cop/style/begin_block.rb
536
555
  - lib/rubocop/cop/style/block_comments.rb
537
556
  - lib/rubocop/cop/style/block_delimiters.rb
538
- - lib/rubocop/cop/style/braces_around_hash_parameters.rb
539
557
  - lib/rubocop/cop/style/case_equality.rb
540
558
  - lib/rubocop/cop/style/character_literal.rb
541
559
  - lib/rubocop/cop/style/class_and_module_children.rb
@@ -554,6 +572,7 @@ files:
554
572
  - lib/rubocop/cop/style/date_time.rb
555
573
  - lib/rubocop/cop/style/def_with_parentheses.rb
556
574
  - lib/rubocop/cop/style/dir.rb
575
+ - lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb
557
576
  - lib/rubocop/cop/style/documentation.rb
558
577
  - lib/rubocop/cop/style/documentation_method.rb
559
578
  - lib/rubocop/cop/style/double_cop_disable_directive.rb
@@ -571,6 +590,7 @@ files:
571
590
  - lib/rubocop/cop/style/eval_with_location.rb
572
591
  - lib/rubocop/cop/style/even_odd.rb
573
592
  - lib/rubocop/cop/style/expand_path_arguments.rb
593
+ - lib/rubocop/cop/style/exponential_notation.rb
574
594
  - lib/rubocop/cop/style/float_division.rb
575
595
  - lib/rubocop/cop/style/for.rb
576
596
  - lib/rubocop/cop/style/format_string.rb
@@ -578,7 +598,10 @@ files:
578
598
  - lib/rubocop/cop/style/frozen_string_literal_comment.rb
579
599
  - lib/rubocop/cop/style/global_vars.rb
580
600
  - lib/rubocop/cop/style/guard_clause.rb
601
+ - lib/rubocop/cop/style/hash_each_methods.rb
581
602
  - lib/rubocop/cop/style/hash_syntax.rb
603
+ - lib/rubocop/cop/style/hash_transform_keys.rb
604
+ - lib/rubocop/cop/style/hash_transform_values.rb
582
605
  - lib/rubocop/cop/style/identical_conditional_branches.rb
583
606
  - lib/rubocop/cop/style/if_inside_else.rb
584
607
  - lib/rubocop/cop/style/if_unless_modifier.rb
@@ -593,6 +616,8 @@ files:
593
616
  - lib/rubocop/cop/style/lambda_call.rb
594
617
  - lib/rubocop/cop/style/line_end_concatenation.rb
595
618
  - lib/rubocop/cop/style/method_call_with_args_parentheses.rb
619
+ - lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb
620
+ - lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb
596
621
  - lib/rubocop/cop/style/method_call_without_args_parentheses.rb
597
622
  - lib/rubocop/cop/style/method_called_on_do_end_block.rb
598
623
  - lib/rubocop/cop/style/method_def_parentheses.rb
@@ -681,6 +706,7 @@ files:
681
706
  - lib/rubocop/cop/style/trailing_body_on_module.rb
682
707
  - lib/rubocop/cop/style/trailing_comma_in_arguments.rb
683
708
  - lib/rubocop/cop/style/trailing_comma_in_array_literal.rb
709
+ - lib/rubocop/cop/style/trailing_comma_in_block_args.rb
684
710
  - lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb
685
711
  - lib/rubocop/cop/style/trailing_method_end_statement.rb
686
712
  - lib/rubocop/cop/style/trailing_underscore_variable.rb
@@ -713,13 +739,13 @@ files:
713
739
  - lib/rubocop/formatter/clang_style_formatter.rb
714
740
  - lib/rubocop/formatter/colorizable.rb
715
741
  - lib/rubocop/formatter/disabled_config_formatter.rb
716
- - lib/rubocop/formatter/disabled_lines_formatter.rb
717
742
  - lib/rubocop/formatter/emacs_style_formatter.rb
718
743
  - lib/rubocop/formatter/file_list_formatter.rb
719
744
  - lib/rubocop/formatter/formatter_set.rb
720
745
  - lib/rubocop/formatter/fuubar_style_formatter.rb
721
746
  - lib/rubocop/formatter/html_formatter.rb
722
747
  - lib/rubocop/formatter/json_formatter.rb
748
+ - lib/rubocop/formatter/junit_formatter.rb
723
749
  - lib/rubocop/formatter/offense_count_formatter.rb
724
750
  - lib/rubocop/formatter/pacman_formatter.rb
725
751
  - lib/rubocop/formatter/progress_formatter.rb
@@ -747,6 +773,7 @@ files:
747
773
  - lib/rubocop/string_interpreter.rb
748
774
  - lib/rubocop/string_util.rb
749
775
  - lib/rubocop/target_finder.rb
776
+ - lib/rubocop/target_ruby.rb
750
777
  - lib/rubocop/token.rb
751
778
  - lib/rubocop/version.rb
752
779
  - lib/rubocop/warning.rb
@@ -768,14 +795,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
768
795
  requirements:
769
796
  - - ">="
770
797
  - !ruby/object:Gem::Version
771
- version: 2.3.0
798
+ version: 2.4.0
772
799
  required_rubygems_version: !ruby/object:Gem::Requirement
773
800
  requirements:
774
801
  - - ">="
775
802
  - !ruby/object:Gem::Version
776
803
  version: '0'
777
804
  requirements: []
778
- rubygems_version: 3.0.3
805
+ rubygems_version: 3.1.2
779
806
  signing_key:
780
807
  specification_version: 4
781
808
  summary: Automatic Ruby code style checking tool.
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module Lint
6
- # This cop checks for END blocks in method definitions.
7
- #
8
- # @example
9
- #
10
- # # bad
11
- #
12
- # def some_method
13
- # END { do_something }
14
- # end
15
- #
16
- # @example
17
- #
18
- # # good
19
- #
20
- # def some_method
21
- # at_exit { do_something }
22
- # end
23
- #
24
- # @example
25
- #
26
- # # good
27
- #
28
- # # outside defs
29
- # END { do_something }
30
- class EndInMethod < Cop
31
- MSG = '`END` found in method definition. Use `at_exit` instead.'
32
-
33
- def on_postexe(node)
34
- inside_of_method = node.each_ancestor(:def, :defs).count.nonzero?
35
- add_offense(node, location: :keyword) if inside_of_method
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,209 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module Style
6
- # This cop checks for braces around the last parameter in a method call
7
- # if the last parameter is a hash.
8
- # It supports `braces`, `no_braces` and `context_dependent` styles.
9
- #
10
- # @example EnforcedStyle: braces
11
- # # The `braces` style enforces braces around all method
12
- # # parameters that are hashes.
13
- #
14
- # # bad
15
- # some_method(x, y, a: 1, b: 2)
16
- #
17
- # # good
18
- # some_method(x, y, {a: 1, b: 2})
19
- #
20
- # @example EnforcedStyle: no_braces (default)
21
- # # The `no_braces` style checks that the last parameter doesn't
22
- # # have braces around it.
23
- #
24
- # # bad
25
- # some_method(x, y, {a: 1, b: 2})
26
- #
27
- # # good
28
- # some_method(x, y, a: 1, b: 2)
29
- #
30
- # @example EnforcedStyle: context_dependent
31
- # # The `context_dependent` style checks that the last parameter
32
- # # doesn't have braces around it, but requires braces if the
33
- # # second to last parameter is also a hash literal.
34
- #
35
- # # bad
36
- # some_method(x, y, {a: 1, b: 2})
37
- # some_method(x, y, {a: 1, b: 2}, a: 1, b: 2)
38
- #
39
- # # good
40
- # some_method(x, y, a: 1, b: 2)
41
- # some_method(x, y, {a: 1, b: 2}, {a: 1, b: 2})
42
- class BracesAroundHashParameters < Cop
43
- include ConfigurableEnforcedStyle
44
- include RangeHelp
45
-
46
- MSG = '%<type>s curly braces around a hash parameter.'
47
-
48
- def on_send(node)
49
- return if node.assignment_method? || node.operator_method?
50
-
51
- return unless node.arguments? && node.last_argument.hash_type? &&
52
- !node.last_argument.empty?
53
-
54
- check(node.last_argument, node.arguments)
55
- end
56
- alias on_csend on_send
57
-
58
- def autocorrect(send_node)
59
- hash_node = send_node.last_argument
60
-
61
- lambda do |corrector|
62
- if hash_node.braces?
63
- remove_braces_with_whitespace(corrector,
64
- hash_node,
65
- extra_space(hash_node))
66
- else
67
- add_braces(corrector, hash_node)
68
- end
69
- end
70
- end
71
-
72
- private
73
-
74
- def check(arg, args)
75
- case style
76
- when :braces
77
- check_braces(arg)
78
- when :no_braces
79
- check_no_braces(arg)
80
- when :context_dependent
81
- check_context_dependent(arg, args)
82
- end
83
- end
84
-
85
- def check_braces(arg)
86
- add_arg_offense(arg, :missing) unless arg.braces?
87
- end
88
-
89
- def check_no_braces(arg)
90
- return unless arg.braces? && !braces_needed_for_semantics?(arg)
91
-
92
- add_arg_offense(arg, :redundant)
93
- end
94
-
95
- def check_context_dependent(arg, args)
96
- braces_around_second_from_end = args.size > 1 && args[-2].hash_type?
97
-
98
- if arg.braces?
99
- unless braces_around_second_from_end ||
100
- braces_needed_for_semantics?(arg)
101
- add_arg_offense(arg, :redundant)
102
- end
103
- elsif braces_around_second_from_end
104
- add_arg_offense(arg, :missing)
105
- end
106
- end
107
-
108
- # Returns true if there's block inside the braces of the given hash arg
109
- # and that block uses do..end. The reason for wanting to check this is
110
- # that the do..end could bind to a different method invocation if the
111
- # hash braces were removed.
112
- def braces_needed_for_semantics?(arg)
113
- arg.each_pair do |_key, value|
114
- return true if value.block_type? && !value.braces?
115
- end
116
- false
117
- end
118
-
119
- def add_arg_offense(arg, type)
120
- add_offense(arg.parent, location: arg.source_range,
121
- message: format(MSG,
122
- type: type.to_s.capitalize))
123
- end
124
-
125
- def extra_space(hash_node)
126
- {
127
- newlines: extra_left_space?(hash_node) &&
128
- extra_right_space?(hash_node),
129
- left: extra_left_space?(hash_node),
130
- right: extra_right_space?(hash_node)
131
- }
132
- end
133
-
134
- def extra_left_space?(hash_node)
135
- @extra_left_space ||= begin
136
- top_line = hash_node.source_range.source_line
137
- top_line.delete(' ') == '{'
138
- end
139
- end
140
-
141
- def extra_right_space?(hash_node)
142
- @extra_right_space ||= begin
143
- bottom_line_number = hash_node.source_range.last_line
144
- bottom_line = processed_source.lines[bottom_line_number - 1]
145
- bottom_line.delete(' ') == '}'
146
- end
147
- end
148
-
149
- def remove_braces_with_whitespace(corrector, node, space)
150
- loc = node.loc
151
-
152
- if node.multiline?
153
- remove_braces_with_range(corrector,
154
- left_whole_line_range(loc.begin),
155
- right_whole_line_range(loc.end))
156
- else
157
- remove_braces_with_range(corrector,
158
- left_brace_and_space(loc.begin, space),
159
- right_brace_and_space(loc.end, space))
160
- end
161
- end
162
-
163
- def remove_braces_with_range(corrector, left_range, right_range)
164
- corrector.remove(left_range)
165
- corrector.remove(right_range)
166
- end
167
-
168
- def left_whole_line_range(loc_begin)
169
- if range_by_whole_lines(loc_begin).source.strip == '{'
170
- range_by_whole_lines(loc_begin, include_final_newline: true)
171
- else
172
- loc_begin
173
- end
174
- end
175
-
176
- def right_whole_line_range(loc_end)
177
- if range_by_whole_lines(loc_end).source.strip =~ /\A}\s*,?\z/
178
- range_by_whole_lines(loc_end, include_final_newline: true)
179
- else
180
- loc_end
181
- end
182
- end
183
-
184
- def left_brace_and_space(loc_begin, space)
185
- range_with_surrounding_space(range: loc_begin,
186
- side: :right,
187
- newlines: space[:newlines],
188
- whitespace: space[:left])
189
- end
190
-
191
- def right_brace_and_space(loc_end, space)
192
- brace_and_space =
193
- range_with_surrounding_space(
194
- range: loc_end,
195
- side: :left,
196
- newlines: space[:newlines],
197
- whitespace: space[:right]
198
- )
199
- range_with_surrounding_comma(brace_and_space, :left)
200
- end
201
-
202
- def add_braces(corrector, node)
203
- corrector.insert_before(node.source_range, '{')
204
- corrector.insert_after(node.source_range, '}')
205
- end
206
- end
207
- end
208
- end
209
- end