rubocop 0.75.0 → 0.79.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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/config/default.yml +341 -316
- data/lib/rubocop.rb +48 -31
- data/lib/rubocop/ast/builder.rb +43 -41
- data/lib/rubocop/ast/node.rb +5 -1
- 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/return_node.rb +24 -0
- data/lib/rubocop/ast/traversal.rb +11 -3
- data/lib/rubocop/cli.rb +11 -227
- 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 +2 -2
- data/lib/rubocop/config.rb +8 -1
- data/lib/rubocop/config_loader.rb +20 -20
- data/lib/rubocop/config_loader_resolver.rb +2 -1
- data/lib/rubocop/config_obsoletion.rb +73 -11
- data/lib/rubocop/config_validator.rb +77 -110
- 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/commissioner.rb +15 -7
- data/lib/rubocop/cop/cop.rb +31 -6
- data/lib/rubocop/cop/corrector.rb +8 -7
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
- 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 +2 -2
- 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} +3 -2
- data/lib/rubocop/cop/layout/comment_indentation.rb +10 -13
- data/lib/rubocop/cop/layout/empty_comment.rb +7 -16
- data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +22 -7
- data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +2 -2
- data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +2 -2
- data/lib/rubocop/cop/layout/end_of_line.rb +8 -3
- data/lib/rubocop/cop/layout/extra_spacing.rb +1 -1
- data/lib/rubocop/cop/layout/{indent_first_argument.rb → first_argument_indentation.rb} +14 -12
- 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} +4 -4
- 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} +16 -8
- data/lib/rubocop/cop/layout/{indent_heredoc.rb → heredoc_indentation.rb} +5 -5
- data/lib/rubocop/cop/layout/{leading_blank_lines.rb → leading_empty_lines.rb} +1 -1
- data/lib/rubocop/cop/{metrics → layout}/line_length.rb +41 -114
- data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +14 -5
- 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/rescue_ensure_alignment.rb +2 -0
- data/lib/rubocop/cop/layout/space_around_keyword.rb +12 -0
- data/lib/rubocop/cop/layout/space_around_operators.rb +32 -7
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +17 -0
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +9 -7
- data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +7 -4
- data/lib/rubocop/cop/layout/space_inside_parens.rb +6 -6
- data/lib/rubocop/cop/layout/{trailing_blank_lines.rb → trailing_empty_lines.rb} +1 -1
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +18 -2
- data/lib/rubocop/cop/lint/debugger.rb +2 -2
- 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/erb_new_arguments.rb +9 -8
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
- data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +2 -2
- 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/{unneeded_cop_disable_directive.rb → redundant_cop_disable_directive.rb} +26 -26
- data/lib/rubocop/cop/lint/{unneeded_cop_enable_directive.rb → redundant_cop_enable_directive.rb} +10 -12
- data/lib/rubocop/cop/lint/{unneeded_require_statement.rb → redundant_require_statement.rb} +1 -1
- data/lib/rubocop/cop/lint/{unneeded_splat_expansion.rb → redundant_splat_expansion.rb} +6 -6
- 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/safe_navigation_chain.rb +5 -6
- data/lib/rubocop/cop/lint/{handle_exceptions.rb → suppressed_exception.rb} +1 -1
- data/lib/rubocop/cop/lint/unused_block_argument.rb +22 -6
- data/lib/rubocop/cop/lint/unused_method_argument.rb +23 -5
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +57 -23
- data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
- data/lib/rubocop/cop/lint/void.rb +7 -26
- data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
- data/lib/rubocop/cop/metrics/method_length.rb +1 -1
- data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +23 -6
- data/lib/rubocop/cop/migration/department_name.rb +16 -1
- data/lib/rubocop/cop/mixin/alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -7
- data/lib/rubocop/cop/mixin/{hash_alignment.rb → hash_alignment_styles.rb} +1 -1
- data/lib/rubocop/cop/mixin/line_length_help.rb +88 -0
- data/lib/rubocop/cop/mixin/method_complexity.rb +2 -1
- 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 +7 -4
- data/lib/rubocop/cop/mixin/trailing_comma.rb +14 -9
- data/lib/rubocop/cop/naming/{uncommunicative_block_param_name.rb → block_parameter_name.rb} +3 -3
- data/lib/rubocop/cop/naming/file_name.rb +12 -5
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +5 -5
- 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 +8 -3
- 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 +10 -2
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +6 -6
- data/lib/rubocop/cop/style/comment_annotation.rb +5 -5
- data/lib/rubocop/cop/style/conditional_assignment.rb +2 -2
- data/lib/rubocop/cop/style/copyright.rb +11 -7
- data/lib/rubocop/cop/style/documentation_method.rb +44 -0
- data/lib/rubocop/cop/style/double_cop_disable_directive.rb +2 -2
- data/lib/rubocop/cop/style/empty_case_condition.rb +2 -2
- data/lib/rubocop/cop/style/empty_literal.rb +2 -2
- data/lib/rubocop/cop/style/empty_method.rb +5 -5
- 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/expand_path_arguments.rb +1 -1
- data/lib/rubocop/cop/style/format_string.rb +10 -7
- data/lib/rubocop/cop/style/format_string_token.rb +15 -34
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +10 -0
- data/lib/rubocop/cop/style/guard_clause.rb +3 -2
- data/lib/rubocop/cop/style/hash_syntax.rb +2 -2
- data/lib/rubocop/cop/style/if_unless_modifier.rb +45 -3
- data/lib/rubocop/cop/style/infinite_loop.rb +5 -4
- data/lib/rubocop/cop/style/inverse_methods.rb +19 -13
- data/lib/rubocop/cop/style/ip_addresses.rb +4 -4
- data/lib/rubocop/cop/style/line_end_concatenation.rb +14 -10
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +24 -227
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +168 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +54 -0
- data/lib/rubocop/cop/style/method_def_parentheses.rb +17 -9
- 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 +6 -2
- data/lib/rubocop/cop/style/nested_modifier.rb +4 -2
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +5 -5
- data/lib/rubocop/cop/style/next.rb +5 -5
- data/lib/rubocop/cop/style/non_nil_check.rb +21 -9
- 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/percent_literal_delimiters.rb +7 -7
- data/lib/rubocop/cop/style/{unneeded_capital_w.rb → redundant_capital_w.rb} +1 -1
- data/lib/rubocop/cop/style/{unneeded_condition.rb → redundant_condition.rb} +3 -3
- data/lib/rubocop/cop/style/{unneeded_interpolation.rb → redundant_interpolation.rb} +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +3 -3
- data/lib/rubocop/cop/style/{unneeded_percent_q.rb → redundant_percent_q.rb} +1 -1
- data/lib/rubocop/cop/style/redundant_return.rb +39 -29
- data/lib/rubocop/cop/style/{unneeded_sort.rb → redundant_sort.rb} +5 -5
- data/lib/rubocop/cop/style/safe_navigation.rb +19 -8
- data/lib/rubocop/cop/style/semicolon.rb +13 -2
- data/lib/rubocop/cop/style/special_global_vars.rb +5 -7
- 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/util.rb +1 -1
- data/lib/rubocop/cop/utils/format_string.rb +10 -18
- data/lib/rubocop/cop/variable_force.rb +7 -5
- data/lib/rubocop/formatter/base_formatter.rb +2 -2
- data/lib/rubocop/formatter/clang_style_formatter.rb +9 -6
- data/lib/rubocop/formatter/emacs_style_formatter.rb +22 -12
- data/lib/rubocop/formatter/file_list_formatter.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +16 -16
- data/lib/rubocop/formatter/json_formatter.rb +6 -5
- data/lib/rubocop/formatter/pacman_formatter.rb +3 -3
- data/lib/rubocop/formatter/simple_text_formatter.rb +7 -3
- data/lib/rubocop/formatter/tap_formatter.rb +9 -6
- data/lib/rubocop/node_pattern.rb +4 -2
- data/lib/rubocop/options.rb +20 -26
- data/lib/rubocop/processed_source.rb +1 -1
- data/lib/rubocop/rake_task.rb +1 -0
- data/lib/rubocop/result_cache.rb +24 -8
- data/lib/rubocop/rspec/shared_contexts.rb +5 -0
- data/lib/rubocop/runner.rb +50 -29
- data/lib/rubocop/target_finder.rb +12 -6
- data/lib/rubocop/target_ruby.rb +151 -0
- data/lib/rubocop/version.rb +1 -1
- metadata +50 -34
- data/lib/rubocop/cop/mixin/safe_mode.rb +0 -24
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'
|
@@ -55,6 +56,7 @@ require_relative 'rubocop/ast/node/range_node'
|
|
55
56
|
require_relative 'rubocop/ast/node/regexp_node'
|
56
57
|
require_relative 'rubocop/ast/node/resbody_node'
|
57
58
|
require_relative 'rubocop/ast/node/retry_node'
|
59
|
+
require_relative 'rubocop/ast/node/return_node'
|
58
60
|
require_relative 'rubocop/ast/node/self_class_node'
|
59
61
|
require_relative 'rubocop/ast/node/send_node'
|
60
62
|
require_relative 'rubocop/ast/node/str_node'
|
@@ -117,11 +119,12 @@ require_relative 'rubocop/cop/mixin/end_keyword_alignment'
|
|
117
119
|
require_relative 'rubocop/cop/mixin/enforce_superclass'
|
118
120
|
require_relative 'rubocop/cop/mixin/first_element_line_break'
|
119
121
|
require_relative 'rubocop/cop/mixin/frozen_string_literal'
|
120
|
-
require_relative 'rubocop/cop/mixin/
|
122
|
+
require_relative 'rubocop/cop/mixin/hash_alignment_styles'
|
121
123
|
require_relative 'rubocop/cop/mixin/ignored_pattern'
|
122
124
|
require_relative 'rubocop/cop/mixin/ignored_methods'
|
123
125
|
require_relative 'rubocop/cop/mixin/integer_node'
|
124
126
|
require_relative 'rubocop/cop/mixin/interpolation'
|
127
|
+
require_relative 'rubocop/cop/mixin/line_length_help'
|
125
128
|
require_relative 'rubocop/cop/mixin/match_range'
|
126
129
|
require_relative 'rubocop/cop/mixin/method_complexity'
|
127
130
|
require_relative 'rubocop/cop/mixin/method_preference'
|
@@ -141,9 +144,9 @@ require_relative 'rubocop/cop/mixin/percent_array'
|
|
141
144
|
require_relative 'rubocop/cop/mixin/percent_literal'
|
142
145
|
require_relative 'rubocop/cop/mixin/preceding_following_alignment'
|
143
146
|
require_relative 'rubocop/cop/mixin/preferred_delimiters'
|
147
|
+
require_relative 'rubocop/cop/mixin/rational_literal'
|
144
148
|
require_relative 'rubocop/cop/mixin/rescue_node'
|
145
149
|
require_relative 'rubocop/cop/mixin/safe_assignment'
|
146
|
-
require_relative 'rubocop/cop/mixin/safe_mode'
|
147
150
|
require_relative 'rubocop/cop/mixin/space_after_punctuation'
|
148
151
|
require_relative 'rubocop/cop/mixin/space_before_punctuation'
|
149
152
|
require_relative 'rubocop/cop/mixin/surrounding_space'
|
@@ -188,10 +191,9 @@ require_relative 'rubocop/cop/gemspec/required_ruby_version'
|
|
188
191
|
require_relative 'rubocop/cop/gemspec/ruby_version_globals_usage'
|
189
192
|
|
190
193
|
require_relative 'rubocop/cop/layout/access_modifier_indentation'
|
191
|
-
require_relative 'rubocop/cop/layout/
|
192
|
-
require_relative 'rubocop/cop/layout/
|
193
|
-
require_relative 'rubocop/cop/layout/
|
194
|
-
require_relative 'rubocop/cop/layout/align_parameters'
|
194
|
+
require_relative 'rubocop/cop/layout/argument_alignment'
|
195
|
+
require_relative 'rubocop/cop/layout/array_alignment'
|
196
|
+
require_relative 'rubocop/cop/layout/assignment_indentation'
|
195
197
|
require_relative 'rubocop/cop/layout/block_alignment'
|
196
198
|
require_relative 'rubocop/cop/layout/block_end_newline'
|
197
199
|
require_relative 'rubocop/cop/layout/case_indentation'
|
@@ -212,29 +214,30 @@ require_relative 'rubocop/cop/layout/empty_lines_around_arguments'
|
|
212
214
|
require_relative 'rubocop/cop/layout/empty_lines_around_begin_body'
|
213
215
|
require_relative 'rubocop/cop/layout/empty_lines_around_block_body'
|
214
216
|
require_relative 'rubocop/cop/layout/empty_lines_around_class_body'
|
215
|
-
require_relative 'rubocop/cop/layout/empty_lines_around_exception_handling_keywords' # rubocop:disable
|
217
|
+
require_relative 'rubocop/cop/layout/empty_lines_around_exception_handling_keywords' # rubocop:disable Layout/LineLength
|
216
218
|
require_relative 'rubocop/cop/layout/empty_lines_around_method_body'
|
217
219
|
require_relative 'rubocop/cop/layout/empty_lines_around_module_body'
|
218
220
|
require_relative 'rubocop/cop/layout/empty_lines'
|
219
221
|
require_relative 'rubocop/cop/layout/end_alignment'
|
220
222
|
require_relative 'rubocop/cop/layout/end_of_line'
|
221
223
|
require_relative 'rubocop/cop/layout/extra_spacing'
|
224
|
+
require_relative 'rubocop/cop/layout/first_argument_indentation'
|
225
|
+
require_relative 'rubocop/cop/layout/first_array_element_indentation'
|
222
226
|
require_relative 'rubocop/cop/layout/first_array_element_line_break'
|
227
|
+
require_relative 'rubocop/cop/layout/first_hash_element_indentation'
|
223
228
|
require_relative 'rubocop/cop/layout/first_hash_element_line_break'
|
224
229
|
require_relative 'rubocop/cop/layout/first_method_argument_line_break'
|
225
230
|
require_relative 'rubocop/cop/layout/first_method_parameter_line_break'
|
231
|
+
require_relative 'rubocop/cop/layout/first_parameter_indentation'
|
232
|
+
require_relative 'rubocop/cop/layout/hash_alignment'
|
226
233
|
require_relative 'rubocop/cop/layout/heredoc_argument_closing_parenthesis'
|
227
|
-
require_relative 'rubocop/cop/layout/
|
234
|
+
require_relative 'rubocop/cop/layout/heredoc_indentation'
|
228
235
|
require_relative 'rubocop/cop/layout/indentation_consistency'
|
229
236
|
require_relative 'rubocop/cop/layout/indentation_width'
|
230
|
-
require_relative 'rubocop/cop/layout/indent_first_argument'
|
231
|
-
require_relative 'rubocop/cop/layout/indent_first_array_element'
|
232
|
-
require_relative 'rubocop/cop/layout/indent_first_hash_element'
|
233
|
-
require_relative 'rubocop/cop/layout/indent_first_parameter'
|
234
|
-
require_relative 'rubocop/cop/layout/indent_heredoc'
|
235
237
|
require_relative 'rubocop/cop/layout/initial_indentation'
|
236
|
-
require_relative 'rubocop/cop/layout/leading_blank_lines'
|
237
238
|
require_relative 'rubocop/cop/layout/leading_comment_space'
|
239
|
+
require_relative 'rubocop/cop/layout/leading_empty_lines'
|
240
|
+
require_relative 'rubocop/cop/layout/line_length'
|
238
241
|
require_relative 'rubocop/cop/layout/multiline_array_brace_layout'
|
239
242
|
require_relative 'rubocop/cop/layout/multiline_array_line_breaks'
|
240
243
|
require_relative 'rubocop/cop/layout/multiline_assignment_layout'
|
@@ -246,6 +249,7 @@ require_relative 'rubocop/cop/layout/multiline_method_call_brace_layout'
|
|
246
249
|
require_relative 'rubocop/cop/layout/multiline_method_call_indentation'
|
247
250
|
require_relative 'rubocop/cop/layout/multiline_method_definition_brace_layout'
|
248
251
|
require_relative 'rubocop/cop/layout/multiline_operation_indentation'
|
252
|
+
require_relative 'rubocop/cop/layout/parameter_alignment'
|
249
253
|
require_relative 'rubocop/cop/layout/rescue_ensure_alignment'
|
250
254
|
require_relative 'rubocop/cop/layout/space_after_colon'
|
251
255
|
require_relative 'rubocop/cop/layout/space_after_comma'
|
@@ -272,7 +276,7 @@ require_relative 'rubocop/cop/layout/space_inside_range_literal'
|
|
272
276
|
require_relative 'rubocop/cop/layout/space_inside_reference_brackets'
|
273
277
|
require_relative 'rubocop/cop/layout/space_inside_string_interpolation'
|
274
278
|
require_relative 'rubocop/cop/layout/tab'
|
275
|
-
require_relative 'rubocop/cop/layout/
|
279
|
+
require_relative 'rubocop/cop/layout/trailing_empty_lines'
|
276
280
|
require_relative 'rubocop/cop/layout/trailing_whitespace'
|
277
281
|
|
278
282
|
require_relative 'rubocop/cop/lint/ambiguous_block_association'
|
@@ -286,8 +290,8 @@ require_relative 'rubocop/cop/lint/debugger'
|
|
286
290
|
require_relative 'rubocop/cop/lint/deprecated_class_methods'
|
287
291
|
require_relative 'rubocop/cop/lint/disjunctive_assignment_in_constructor'
|
288
292
|
require_relative 'rubocop/cop/lint/duplicate_case_condition'
|
293
|
+
require_relative 'rubocop/cop/lint/duplicate_hash_key'
|
289
294
|
require_relative 'rubocop/cop/lint/duplicate_methods'
|
290
|
-
require_relative 'rubocop/cop/lint/duplicated_key'
|
291
295
|
require_relative 'rubocop/cop/lint/each_with_object_argument'
|
292
296
|
require_relative 'rubocop/cop/lint/else_layout'
|
293
297
|
require_relative 'rubocop/cop/lint/empty_ensure'
|
@@ -300,7 +304,6 @@ require_relative 'rubocop/cop/lint/erb_new_arguments'
|
|
300
304
|
require_relative 'rubocop/cop/lint/flip_flop'
|
301
305
|
require_relative 'rubocop/cop/lint/float_out_of_range'
|
302
306
|
require_relative 'rubocop/cop/lint/format_parameter_mismatch'
|
303
|
-
require_relative 'rubocop/cop/lint/handle_exceptions'
|
304
307
|
require_relative 'rubocop/cop/lint/heredoc_method_call_position'
|
305
308
|
require_relative 'rubocop/cop/lint/implicit_string_concatenation'
|
306
309
|
require_relative 'rubocop/cop/lint/inherit_exception'
|
@@ -310,10 +313,11 @@ require_relative 'rubocop/cop/lint/literal_as_condition'
|
|
310
313
|
require_relative 'rubocop/cop/lint/literal_in_interpolation'
|
311
314
|
require_relative 'rubocop/cop/lint/loop'
|
312
315
|
require_relative 'rubocop/cop/lint/missing_cop_enable_directive'
|
313
|
-
require_relative 'rubocop/cop/lint/
|
316
|
+
require_relative 'rubocop/cop/lint/multiple_comparison'
|
314
317
|
require_relative 'rubocop/cop/lint/nested_method_definition'
|
315
318
|
require_relative 'rubocop/cop/lint/nested_percent_literal'
|
316
319
|
require_relative 'rubocop/cop/lint/next_without_accumulator'
|
320
|
+
require_relative 'rubocop/cop/lint/non_deterministic_require_order'
|
317
321
|
require_relative 'rubocop/cop/lint/non_local_exit_from_iterator'
|
318
322
|
require_relative 'rubocop/cop/lint/number_conversion'
|
319
323
|
require_relative 'rubocop/cop/lint/ordered_magic_comments'
|
@@ -321,6 +325,11 @@ require_relative 'rubocop/cop/lint/parentheses_as_grouped_expression'
|
|
321
325
|
require_relative 'rubocop/cop/lint/percent_string_array'
|
322
326
|
require_relative 'rubocop/cop/lint/percent_symbol_array'
|
323
327
|
require_relative 'rubocop/cop/lint/rand_one'
|
328
|
+
require_relative 'rubocop/cop/lint/redundant_cop_disable_directive'
|
329
|
+
require_relative 'rubocop/cop/lint/redundant_cop_enable_directive'
|
330
|
+
require_relative 'rubocop/cop/lint/redundant_require_statement'
|
331
|
+
require_relative 'rubocop/cop/lint/redundant_splat_expansion'
|
332
|
+
require_relative 'rubocop/cop/lint/redundant_string_coercion'
|
324
333
|
require_relative 'rubocop/cop/lint/redundant_with_index'
|
325
334
|
require_relative 'rubocop/cop/lint/redundant_with_object'
|
326
335
|
require_relative 'rubocop/cop/lint/regexp_as_condition'
|
@@ -336,15 +345,11 @@ require_relative 'rubocop/cop/lint/send_with_mixin_argument'
|
|
336
345
|
require_relative 'rubocop/cop/lint/shadowed_argument'
|
337
346
|
require_relative 'rubocop/cop/lint/shadowed_exception'
|
338
347
|
require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
|
339
|
-
require_relative 'rubocop/cop/lint/
|
348
|
+
require_relative 'rubocop/cop/lint/suppressed_exception'
|
340
349
|
require_relative 'rubocop/cop/lint/syntax'
|
341
350
|
require_relative 'rubocop/cop/lint/to_json'
|
342
351
|
require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
|
343
352
|
require_relative 'rubocop/cop/lint/unified_integer'
|
344
|
-
require_relative 'rubocop/cop/lint/unneeded_cop_disable_directive'
|
345
|
-
require_relative 'rubocop/cop/lint/unneeded_cop_enable_directive'
|
346
|
-
require_relative 'rubocop/cop/lint/unneeded_require_statement'
|
347
|
-
require_relative 'rubocop/cop/lint/unneeded_splat_expansion'
|
348
353
|
require_relative 'rubocop/cop/lint/unreachable_code'
|
349
354
|
require_relative 'rubocop/cop/lint/unused_block_argument'
|
350
355
|
require_relative 'rubocop/cop/lint/unused_method_argument'
|
@@ -364,7 +369,6 @@ require_relative 'rubocop/cop/metrics/abc_size'
|
|
364
369
|
require_relative 'rubocop/cop/metrics/block_length'
|
365
370
|
require_relative 'rubocop/cop/metrics/block_nesting'
|
366
371
|
require_relative 'rubocop/cop/metrics/class_length'
|
367
|
-
require_relative 'rubocop/cop/metrics/line_length'
|
368
372
|
require_relative 'rubocop/cop/metrics/method_length'
|
369
373
|
require_relative 'rubocop/cop/metrics/module_length'
|
370
374
|
require_relative 'rubocop/cop/metrics/parameter_lists'
|
@@ -372,6 +376,7 @@ require_relative 'rubocop/cop/metrics/perceived_complexity'
|
|
372
376
|
|
373
377
|
require_relative 'rubocop/cop/naming/accessor_method_name'
|
374
378
|
require_relative 'rubocop/cop/naming/ascii_identifiers'
|
379
|
+
require_relative 'rubocop/cop/naming/block_parameter_name'
|
375
380
|
require_relative 'rubocop/cop/naming/class_and_module_camel_case'
|
376
381
|
require_relative 'rubocop/cop/naming/constant_name'
|
377
382
|
require_relative 'rubocop/cop/naming/file_name'
|
@@ -379,11 +384,10 @@ require_relative 'rubocop/cop/naming/heredoc_delimiter_case'
|
|
379
384
|
require_relative 'rubocop/cop/naming/heredoc_delimiter_naming'
|
380
385
|
require_relative 'rubocop/cop/naming/memoized_instance_variable_name'
|
381
386
|
require_relative 'rubocop/cop/naming/method_name'
|
387
|
+
require_relative 'rubocop/cop/naming/method_parameter_name'
|
382
388
|
require_relative 'rubocop/cop/naming/binary_operator_parameter_name'
|
383
389
|
require_relative 'rubocop/cop/naming/predicate_name'
|
384
390
|
require_relative 'rubocop/cop/naming/rescued_exceptions_variable_name'
|
385
|
-
require_relative 'rubocop/cop/naming/uncommunicative_block_param_name'
|
386
|
-
require_relative 'rubocop/cop/naming/uncommunicative_method_param_name'
|
387
391
|
require_relative 'rubocop/cop/naming/variable_name'
|
388
392
|
require_relative 'rubocop/cop/naming/variable_number'
|
389
393
|
|
@@ -456,7 +460,11 @@ require_relative 'rubocop/cop/style/lambda'
|
|
456
460
|
require_relative 'rubocop/cop/style/lambda_call'
|
457
461
|
require_relative 'rubocop/cop/style/line_end_concatenation'
|
458
462
|
require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
|
463
|
+
# rubocop:disable Layout/LineLength
|
459
464
|
require_relative 'rubocop/cop/style/method_call_with_args_parentheses'
|
465
|
+
require_relative 'rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses'
|
466
|
+
require_relative 'rubocop/cop/style/method_call_with_args_parentheses/require_parentheses'
|
467
|
+
# rubocop:enable Layout/LineLength
|
460
468
|
require_relative 'rubocop/cop/style/method_called_on_do_end_block'
|
461
469
|
require_relative 'rubocop/cop/style/method_def_parentheses'
|
462
470
|
require_relative 'rubocop/cop/style/method_missing_super'
|
@@ -502,12 +510,17 @@ require_relative 'rubocop/cop/style/proc'
|
|
502
510
|
require_relative 'rubocop/cop/style/raise_args'
|
503
511
|
require_relative 'rubocop/cop/style/random_with_offset'
|
504
512
|
require_relative 'rubocop/cop/style/redundant_begin'
|
513
|
+
require_relative 'rubocop/cop/style/redundant_capital_w'
|
514
|
+
require_relative 'rubocop/cop/style/redundant_condition'
|
505
515
|
require_relative 'rubocop/cop/style/redundant_conditional'
|
506
516
|
require_relative 'rubocop/cop/style/redundant_exception'
|
507
517
|
require_relative 'rubocop/cop/style/redundant_freeze'
|
518
|
+
require_relative 'rubocop/cop/style/redundant_interpolation'
|
508
519
|
require_relative 'rubocop/cop/style/redundant_parentheses'
|
520
|
+
require_relative 'rubocop/cop/style/redundant_percent_q'
|
509
521
|
require_relative 'rubocop/cop/style/redundant_return'
|
510
522
|
require_relative 'rubocop/cop/style/redundant_self'
|
523
|
+
require_relative 'rubocop/cop/style/redundant_sort'
|
511
524
|
require_relative 'rubocop/cop/style/redundant_sort_by'
|
512
525
|
require_relative 'rubocop/cop/style/regexp_literal'
|
513
526
|
require_relative 'rubocop/cop/style/rescue_modifier'
|
@@ -544,11 +557,6 @@ require_relative 'rubocop/cop/style/trailing_method_end_statement'
|
|
544
557
|
require_relative 'rubocop/cop/style/trailing_underscore_variable'
|
545
558
|
require_relative 'rubocop/cop/style/trivial_accessors'
|
546
559
|
require_relative 'rubocop/cop/style/unless_else'
|
547
|
-
require_relative 'rubocop/cop/style/unneeded_capital_w'
|
548
|
-
require_relative 'rubocop/cop/style/unneeded_condition'
|
549
|
-
require_relative 'rubocop/cop/style/unneeded_interpolation'
|
550
|
-
require_relative 'rubocop/cop/style/unneeded_percent_q'
|
551
|
-
require_relative 'rubocop/cop/style/unneeded_sort'
|
552
560
|
require_relative 'rubocop/cop/style/unpack_first'
|
553
561
|
require_relative 'rubocop/cop/style/variable_interpolation'
|
554
562
|
require_relative 'rubocop/cop/style/when_then'
|
@@ -603,6 +611,15 @@ require_relative 'rubocop/processed_source'
|
|
603
611
|
require_relative 'rubocop/result_cache'
|
604
612
|
require_relative 'rubocop/runner'
|
605
613
|
require_relative 'rubocop/cli'
|
614
|
+
require_relative 'rubocop/cli/command'
|
615
|
+
require_relative 'rubocop/cli/environment'
|
616
|
+
require_relative 'rubocop/cli/command/base'
|
617
|
+
require_relative 'rubocop/cli/command/auto_genenerate_config'
|
618
|
+
require_relative 'rubocop/cli/command/execute_runner'
|
619
|
+
require_relative 'rubocop/cli/command/init_dotfile'
|
620
|
+
require_relative 'rubocop/cli/command/show_cops'
|
621
|
+
require_relative 'rubocop/cli/command/version'
|
606
622
|
require_relative 'rubocop/options'
|
607
623
|
require_relative 'rubocop/remote_config'
|
624
|
+
require_relative 'rubocop/target_ruby'
|
608
625
|
require_relative 'rubocop/yaml_duplication_checker'
|
data/lib/rubocop/ast/builder.rb
CHANGED
@@ -15,47 +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
|
-
|
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
|
59
61
|
}.freeze
|
60
62
|
|
61
63
|
# Generates {Node} from the given information.
|
data/lib/rubocop/ast/node.rb
CHANGED
@@ -469,6 +469,10 @@ module RuboCop
|
|
469
469
|
parent&.send_type? && parent.arguments.include?(self)
|
470
470
|
end
|
471
471
|
|
472
|
+
def boolean_type?
|
473
|
+
true_type? || false_type?
|
474
|
+
end
|
475
|
+
|
472
476
|
def numeric_type?
|
473
477
|
int_type? || float_type?
|
474
478
|
end
|
@@ -620,7 +624,7 @@ module RuboCop
|
|
620
624
|
end
|
621
625
|
|
622
626
|
def parent_module_name_for_block(ancestor)
|
623
|
-
if ancestor.
|
627
|
+
if ancestor.method?(:class_eval)
|
624
628
|
# `class_eval` with no receiver applies to whatever module or class
|
625
629
|
# we are currently in
|
626
630
|
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
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module AST
|
5
|
+
# A node extension for `return` nodes. This will be used in place of a
|
6
|
+
# plain node when the builder constructs the AST, making its methods
|
7
|
+
# available to all `return` nodes within RuboCop.
|
8
|
+
class ReturnNode < Node
|
9
|
+
include MethodDispatchNode
|
10
|
+
include ParameterizedNode
|
11
|
+
|
12
|
+
# Returns the arguments of the `return`.
|
13
|
+
#
|
14
|
+
# @return [Array] The arguments of the `return`.
|
15
|
+
def arguments
|
16
|
+
if node_parts.one? && node_parts.first.begin_type?
|
17
|
+
node_parts.first.children
|
18
|
+
else
|
19
|
+
node_parts
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
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
|
|
@@ -181,3 +188,4 @@ module RuboCop
|
|
181
188
|
end
|
182
189
|
end
|
183
190
|
end
|
191
|
+
# rubocop:enable Metrics/ModuleLength
|