rubocop 0.75.1 → 0.80.0
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 +374 -335
- data/lib/rubocop.rb +53 -32
- data/lib/rubocop/ast/builder.rb +43 -41
- data/lib/rubocop/ast/node.rb +5 -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/node/return_node.rb +24 -0
- data/lib/rubocop/ast/traversal.rb +20 -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 +8 -3
- 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 -10
- 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/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} +1 -1
- 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_between_defs.rb +2 -1
- 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_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 +68 -112
- 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_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/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 +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_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_hash_literal_braces.rb +2 -9
- 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 +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/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} +18 -15
- 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/useless_access_modifier.rb +57 -23
- data/lib/rubocop/cop/lint/useless_setter_call.rb +5 -1
- data/lib/rubocop/cop/lint/void.rb +4 -4
- 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 +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 +172 -0
- 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 +16 -18
- 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/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 +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/block_delimiters.rb +60 -1
- 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/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/format_string.rb +10 -7
- data/lib/rubocop/cop/style/format_string_token.rb +2 -0
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +99 -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_syntax.rb +2 -2
- 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 +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 +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/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/or_assignment.rb +3 -2
- 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 +27 -29
- data/lib/rubocop/cop/style/{unneeded_sort.rb → redundant_sort.rb} +5 -5
- data/lib/rubocop/cop/style/safe_navigation.rb +13 -10
- data/lib/rubocop/cop/style/semicolon.rb +2 -2
- data/lib/rubocop/cop/style/special_global_vars.rb +5 -7
- 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/util.rb +1 -1
- data/lib/rubocop/cop/utils/format_string.rb +10 -18
- data/lib/rubocop/cop/variable_force.rb +11 -6
- 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 +100 -12
- data/lib/rubocop/options.rb +17 -11
- 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 +69 -35
- 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'
|
@@ -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,13 @@ 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'
|
123
|
+
require_relative 'rubocop/cop/mixin/hash_transform_method'
|
121
124
|
require_relative 'rubocop/cop/mixin/ignored_pattern'
|
122
125
|
require_relative 'rubocop/cop/mixin/ignored_methods'
|
123
126
|
require_relative 'rubocop/cop/mixin/integer_node'
|
124
127
|
require_relative 'rubocop/cop/mixin/interpolation'
|
128
|
+
require_relative 'rubocop/cop/mixin/line_length_help'
|
125
129
|
require_relative 'rubocop/cop/mixin/match_range'
|
126
130
|
require_relative 'rubocop/cop/mixin/method_complexity'
|
127
131
|
require_relative 'rubocop/cop/mixin/method_preference'
|
@@ -141,9 +145,9 @@ require_relative 'rubocop/cop/mixin/percent_array'
|
|
141
145
|
require_relative 'rubocop/cop/mixin/percent_literal'
|
142
146
|
require_relative 'rubocop/cop/mixin/preceding_following_alignment'
|
143
147
|
require_relative 'rubocop/cop/mixin/preferred_delimiters'
|
148
|
+
require_relative 'rubocop/cop/mixin/rational_literal'
|
144
149
|
require_relative 'rubocop/cop/mixin/rescue_node'
|
145
150
|
require_relative 'rubocop/cop/mixin/safe_assignment'
|
146
|
-
require_relative 'rubocop/cop/mixin/safe_mode'
|
147
151
|
require_relative 'rubocop/cop/mixin/space_after_punctuation'
|
148
152
|
require_relative 'rubocop/cop/mixin/space_before_punctuation'
|
149
153
|
require_relative 'rubocop/cop/mixin/surrounding_space'
|
@@ -188,10 +192,9 @@ require_relative 'rubocop/cop/gemspec/required_ruby_version'
|
|
188
192
|
require_relative 'rubocop/cop/gemspec/ruby_version_globals_usage'
|
189
193
|
|
190
194
|
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'
|
195
|
+
require_relative 'rubocop/cop/layout/argument_alignment'
|
196
|
+
require_relative 'rubocop/cop/layout/array_alignment'
|
197
|
+
require_relative 'rubocop/cop/layout/assignment_indentation'
|
195
198
|
require_relative 'rubocop/cop/layout/block_alignment'
|
196
199
|
require_relative 'rubocop/cop/layout/block_end_newline'
|
197
200
|
require_relative 'rubocop/cop/layout/case_indentation'
|
@@ -212,29 +215,30 @@ require_relative 'rubocop/cop/layout/empty_lines_around_arguments'
|
|
212
215
|
require_relative 'rubocop/cop/layout/empty_lines_around_begin_body'
|
213
216
|
require_relative 'rubocop/cop/layout/empty_lines_around_block_body'
|
214
217
|
require_relative 'rubocop/cop/layout/empty_lines_around_class_body'
|
215
|
-
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
|
216
219
|
require_relative 'rubocop/cop/layout/empty_lines_around_method_body'
|
217
220
|
require_relative 'rubocop/cop/layout/empty_lines_around_module_body'
|
218
221
|
require_relative 'rubocop/cop/layout/empty_lines'
|
219
222
|
require_relative 'rubocop/cop/layout/end_alignment'
|
220
223
|
require_relative 'rubocop/cop/layout/end_of_line'
|
221
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'
|
222
227
|
require_relative 'rubocop/cop/layout/first_array_element_line_break'
|
228
|
+
require_relative 'rubocop/cop/layout/first_hash_element_indentation'
|
223
229
|
require_relative 'rubocop/cop/layout/first_hash_element_line_break'
|
224
230
|
require_relative 'rubocop/cop/layout/first_method_argument_line_break'
|
225
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'
|
226
234
|
require_relative 'rubocop/cop/layout/heredoc_argument_closing_parenthesis'
|
227
|
-
require_relative 'rubocop/cop/layout/
|
235
|
+
require_relative 'rubocop/cop/layout/heredoc_indentation'
|
228
236
|
require_relative 'rubocop/cop/layout/indentation_consistency'
|
229
237
|
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
238
|
require_relative 'rubocop/cop/layout/initial_indentation'
|
236
|
-
require_relative 'rubocop/cop/layout/leading_blank_lines'
|
237
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'
|
238
242
|
require_relative 'rubocop/cop/layout/multiline_array_brace_layout'
|
239
243
|
require_relative 'rubocop/cop/layout/multiline_array_line_breaks'
|
240
244
|
require_relative 'rubocop/cop/layout/multiline_assignment_layout'
|
@@ -246,6 +250,7 @@ require_relative 'rubocop/cop/layout/multiline_method_call_brace_layout'
|
|
246
250
|
require_relative 'rubocop/cop/layout/multiline_method_call_indentation'
|
247
251
|
require_relative 'rubocop/cop/layout/multiline_method_definition_brace_layout'
|
248
252
|
require_relative 'rubocop/cop/layout/multiline_operation_indentation'
|
253
|
+
require_relative 'rubocop/cop/layout/parameter_alignment'
|
249
254
|
require_relative 'rubocop/cop/layout/rescue_ensure_alignment'
|
250
255
|
require_relative 'rubocop/cop/layout/space_after_colon'
|
251
256
|
require_relative 'rubocop/cop/layout/space_after_comma'
|
@@ -272,7 +277,7 @@ require_relative 'rubocop/cop/layout/space_inside_range_literal'
|
|
272
277
|
require_relative 'rubocop/cop/layout/space_inside_reference_brackets'
|
273
278
|
require_relative 'rubocop/cop/layout/space_inside_string_interpolation'
|
274
279
|
require_relative 'rubocop/cop/layout/tab'
|
275
|
-
require_relative 'rubocop/cop/layout/
|
280
|
+
require_relative 'rubocop/cop/layout/trailing_empty_lines'
|
276
281
|
require_relative 'rubocop/cop/layout/trailing_whitespace'
|
277
282
|
|
278
283
|
require_relative 'rubocop/cop/lint/ambiguous_block_association'
|
@@ -286,8 +291,8 @@ require_relative 'rubocop/cop/lint/debugger'
|
|
286
291
|
require_relative 'rubocop/cop/lint/deprecated_class_methods'
|
287
292
|
require_relative 'rubocop/cop/lint/disjunctive_assignment_in_constructor'
|
288
293
|
require_relative 'rubocop/cop/lint/duplicate_case_condition'
|
294
|
+
require_relative 'rubocop/cop/lint/duplicate_hash_key'
|
289
295
|
require_relative 'rubocop/cop/lint/duplicate_methods'
|
290
|
-
require_relative 'rubocop/cop/lint/duplicated_key'
|
291
296
|
require_relative 'rubocop/cop/lint/each_with_object_argument'
|
292
297
|
require_relative 'rubocop/cop/lint/else_layout'
|
293
298
|
require_relative 'rubocop/cop/lint/empty_ensure'
|
@@ -300,7 +305,6 @@ require_relative 'rubocop/cop/lint/erb_new_arguments'
|
|
300
305
|
require_relative 'rubocop/cop/lint/flip_flop'
|
301
306
|
require_relative 'rubocop/cop/lint/float_out_of_range'
|
302
307
|
require_relative 'rubocop/cop/lint/format_parameter_mismatch'
|
303
|
-
require_relative 'rubocop/cop/lint/handle_exceptions'
|
304
308
|
require_relative 'rubocop/cop/lint/heredoc_method_call_position'
|
305
309
|
require_relative 'rubocop/cop/lint/implicit_string_concatenation'
|
306
310
|
require_relative 'rubocop/cop/lint/inherit_exception'
|
@@ -310,10 +314,11 @@ require_relative 'rubocop/cop/lint/literal_as_condition'
|
|
310
314
|
require_relative 'rubocop/cop/lint/literal_in_interpolation'
|
311
315
|
require_relative 'rubocop/cop/lint/loop'
|
312
316
|
require_relative 'rubocop/cop/lint/missing_cop_enable_directive'
|
313
|
-
require_relative 'rubocop/cop/lint/
|
317
|
+
require_relative 'rubocop/cop/lint/multiple_comparison'
|
314
318
|
require_relative 'rubocop/cop/lint/nested_method_definition'
|
315
319
|
require_relative 'rubocop/cop/lint/nested_percent_literal'
|
316
320
|
require_relative 'rubocop/cop/lint/next_without_accumulator'
|
321
|
+
require_relative 'rubocop/cop/lint/non_deterministic_require_order'
|
317
322
|
require_relative 'rubocop/cop/lint/non_local_exit_from_iterator'
|
318
323
|
require_relative 'rubocop/cop/lint/number_conversion'
|
319
324
|
require_relative 'rubocop/cop/lint/ordered_magic_comments'
|
@@ -321,6 +326,11 @@ require_relative 'rubocop/cop/lint/parentheses_as_grouped_expression'
|
|
321
326
|
require_relative 'rubocop/cop/lint/percent_string_array'
|
322
327
|
require_relative 'rubocop/cop/lint/percent_symbol_array'
|
323
328
|
require_relative 'rubocop/cop/lint/rand_one'
|
329
|
+
require_relative 'rubocop/cop/lint/redundant_cop_disable_directive'
|
330
|
+
require_relative 'rubocop/cop/lint/redundant_cop_enable_directive'
|
331
|
+
require_relative 'rubocop/cop/lint/redundant_require_statement'
|
332
|
+
require_relative 'rubocop/cop/lint/redundant_splat_expansion'
|
333
|
+
require_relative 'rubocop/cop/lint/redundant_string_coercion'
|
324
334
|
require_relative 'rubocop/cop/lint/redundant_with_index'
|
325
335
|
require_relative 'rubocop/cop/lint/redundant_with_object'
|
326
336
|
require_relative 'rubocop/cop/lint/regexp_as_condition'
|
@@ -336,15 +346,11 @@ require_relative 'rubocop/cop/lint/send_with_mixin_argument'
|
|
336
346
|
require_relative 'rubocop/cop/lint/shadowed_argument'
|
337
347
|
require_relative 'rubocop/cop/lint/shadowed_exception'
|
338
348
|
require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
|
339
|
-
require_relative 'rubocop/cop/lint/
|
349
|
+
require_relative 'rubocop/cop/lint/suppressed_exception'
|
340
350
|
require_relative 'rubocop/cop/lint/syntax'
|
341
351
|
require_relative 'rubocop/cop/lint/to_json'
|
342
352
|
require_relative 'rubocop/cop/lint/underscore_prefixed_variable_name'
|
343
353
|
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
354
|
require_relative 'rubocop/cop/lint/unreachable_code'
|
349
355
|
require_relative 'rubocop/cop/lint/unused_block_argument'
|
350
356
|
require_relative 'rubocop/cop/lint/unused_method_argument'
|
@@ -364,7 +370,6 @@ require_relative 'rubocop/cop/metrics/abc_size'
|
|
364
370
|
require_relative 'rubocop/cop/metrics/block_length'
|
365
371
|
require_relative 'rubocop/cop/metrics/block_nesting'
|
366
372
|
require_relative 'rubocop/cop/metrics/class_length'
|
367
|
-
require_relative 'rubocop/cop/metrics/line_length'
|
368
373
|
require_relative 'rubocop/cop/metrics/method_length'
|
369
374
|
require_relative 'rubocop/cop/metrics/module_length'
|
370
375
|
require_relative 'rubocop/cop/metrics/parameter_lists'
|
@@ -372,6 +377,7 @@ require_relative 'rubocop/cop/metrics/perceived_complexity'
|
|
372
377
|
|
373
378
|
require_relative 'rubocop/cop/naming/accessor_method_name'
|
374
379
|
require_relative 'rubocop/cop/naming/ascii_identifiers'
|
380
|
+
require_relative 'rubocop/cop/naming/block_parameter_name'
|
375
381
|
require_relative 'rubocop/cop/naming/class_and_module_camel_case'
|
376
382
|
require_relative 'rubocop/cop/naming/constant_name'
|
377
383
|
require_relative 'rubocop/cop/naming/file_name'
|
@@ -379,11 +385,10 @@ require_relative 'rubocop/cop/naming/heredoc_delimiter_case'
|
|
379
385
|
require_relative 'rubocop/cop/naming/heredoc_delimiter_naming'
|
380
386
|
require_relative 'rubocop/cop/naming/memoized_instance_variable_name'
|
381
387
|
require_relative 'rubocop/cop/naming/method_name'
|
388
|
+
require_relative 'rubocop/cop/naming/method_parameter_name'
|
382
389
|
require_relative 'rubocop/cop/naming/binary_operator_parameter_name'
|
383
390
|
require_relative 'rubocop/cop/naming/predicate_name'
|
384
391
|
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
392
|
require_relative 'rubocop/cop/naming/variable_name'
|
388
393
|
require_relative 'rubocop/cop/naming/variable_number'
|
389
394
|
|
@@ -398,7 +403,6 @@ require_relative 'rubocop/cop/style/bare_percent_literals'
|
|
398
403
|
require_relative 'rubocop/cop/style/begin_block'
|
399
404
|
require_relative 'rubocop/cop/style/block_comments'
|
400
405
|
require_relative 'rubocop/cop/style/block_delimiters'
|
401
|
-
require_relative 'rubocop/cop/style/braces_around_hash_parameters'
|
402
406
|
require_relative 'rubocop/cop/style/case_equality'
|
403
407
|
require_relative 'rubocop/cop/style/character_literal'
|
404
408
|
require_relative 'rubocop/cop/style/class_and_module_children'
|
@@ -441,7 +445,10 @@ require_relative 'rubocop/cop/style/format_string_token'
|
|
441
445
|
require_relative 'rubocop/cop/style/frozen_string_literal_comment'
|
442
446
|
require_relative 'rubocop/cop/style/global_vars'
|
443
447
|
require_relative 'rubocop/cop/style/guard_clause'
|
448
|
+
require_relative 'rubocop/cop/style/hash_each_methods'
|
444
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'
|
445
452
|
require_relative 'rubocop/cop/style/identical_conditional_branches'
|
446
453
|
require_relative 'rubocop/cop/style/if_inside_else'
|
447
454
|
require_relative 'rubocop/cop/style/if_unless_modifier'
|
@@ -456,7 +463,11 @@ require_relative 'rubocop/cop/style/lambda'
|
|
456
463
|
require_relative 'rubocop/cop/style/lambda_call'
|
457
464
|
require_relative 'rubocop/cop/style/line_end_concatenation'
|
458
465
|
require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
|
466
|
+
# rubocop:disable Layout/LineLength
|
459
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
|
460
471
|
require_relative 'rubocop/cop/style/method_called_on_do_end_block'
|
461
472
|
require_relative 'rubocop/cop/style/method_def_parentheses'
|
462
473
|
require_relative 'rubocop/cop/style/method_missing_super'
|
@@ -502,12 +513,17 @@ require_relative 'rubocop/cop/style/proc'
|
|
502
513
|
require_relative 'rubocop/cop/style/raise_args'
|
503
514
|
require_relative 'rubocop/cop/style/random_with_offset'
|
504
515
|
require_relative 'rubocop/cop/style/redundant_begin'
|
516
|
+
require_relative 'rubocop/cop/style/redundant_capital_w'
|
517
|
+
require_relative 'rubocop/cop/style/redundant_condition'
|
505
518
|
require_relative 'rubocop/cop/style/redundant_conditional'
|
506
519
|
require_relative 'rubocop/cop/style/redundant_exception'
|
507
520
|
require_relative 'rubocop/cop/style/redundant_freeze'
|
521
|
+
require_relative 'rubocop/cop/style/redundant_interpolation'
|
508
522
|
require_relative 'rubocop/cop/style/redundant_parentheses'
|
523
|
+
require_relative 'rubocop/cop/style/redundant_percent_q'
|
509
524
|
require_relative 'rubocop/cop/style/redundant_return'
|
510
525
|
require_relative 'rubocop/cop/style/redundant_self'
|
526
|
+
require_relative 'rubocop/cop/style/redundant_sort'
|
511
527
|
require_relative 'rubocop/cop/style/redundant_sort_by'
|
512
528
|
require_relative 'rubocop/cop/style/regexp_literal'
|
513
529
|
require_relative 'rubocop/cop/style/rescue_modifier'
|
@@ -544,11 +560,6 @@ require_relative 'rubocop/cop/style/trailing_method_end_statement'
|
|
544
560
|
require_relative 'rubocop/cop/style/trailing_underscore_variable'
|
545
561
|
require_relative 'rubocop/cop/style/trivial_accessors'
|
546
562
|
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
563
|
require_relative 'rubocop/cop/style/unpack_first'
|
553
564
|
require_relative 'rubocop/cop/style/variable_interpolation'
|
554
565
|
require_relative 'rubocop/cop/style/when_then'
|
@@ -577,6 +588,7 @@ require_relative 'rubocop/formatter/file_list_formatter'
|
|
577
588
|
require_relative 'rubocop/formatter/fuubar_style_formatter'
|
578
589
|
require_relative 'rubocop/formatter/html_formatter'
|
579
590
|
require_relative 'rubocop/formatter/json_formatter'
|
591
|
+
require_relative 'rubocop/formatter/junit_formatter'
|
580
592
|
require_relative 'rubocop/formatter/offense_count_formatter'
|
581
593
|
require_relative 'rubocop/formatter/progress_formatter'
|
582
594
|
require_relative 'rubocop/formatter/quiet_formatter'
|
@@ -603,6 +615,15 @@ require_relative 'rubocop/processed_source'
|
|
603
615
|
require_relative 'rubocop/result_cache'
|
604
616
|
require_relative 'rubocop/runner'
|
605
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'
|
606
626
|
require_relative 'rubocop/options'
|
607
627
|
require_relative 'rubocop/remote_config'
|
628
|
+
require_relative 'rubocop/target_ruby'
|
608
629
|
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
@@ -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
|
@@ -469,6 +457,10 @@ module RuboCop
|
|
469
457
|
parent&.send_type? && parent.arguments.include?(self)
|
470
458
|
end
|
471
459
|
|
460
|
+
def boolean_type?
|
461
|
+
true_type? || false_type?
|
462
|
+
end
|
463
|
+
|
472
464
|
def numeric_type?
|
473
465
|
int_type? || float_type?
|
474
466
|
end
|
@@ -620,7 +612,7 @@ module RuboCop
|
|
620
612
|
end
|
621
613
|
|
622
614
|
def parent_module_name_for_block(ancestor)
|
623
|
-
if ancestor.
|
615
|
+
if ancestor.method?(:class_eval)
|
624
616
|
# `class_eval` with no receiver applies to whatever module or class
|
625
617
|
# we are currently in
|
626
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
|