rubocop 0.76.0 → 0.80.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +4 -4
- data/config/default.yml +325 -283
- data/lib/rubocop.rb +43 -23
- data/lib/rubocop/ast/builder.rb +43 -42
- data/lib/rubocop/ast/node.rb +1 -13
- data/lib/rubocop/ast/node/block_node.rb +2 -0
- data/lib/rubocop/ast/node/def_node.rb +11 -0
- data/lib/rubocop/ast/node/forward_args_node.rb +18 -0
- data/lib/rubocop/ast/node/regexp_node.rb +2 -4
- data/lib/rubocop/ast/traversal.rb +20 -3
- data/lib/rubocop/cli.rb +11 -230
- data/lib/rubocop/cli/command.rb +21 -0
- data/lib/rubocop/cli/command/auto_genenerate_config.rb +105 -0
- data/lib/rubocop/cli/command/base.rb +33 -0
- data/lib/rubocop/cli/command/execute_runner.rb +76 -0
- data/lib/rubocop/cli/command/init_dotfile.rb +45 -0
- data/lib/rubocop/cli/command/show_cops.rb +80 -0
- data/lib/rubocop/cli/command/version.rb +17 -0
- data/lib/rubocop/cli/environment.rb +21 -0
- data/lib/rubocop/comment_config.rb +6 -1
- data/lib/rubocop/config.rb +28 -10
- data/lib/rubocop/config_loader.rb +19 -19
- data/lib/rubocop/config_obsoletion.rb +65 -11
- data/lib/rubocop/config_validator.rb +56 -98
- data/lib/rubocop/cop/autocorrect_logic.rb +7 -4
- data/lib/rubocop/cop/bundler/gem_comment.rb +4 -4
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +2 -2
- data/lib/rubocop/cop/cop.rb +21 -0
- data/lib/rubocop/cop/correctors/space_corrector.rb +1 -2
- data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
- data/lib/rubocop/cop/generator.rb +3 -4
- data/lib/rubocop/cop/generator/configuration_injector.rb +1 -1
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +59 -0
- data/lib/rubocop/cop/layout/{align_arguments.rb → argument_alignment.rb} +1 -1
- data/lib/rubocop/cop/layout/{align_array.rb → array_alignment.rb} +1 -1
- data/lib/rubocop/cop/layout/{indent_assignment.rb → assignment_indentation.rb} +1 -1
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +2 -1
- data/lib/rubocop/cop/layout/extra_spacing.rb +1 -1
- data/lib/rubocop/cop/layout/{indent_first_argument.rb → first_argument_indentation.rb} +5 -5
- data/lib/rubocop/cop/layout/{indent_first_array_element.rb → first_array_element_indentation.rb} +4 -4
- data/lib/rubocop/cop/layout/{indent_first_hash_element.rb → first_hash_element_indentation.rb} +3 -3
- data/lib/rubocop/cop/layout/{indent_first_parameter.rb → first_parameter_indentation.rb} +3 -3
- data/lib/rubocop/cop/layout/{align_hash.rb → hash_alignment.rb} +10 -6
- data/lib/rubocop/cop/layout/{indent_heredoc.rb → heredoc_indentation.rb} +5 -5
- data/lib/rubocop/cop/layout/leading_comment_space.rb +33 -2
- data/lib/rubocop/cop/layout/{leading_blank_lines.rb → leading_empty_lines.rb} +1 -1
- data/lib/rubocop/cop/{metrics → layout}/line_length.rb +67 -108
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +14 -5
- data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +0 -4
- data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +1 -1
- data/lib/rubocop/cop/layout/{align_parameters.rb → parameter_alignment.rb} +1 -1
- data/lib/rubocop/cop/layout/space_around_keyword.rb +12 -0
- data/lib/rubocop/cop/layout/space_around_operators.rb +50 -7
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +17 -0
- data/lib/rubocop/cop/layout/space_before_first_arg.rb +8 -0
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +2 -9
- data/lib/rubocop/cop/layout/{trailing_blank_lines.rb → trailing_empty_lines.rb} +1 -1
- data/lib/rubocop/cop/lint/debugger.rb +1 -1
- data/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb +1 -1
- data/lib/rubocop/cop/lint/{duplicated_key.rb → duplicate_hash_key.rb} +1 -1
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -1
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
- data/lib/rubocop/cop/lint/{multiple_compare.rb → multiple_comparison.rb} +1 -1
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +89 -0
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +3 -3
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +13 -8
- data/lib/rubocop/cop/lint/redundant_splat_expansion.rb +1 -1
- data/lib/rubocop/cop/lint/{string_conversion_in_interpolation.rb → redundant_string_coercion.rb} +1 -1
- data/lib/rubocop/cop/lint/redundant_with_index.rb +2 -2
- data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -2
- data/lib/rubocop/cop/lint/{handle_exceptions.rb → suppressed_exception.rb} +1 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +57 -23
- data/lib/rubocop/cop/lint/useless_setter_call.rb +5 -1
- data/lib/rubocop/cop/metrics/method_length.rb +1 -1
- data/lib/rubocop/cop/migration/department_name.rb +30 -2
- data/lib/rubocop/cop/mixin/alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +4 -0
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +7 -7
- data/lib/rubocop/cop/mixin/{hash_alignment.rb → hash_alignment_styles.rb} +1 -1
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +171 -0
- data/lib/rubocop/cop/mixin/line_length_help.rb +88 -0
- data/lib/rubocop/cop/mixin/nil_methods.rb +4 -4
- data/lib/rubocop/cop/mixin/rational_literal.rb +18 -0
- data/lib/rubocop/cop/mixin/statement_modifier.rb +2 -2
- data/lib/rubocop/cop/mixin/trailing_comma.rb +8 -12
- data/lib/rubocop/cop/naming/{uncommunicative_block_param_name.rb → block_parameter_name.rb} +3 -3
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +5 -5
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
- data/lib/rubocop/cop/naming/{uncommunicative_method_param_name.rb → method_parameter_name.rb} +4 -4
- data/lib/rubocop/cop/naming/predicate_name.rb +6 -6
- data/lib/rubocop/cop/offense.rb +11 -0
- data/lib/rubocop/cop/registry.rb +7 -2
- data/lib/rubocop/cop/style/alias.rb +1 -1
- data/lib/rubocop/cop/style/array_join.rb +1 -1
- data/lib/rubocop/cop/style/attr.rb +8 -0
- data/lib/rubocop/cop/style/block_delimiters.rb +60 -1
- data/lib/rubocop/cop/style/conditional_assignment.rb +2 -2
- data/lib/rubocop/cop/style/eval_with_location.rb +1 -1
- data/lib/rubocop/cop/style/even_odd.rb +1 -1
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +89 -11
- data/lib/rubocop/cop/style/guard_clause.rb +3 -2
- data/lib/rubocop/cop/style/hash_each_methods.rb +87 -0
- data/lib/rubocop/cop/style/hash_transform_keys.rb +79 -0
- data/lib/rubocop/cop/style/hash_transform_values.rb +79 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +38 -3
- data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +8 -4
- data/lib/rubocop/cop/style/ip_addresses.rb +4 -4
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +7 -205
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +169 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +54 -0
- data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
- data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +5 -1
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +7 -7
- data/lib/rubocop/cop/style/next.rb +5 -5
- data/lib/rubocop/cop/style/numeric_literals.rb +7 -3
- data/lib/rubocop/cop/style/numeric_predicate.rb +4 -3
- data/lib/rubocop/cop/style/option_hash.rb +3 -3
- data/lib/rubocop/cop/style/or_assignment.rb +3 -2
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +7 -7
- data/lib/rubocop/cop/style/redundant_condition.rb +17 -4
- data/lib/rubocop/cop/style/redundant_parentheses.rb +3 -3
- data/lib/rubocop/cop/style/redundant_return.rb +2 -8
- data/lib/rubocop/cop/style/redundant_sort.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +2 -2
- data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +0 -22
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +7 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +5 -5
- data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
- data/lib/rubocop/cop/style/yoda_condition.rb +16 -1
- data/lib/rubocop/cop/team.rb +5 -0
- data/lib/rubocop/cop/variable_force.rb +4 -1
- data/lib/rubocop/formatter/base_formatter.rb +2 -2
- data/lib/rubocop/formatter/clang_style_formatter.rb +1 -3
- data/lib/rubocop/formatter/formatter_set.rb +1 -0
- data/lib/rubocop/formatter/json_formatter.rb +6 -5
- data/lib/rubocop/formatter/junit_formatter.rb +63 -0
- data/lib/rubocop/formatter/tap_formatter.rb +1 -3
- data/lib/rubocop/node_pattern.rb +97 -11
- data/lib/rubocop/options.rb +8 -8
- data/lib/rubocop/processed_source.rb +1 -1
- data/lib/rubocop/rake_task.rb +1 -0
- data/lib/rubocop/result_cache.rb +23 -7
- data/lib/rubocop/rspec/shared_contexts.rb +5 -0
- data/lib/rubocop/runner.rb +18 -2
- data/lib/rubocop/target_ruby.rb +151 -0
- data/lib/rubocop/version.rb +1 -1
- metadata +60 -27
- data/lib/rubocop/cop/mixin/safe_mode.rb +0 -24
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +0 -209
data/lib/rubocop.rb
CHANGED
@@ -43,6 +43,7 @@ require_relative 'rubocop/ast/node/def_node'
|
|
43
43
|
require_relative 'rubocop/ast/node/defined_node'
|
44
44
|
require_relative 'rubocop/ast/node/ensure_node'
|
45
45
|
require_relative 'rubocop/ast/node/for_node'
|
46
|
+
require_relative 'rubocop/ast/node/forward_args_node'
|
46
47
|
require_relative 'rubocop/ast/node/float_node'
|
47
48
|
require_relative 'rubocop/ast/node/hash_node'
|
48
49
|
require_relative 'rubocop/ast/node/if_node'
|
@@ -118,11 +119,13 @@ require_relative 'rubocop/cop/mixin/end_keyword_alignment'
|
|
118
119
|
require_relative 'rubocop/cop/mixin/enforce_superclass'
|
119
120
|
require_relative 'rubocop/cop/mixin/first_element_line_break'
|
120
121
|
require_relative 'rubocop/cop/mixin/frozen_string_literal'
|
121
|
-
require_relative 'rubocop/cop/mixin/
|
122
|
+
require_relative 'rubocop/cop/mixin/hash_alignment_styles'
|
123
|
+
require_relative 'rubocop/cop/mixin/hash_transform_method'
|
122
124
|
require_relative 'rubocop/cop/mixin/ignored_pattern'
|
123
125
|
require_relative 'rubocop/cop/mixin/ignored_methods'
|
124
126
|
require_relative 'rubocop/cop/mixin/integer_node'
|
125
127
|
require_relative 'rubocop/cop/mixin/interpolation'
|
128
|
+
require_relative 'rubocop/cop/mixin/line_length_help'
|
126
129
|
require_relative 'rubocop/cop/mixin/match_range'
|
127
130
|
require_relative 'rubocop/cop/mixin/method_complexity'
|
128
131
|
require_relative 'rubocop/cop/mixin/method_preference'
|
@@ -142,9 +145,9 @@ require_relative 'rubocop/cop/mixin/percent_array'
|
|
142
145
|
require_relative 'rubocop/cop/mixin/percent_literal'
|
143
146
|
require_relative 'rubocop/cop/mixin/preceding_following_alignment'
|
144
147
|
require_relative 'rubocop/cop/mixin/preferred_delimiters'
|
148
|
+
require_relative 'rubocop/cop/mixin/rational_literal'
|
145
149
|
require_relative 'rubocop/cop/mixin/rescue_node'
|
146
150
|
require_relative 'rubocop/cop/mixin/safe_assignment'
|
147
|
-
require_relative 'rubocop/cop/mixin/safe_mode'
|
148
151
|
require_relative 'rubocop/cop/mixin/space_after_punctuation'
|
149
152
|
require_relative 'rubocop/cop/mixin/space_before_punctuation'
|
150
153
|
require_relative 'rubocop/cop/mixin/surrounding_space'
|
@@ -189,10 +192,9 @@ require_relative 'rubocop/cop/gemspec/required_ruby_version'
|
|
189
192
|
require_relative 'rubocop/cop/gemspec/ruby_version_globals_usage'
|
190
193
|
|
191
194
|
require_relative 'rubocop/cop/layout/access_modifier_indentation'
|
192
|
-
require_relative 'rubocop/cop/layout/
|
193
|
-
require_relative 'rubocop/cop/layout/
|
194
|
-
require_relative 'rubocop/cop/layout/
|
195
|
-
require_relative 'rubocop/cop/layout/align_parameters'
|
195
|
+
require_relative 'rubocop/cop/layout/argument_alignment'
|
196
|
+
require_relative 'rubocop/cop/layout/array_alignment'
|
197
|
+
require_relative 'rubocop/cop/layout/assignment_indentation'
|
196
198
|
require_relative 'rubocop/cop/layout/block_alignment'
|
197
199
|
require_relative 'rubocop/cop/layout/block_end_newline'
|
198
200
|
require_relative 'rubocop/cop/layout/case_indentation'
|
@@ -213,29 +215,30 @@ require_relative 'rubocop/cop/layout/empty_lines_around_arguments'
|
|
213
215
|
require_relative 'rubocop/cop/layout/empty_lines_around_begin_body'
|
214
216
|
require_relative 'rubocop/cop/layout/empty_lines_around_block_body'
|
215
217
|
require_relative 'rubocop/cop/layout/empty_lines_around_class_body'
|
216
|
-
require_relative 'rubocop/cop/layout/empty_lines_around_exception_handling_keywords' # rubocop:disable
|
218
|
+
require_relative 'rubocop/cop/layout/empty_lines_around_exception_handling_keywords' # rubocop:disable Layout/LineLength
|
217
219
|
require_relative 'rubocop/cop/layout/empty_lines_around_method_body'
|
218
220
|
require_relative 'rubocop/cop/layout/empty_lines_around_module_body'
|
219
221
|
require_relative 'rubocop/cop/layout/empty_lines'
|
220
222
|
require_relative 'rubocop/cop/layout/end_alignment'
|
221
223
|
require_relative 'rubocop/cop/layout/end_of_line'
|
222
224
|
require_relative 'rubocop/cop/layout/extra_spacing'
|
225
|
+
require_relative 'rubocop/cop/layout/first_argument_indentation'
|
226
|
+
require_relative 'rubocop/cop/layout/first_array_element_indentation'
|
223
227
|
require_relative 'rubocop/cop/layout/first_array_element_line_break'
|
228
|
+
require_relative 'rubocop/cop/layout/first_hash_element_indentation'
|
224
229
|
require_relative 'rubocop/cop/layout/first_hash_element_line_break'
|
225
230
|
require_relative 'rubocop/cop/layout/first_method_argument_line_break'
|
226
231
|
require_relative 'rubocop/cop/layout/first_method_parameter_line_break'
|
232
|
+
require_relative 'rubocop/cop/layout/first_parameter_indentation'
|
233
|
+
require_relative 'rubocop/cop/layout/hash_alignment'
|
227
234
|
require_relative 'rubocop/cop/layout/heredoc_argument_closing_parenthesis'
|
228
|
-
require_relative 'rubocop/cop/layout/
|
235
|
+
require_relative 'rubocop/cop/layout/heredoc_indentation'
|
229
236
|
require_relative 'rubocop/cop/layout/indentation_consistency'
|
230
237
|
require_relative 'rubocop/cop/layout/indentation_width'
|
231
|
-
require_relative 'rubocop/cop/layout/indent_first_argument'
|
232
|
-
require_relative 'rubocop/cop/layout/indent_first_array_element'
|
233
|
-
require_relative 'rubocop/cop/layout/indent_first_hash_element'
|
234
|
-
require_relative 'rubocop/cop/layout/indent_first_parameter'
|
235
|
-
require_relative 'rubocop/cop/layout/indent_heredoc'
|
236
238
|
require_relative 'rubocop/cop/layout/initial_indentation'
|
237
|
-
require_relative 'rubocop/cop/layout/leading_blank_lines'
|
238
239
|
require_relative 'rubocop/cop/layout/leading_comment_space'
|
240
|
+
require_relative 'rubocop/cop/layout/leading_empty_lines'
|
241
|
+
require_relative 'rubocop/cop/layout/line_length'
|
239
242
|
require_relative 'rubocop/cop/layout/multiline_array_brace_layout'
|
240
243
|
require_relative 'rubocop/cop/layout/multiline_array_line_breaks'
|
241
244
|
require_relative 'rubocop/cop/layout/multiline_assignment_layout'
|
@@ -247,6 +250,7 @@ require_relative 'rubocop/cop/layout/multiline_method_call_brace_layout'
|
|
247
250
|
require_relative 'rubocop/cop/layout/multiline_method_call_indentation'
|
248
251
|
require_relative 'rubocop/cop/layout/multiline_method_definition_brace_layout'
|
249
252
|
require_relative 'rubocop/cop/layout/multiline_operation_indentation'
|
253
|
+
require_relative 'rubocop/cop/layout/parameter_alignment'
|
250
254
|
require_relative 'rubocop/cop/layout/rescue_ensure_alignment'
|
251
255
|
require_relative 'rubocop/cop/layout/space_after_colon'
|
252
256
|
require_relative 'rubocop/cop/layout/space_after_comma'
|
@@ -273,7 +277,7 @@ require_relative 'rubocop/cop/layout/space_inside_range_literal'
|
|
273
277
|
require_relative 'rubocop/cop/layout/space_inside_reference_brackets'
|
274
278
|
require_relative 'rubocop/cop/layout/space_inside_string_interpolation'
|
275
279
|
require_relative 'rubocop/cop/layout/tab'
|
276
|
-
require_relative 'rubocop/cop/layout/
|
280
|
+
require_relative 'rubocop/cop/layout/trailing_empty_lines'
|
277
281
|
require_relative 'rubocop/cop/layout/trailing_whitespace'
|
278
282
|
|
279
283
|
require_relative 'rubocop/cop/lint/ambiguous_block_association'
|
@@ -287,8 +291,8 @@ require_relative 'rubocop/cop/lint/debugger'
|
|
287
291
|
require_relative 'rubocop/cop/lint/deprecated_class_methods'
|
288
292
|
require_relative 'rubocop/cop/lint/disjunctive_assignment_in_constructor'
|
289
293
|
require_relative 'rubocop/cop/lint/duplicate_case_condition'
|
294
|
+
require_relative 'rubocop/cop/lint/duplicate_hash_key'
|
290
295
|
require_relative 'rubocop/cop/lint/duplicate_methods'
|
291
|
-
require_relative 'rubocop/cop/lint/duplicated_key'
|
292
296
|
require_relative 'rubocop/cop/lint/each_with_object_argument'
|
293
297
|
require_relative 'rubocop/cop/lint/else_layout'
|
294
298
|
require_relative 'rubocop/cop/lint/empty_ensure'
|
@@ -301,7 +305,6 @@ require_relative 'rubocop/cop/lint/erb_new_arguments'
|
|
301
305
|
require_relative 'rubocop/cop/lint/flip_flop'
|
302
306
|
require_relative 'rubocop/cop/lint/float_out_of_range'
|
303
307
|
require_relative 'rubocop/cop/lint/format_parameter_mismatch'
|
304
|
-
require_relative 'rubocop/cop/lint/handle_exceptions'
|
305
308
|
require_relative 'rubocop/cop/lint/heredoc_method_call_position'
|
306
309
|
require_relative 'rubocop/cop/lint/implicit_string_concatenation'
|
307
310
|
require_relative 'rubocop/cop/lint/inherit_exception'
|
@@ -311,10 +314,11 @@ require_relative 'rubocop/cop/lint/literal_as_condition'
|
|
311
314
|
require_relative 'rubocop/cop/lint/literal_in_interpolation'
|
312
315
|
require_relative 'rubocop/cop/lint/loop'
|
313
316
|
require_relative 'rubocop/cop/lint/missing_cop_enable_directive'
|
314
|
-
require_relative 'rubocop/cop/lint/
|
317
|
+
require_relative 'rubocop/cop/lint/multiple_comparison'
|
315
318
|
require_relative 'rubocop/cop/lint/nested_method_definition'
|
316
319
|
require_relative 'rubocop/cop/lint/nested_percent_literal'
|
317
320
|
require_relative 'rubocop/cop/lint/next_without_accumulator'
|
321
|
+
require_relative 'rubocop/cop/lint/non_deterministic_require_order'
|
318
322
|
require_relative 'rubocop/cop/lint/non_local_exit_from_iterator'
|
319
323
|
require_relative 'rubocop/cop/lint/number_conversion'
|
320
324
|
require_relative 'rubocop/cop/lint/ordered_magic_comments'
|
@@ -326,6 +330,7 @@ require_relative 'rubocop/cop/lint/redundant_cop_disable_directive'
|
|
326
330
|
require_relative 'rubocop/cop/lint/redundant_cop_enable_directive'
|
327
331
|
require_relative 'rubocop/cop/lint/redundant_require_statement'
|
328
332
|
require_relative 'rubocop/cop/lint/redundant_splat_expansion'
|
333
|
+
require_relative 'rubocop/cop/lint/redundant_string_coercion'
|
329
334
|
require_relative 'rubocop/cop/lint/redundant_with_index'
|
330
335
|
require_relative 'rubocop/cop/lint/redundant_with_object'
|
331
336
|
require_relative 'rubocop/cop/lint/regexp_as_condition'
|
@@ -341,7 +346,7 @@ require_relative 'rubocop/cop/lint/send_with_mixin_argument'
|
|
341
346
|
require_relative 'rubocop/cop/lint/shadowed_argument'
|
342
347
|
require_relative 'rubocop/cop/lint/shadowed_exception'
|
343
348
|
require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
|
344
|
-
require_relative 'rubocop/cop/lint/
|
349
|
+
require_relative 'rubocop/cop/lint/suppressed_exception'
|
345
350
|
require_relative 'rubocop/cop/lint/syntax'
|
346
351
|
require_relative 'rubocop/cop/lint/to_json'
|
347
352
|
require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
|
@@ -365,7 +370,6 @@ require_relative 'rubocop/cop/metrics/abc_size'
|
|
365
370
|
require_relative 'rubocop/cop/metrics/block_length'
|
366
371
|
require_relative 'rubocop/cop/metrics/block_nesting'
|
367
372
|
require_relative 'rubocop/cop/metrics/class_length'
|
368
|
-
require_relative 'rubocop/cop/metrics/line_length'
|
369
373
|
require_relative 'rubocop/cop/metrics/method_length'
|
370
374
|
require_relative 'rubocop/cop/metrics/module_length'
|
371
375
|
require_relative 'rubocop/cop/metrics/parameter_lists'
|
@@ -373,6 +377,7 @@ require_relative 'rubocop/cop/metrics/perceived_complexity'
|
|
373
377
|
|
374
378
|
require_relative 'rubocop/cop/naming/accessor_method_name'
|
375
379
|
require_relative 'rubocop/cop/naming/ascii_identifiers'
|
380
|
+
require_relative 'rubocop/cop/naming/block_parameter_name'
|
376
381
|
require_relative 'rubocop/cop/naming/class_and_module_camel_case'
|
377
382
|
require_relative 'rubocop/cop/naming/constant_name'
|
378
383
|
require_relative 'rubocop/cop/naming/file_name'
|
@@ -380,11 +385,10 @@ require_relative 'rubocop/cop/naming/heredoc_delimiter_case'
|
|
380
385
|
require_relative 'rubocop/cop/naming/heredoc_delimiter_naming'
|
381
386
|
require_relative 'rubocop/cop/naming/memoized_instance_variable_name'
|
382
387
|
require_relative 'rubocop/cop/naming/method_name'
|
388
|
+
require_relative 'rubocop/cop/naming/method_parameter_name'
|
383
389
|
require_relative 'rubocop/cop/naming/binary_operator_parameter_name'
|
384
390
|
require_relative 'rubocop/cop/naming/predicate_name'
|
385
391
|
require_relative 'rubocop/cop/naming/rescued_exceptions_variable_name'
|
386
|
-
require_relative 'rubocop/cop/naming/uncommunicative_block_param_name'
|
387
|
-
require_relative 'rubocop/cop/naming/uncommunicative_method_param_name'
|
388
392
|
require_relative 'rubocop/cop/naming/variable_name'
|
389
393
|
require_relative 'rubocop/cop/naming/variable_number'
|
390
394
|
|
@@ -399,7 +403,6 @@ require_relative 'rubocop/cop/style/bare_percent_literals'
|
|
399
403
|
require_relative 'rubocop/cop/style/begin_block'
|
400
404
|
require_relative 'rubocop/cop/style/block_comments'
|
401
405
|
require_relative 'rubocop/cop/style/block_delimiters'
|
402
|
-
require_relative 'rubocop/cop/style/braces_around_hash_parameters'
|
403
406
|
require_relative 'rubocop/cop/style/case_equality'
|
404
407
|
require_relative 'rubocop/cop/style/character_literal'
|
405
408
|
require_relative 'rubocop/cop/style/class_and_module_children'
|
@@ -442,7 +445,10 @@ require_relative 'rubocop/cop/style/format_string_token'
|
|
442
445
|
require_relative 'rubocop/cop/style/frozen_string_literal_comment'
|
443
446
|
require_relative 'rubocop/cop/style/global_vars'
|
444
447
|
require_relative 'rubocop/cop/style/guard_clause'
|
448
|
+
require_relative 'rubocop/cop/style/hash_each_methods'
|
445
449
|
require_relative 'rubocop/cop/style/hash_syntax'
|
450
|
+
require_relative 'rubocop/cop/style/hash_transform_keys'
|
451
|
+
require_relative 'rubocop/cop/style/hash_transform_values'
|
446
452
|
require_relative 'rubocop/cop/style/identical_conditional_branches'
|
447
453
|
require_relative 'rubocop/cop/style/if_inside_else'
|
448
454
|
require_relative 'rubocop/cop/style/if_unless_modifier'
|
@@ -457,7 +463,11 @@ require_relative 'rubocop/cop/style/lambda'
|
|
457
463
|
require_relative 'rubocop/cop/style/lambda_call'
|
458
464
|
require_relative 'rubocop/cop/style/line_end_concatenation'
|
459
465
|
require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
|
466
|
+
# rubocop:disable Layout/LineLength
|
460
467
|
require_relative 'rubocop/cop/style/method_call_with_args_parentheses'
|
468
|
+
require_relative 'rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses'
|
469
|
+
require_relative 'rubocop/cop/style/method_call_with_args_parentheses/require_parentheses'
|
470
|
+
# rubocop:enable Layout/LineLength
|
461
471
|
require_relative 'rubocop/cop/style/method_called_on_do_end_block'
|
462
472
|
require_relative 'rubocop/cop/style/method_def_parentheses'
|
463
473
|
require_relative 'rubocop/cop/style/method_missing_super'
|
@@ -578,6 +588,7 @@ require_relative 'rubocop/formatter/file_list_formatter'
|
|
578
588
|
require_relative 'rubocop/formatter/fuubar_style_formatter'
|
579
589
|
require_relative 'rubocop/formatter/html_formatter'
|
580
590
|
require_relative 'rubocop/formatter/json_formatter'
|
591
|
+
require_relative 'rubocop/formatter/junit_formatter'
|
581
592
|
require_relative 'rubocop/formatter/offense_count_formatter'
|
582
593
|
require_relative 'rubocop/formatter/progress_formatter'
|
583
594
|
require_relative 'rubocop/formatter/quiet_formatter'
|
@@ -604,6 +615,15 @@ require_relative 'rubocop/processed_source'
|
|
604
615
|
require_relative 'rubocop/result_cache'
|
605
616
|
require_relative 'rubocop/runner'
|
606
617
|
require_relative 'rubocop/cli'
|
618
|
+
require_relative 'rubocop/cli/command'
|
619
|
+
require_relative 'rubocop/cli/environment'
|
620
|
+
require_relative 'rubocop/cli/command/base'
|
621
|
+
require_relative 'rubocop/cli/command/auto_genenerate_config'
|
622
|
+
require_relative 'rubocop/cli/command/execute_runner'
|
623
|
+
require_relative 'rubocop/cli/command/init_dotfile'
|
624
|
+
require_relative 'rubocop/cli/command/show_cops'
|
625
|
+
require_relative 'rubocop/cli/command/version'
|
607
626
|
require_relative 'rubocop/options'
|
608
627
|
require_relative 'rubocop/remote_config'
|
628
|
+
require_relative 'rubocop/target_ruby'
|
609
629
|
require_relative 'rubocop/yaml_duplication_checker'
|
data/lib/rubocop/ast/builder.rb
CHANGED
@@ -15,48 +15,49 @@ module RuboCop
|
|
15
15
|
# root_node = parser.parse(buffer)
|
16
16
|
class Builder < Parser::Builders::Default
|
17
17
|
NODE_MAP = {
|
18
|
-
and:
|
19
|
-
alias:
|
20
|
-
args:
|
21
|
-
array:
|
22
|
-
block:
|
23
|
-
break:
|
24
|
-
case:
|
25
|
-
class:
|
26
|
-
def:
|
27
|
-
defined?:
|
28
|
-
defs:
|
29
|
-
ensure:
|
30
|
-
for:
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
18
|
+
and: AndNode,
|
19
|
+
alias: AliasNode,
|
20
|
+
args: ArgsNode,
|
21
|
+
array: ArrayNode,
|
22
|
+
block: BlockNode,
|
23
|
+
break: BreakNode,
|
24
|
+
case: CaseNode,
|
25
|
+
class: ClassNode,
|
26
|
+
def: DefNode,
|
27
|
+
defined?: DefinedNode,
|
28
|
+
defs: DefNode,
|
29
|
+
ensure: EnsureNode,
|
30
|
+
for: ForNode,
|
31
|
+
forward_args: ForwardArgsNode,
|
32
|
+
float: FloatNode,
|
33
|
+
hash: HashNode,
|
34
|
+
if: IfNode,
|
35
|
+
int: IntNode,
|
36
|
+
irange: RangeNode,
|
37
|
+
erange: RangeNode,
|
38
|
+
kwsplat: KeywordSplatNode,
|
39
|
+
module: ModuleNode,
|
40
|
+
or: OrNode,
|
41
|
+
pair: PairNode,
|
42
|
+
regexp: RegexpNode,
|
43
|
+
resbody: ResbodyNode,
|
44
|
+
retry: RetryNode,
|
45
|
+
return: ReturnNode,
|
46
|
+
csend: SendNode,
|
47
|
+
send: SendNode,
|
48
|
+
str: StrNode,
|
49
|
+
dstr: StrNode,
|
50
|
+
xstr: StrNode,
|
51
|
+
sclass: SelfClassNode,
|
52
|
+
super: SuperNode,
|
53
|
+
zsuper: SuperNode,
|
54
|
+
sym: SymbolNode,
|
55
|
+
until: UntilNode,
|
56
|
+
until_post: UntilNode,
|
57
|
+
when: WhenNode,
|
58
|
+
while: WhileNode,
|
59
|
+
while_post: WhileNode,
|
60
|
+
yield: YieldNode
|
60
61
|
}.freeze
|
61
62
|
|
62
63
|
# Generates {Node} from the given information.
|
data/lib/rubocop/ast/node.rb
CHANGED
@@ -141,9 +141,6 @@ module RuboCop
|
|
141
141
|
# Yield only nodes matching any of the types.
|
142
142
|
# @param [Symbol] type_a a node type
|
143
143
|
# @param [Symbol] type_b a node type
|
144
|
-
# @overload each_ancestor(types)
|
145
|
-
# Yield only nodes matching any of types in the array.
|
146
|
-
# @param [Array<Symbol>] types an array containing node types
|
147
144
|
# @yieldparam [Node] node each ancestor node
|
148
145
|
# @return [self] if a block is given
|
149
146
|
# @return [Enumerator] if no block is given
|
@@ -178,9 +175,6 @@ module RuboCop
|
|
178
175
|
# Yield only nodes matching any of the types.
|
179
176
|
# @param [Symbol] type_a a node type
|
180
177
|
# @param [Symbol] type_b a node type
|
181
|
-
# @overload each_child_node(types)
|
182
|
-
# Yield only nodes matching any of types in the array.
|
183
|
-
# @param [Array<Symbol>] types an array containing node types
|
184
178
|
# @yieldparam [Node] node each child node
|
185
179
|
# @return [self] if a block is given
|
186
180
|
# @return [Enumerator] if no block is given
|
@@ -216,9 +210,6 @@ module RuboCop
|
|
216
210
|
# Yield only nodes matching any of the types.
|
217
211
|
# @param [Symbol] type_a a node type
|
218
212
|
# @param [Symbol] type_b a node type
|
219
|
-
# @overload each_descendant(types)
|
220
|
-
# Yield only nodes matching any of types in the array.
|
221
|
-
# @param [Array<Symbol>] types an array containing node types
|
222
213
|
# @yieldparam [Node] node each descendant node
|
223
214
|
# @return [self] if a block is given
|
224
215
|
# @return [Enumerator] if no block is given
|
@@ -254,9 +245,6 @@ module RuboCop
|
|
254
245
|
# Yield only nodes matching any of the types.
|
255
246
|
# @param [Symbol] type_a a node type
|
256
247
|
# @param [Symbol] type_b a node type
|
257
|
-
# @overload each_node(types)
|
258
|
-
# Yield only nodes matching any of types in the array.
|
259
|
-
# @param [Array<Symbol>] types an array containing node types
|
260
248
|
# @yieldparam [Node] node each node
|
261
249
|
# @return [self] if a block is given
|
262
250
|
# @return [Enumerator] if no block is given
|
@@ -624,7 +612,7 @@ module RuboCop
|
|
624
612
|
end
|
625
613
|
|
626
614
|
def parent_module_name_for_block(ancestor)
|
627
|
-
if ancestor.
|
615
|
+
if ancestor.method?(:class_eval)
|
628
616
|
# `class_eval` with no receiver applies to whatever module or class
|
629
617
|
# we are currently in
|
630
618
|
return unless (receiver = ancestor.receiver)
|
@@ -9,6 +9,8 @@ module RuboCop
|
|
9
9
|
# A `block` node is essentially a method send with a block. Parser nests
|
10
10
|
# the `send` node inside the `block` node.
|
11
11
|
class BlockNode < Node
|
12
|
+
include MethodIdentifierPredicates
|
13
|
+
|
12
14
|
VOID_CONTEXT_METHODS = %i[each tap].freeze
|
13
15
|
|
14
16
|
# The `send` node associated with this block.
|
@@ -16,6 +16,17 @@ module RuboCop
|
|
16
16
|
method?(:initialize) || assignment_method?
|
17
17
|
end
|
18
18
|
|
19
|
+
# Checks whether this method definition node forwards its arguments
|
20
|
+
# as per the feature added in Ruby 2.7.
|
21
|
+
#
|
22
|
+
# @note This is written in a way that may support lead arguments
|
23
|
+
# which are rumored to be added in a later version of Ruby.
|
24
|
+
#
|
25
|
+
# @return [Boolean] whether the `def` node uses argument forwarding
|
26
|
+
def argument_forwarding?
|
27
|
+
arguments.any?(&:forward_args_type?)
|
28
|
+
end
|
29
|
+
|
19
30
|
# The name of the defined method as a symbol.
|
20
31
|
#
|
21
32
|
# @return [Symbol] the name of the defined method
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module AST
|
5
|
+
# A node extension for `forward-args` nodes. This will be used in place
|
6
|
+
# of a plain node when the builder constructs the AST, making its methods
|
7
|
+
# available to all `forward-args` nodes within RuboCop.
|
8
|
+
class ForwardArgsNode < Node
|
9
|
+
include CollectionNode
|
10
|
+
|
11
|
+
# Node wraps itself in an array to be compatible with other
|
12
|
+
# enumerable argument types.
|
13
|
+
def to_a
|
14
|
+
[self]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -21,14 +21,12 @@ module RuboCop
|
|
21
21
|
|
22
22
|
# @return [RuboCop::AST::Node] a regopt node
|
23
23
|
def regopt
|
24
|
-
|
25
|
-
first.regopt_type? ? first : second
|
24
|
+
children.last
|
26
25
|
end
|
27
26
|
|
28
27
|
# @return [String] a string of regexp content
|
29
28
|
def content
|
30
|
-
|
31
|
-
str.str_content || ''
|
29
|
+
children.select(&:str_type?).map(&:str_content).join
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# rubocop:disable Metrics/ModuleLength
|
3
4
|
module RuboCop
|
4
5
|
module AST
|
5
6
|
# Provides methods for traversing an AST.
|
@@ -18,15 +19,21 @@ module RuboCop
|
|
18
19
|
rational str sym regopt self lvar
|
19
20
|
ivar cvar gvar nth_ref back_ref cbase
|
20
21
|
arg restarg blockarg shadowarg
|
21
|
-
kwrestarg zsuper lambda redo retry
|
22
|
+
kwrestarg zsuper lambda redo retry
|
23
|
+
forward_args forwarded_args
|
24
|
+
match_var match_nil_pattern].freeze
|
22
25
|
ONE_CHILD_NODE = %i[splat kwsplat block_pass not break next
|
23
26
|
preexe postexe match_current_line defined?
|
24
|
-
arg_expr
|
27
|
+
arg_expr pin match_rest if_guard unless_guard
|
28
|
+
match_with_trailing_comma].freeze
|
25
29
|
MANY_CHILD_NODES = %i[dstr dsym xstr regexp array hash pair
|
26
30
|
mlhs masgn or_asgn and_asgn
|
27
31
|
undef alias args super yield or and
|
28
32
|
while_post until_post iflipflop eflipflop
|
29
|
-
match_with_lvasgn begin kwbegin return
|
33
|
+
match_with_lvasgn begin kwbegin return
|
34
|
+
in_match case_match in_pattern match_alt
|
35
|
+
match_as array_pattern array_pattern_with_tail
|
36
|
+
hash_pattern const_pattern].freeze
|
30
37
|
SECOND_CHILD_ONLY = %i[lvasgn ivasgn cvasgn gvasgn optarg kwarg
|
31
38
|
kwoptarg].freeze
|
32
39
|
|
@@ -178,6 +185,16 @@ module RuboCop
|
|
178
185
|
alias on_when on_case
|
179
186
|
alias on_irange on_case
|
180
187
|
alias on_erange on_case
|
188
|
+
|
189
|
+
def on_numblock(node)
|
190
|
+
children = node.children
|
191
|
+
child = children[0]
|
192
|
+
send(:"on_#{child.type}", child)
|
193
|
+
return unless (child = children[2])
|
194
|
+
|
195
|
+
send(:"on_#{child.type}", child)
|
196
|
+
end
|
181
197
|
end
|
182
198
|
end
|
183
199
|
end
|
200
|
+
# rubocop:enable Metrics/ModuleLength
|