rubocop 0.79.0 → 0.83.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/LICENSE.txt +1 -1
- data/README.md +5 -5
- data/config/default.yml +184 -50
- data/lib/rubocop.rb +15 -5
- data/lib/rubocop/ast/builder.rb +2 -0
- data/lib/rubocop/ast/node.rb +12 -19
- data/lib/rubocop/ast/node/array_node.rb +13 -0
- data/lib/rubocop/ast/node/block_node.rb +5 -1
- data/lib/rubocop/ast/node/case_match_node.rb +56 -0
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +8 -0
- data/lib/rubocop/ast/node/regexp_node.rb +2 -4
- data/lib/rubocop/ast/node/send_node.rb +4 -0
- data/lib/rubocop/ast/traversal.rb +20 -9
- data/lib/rubocop/cli.rb +11 -5
- data/lib/rubocop/comment_config.rb +6 -1
- data/lib/rubocop/config.rb +40 -10
- data/lib/rubocop/config_loader.rb +43 -33
- data/lib/rubocop/config_loader_resolver.rb +28 -1
- data/lib/rubocop/config_obsoletion.rb +4 -1
- data/lib/rubocop/config_validator.rb +18 -1
- data/lib/rubocop/cop/badge.rb +5 -5
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
- data/lib/rubocop/cop/corrector.rb +48 -24
- data/lib/rubocop/cop/correctors/alignment_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/condition_corrector.rb +1 -2
- data/lib/rubocop/cop/correctors/empty_line_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +3 -3
- data/lib/rubocop/cop/correctors/line_break_corrector.rb +2 -2
- data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +1 -1
- data/lib/rubocop/cop/correctors/string_literal_corrector.rb +2 -2
- data/lib/rubocop/cop/generator.rb +3 -2
- data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +1 -1
- data/lib/rubocop/cop/layout/array_alignment.rb +53 -10
- data/lib/rubocop/cop/layout/block_end_newline.rb +5 -3
- data/lib/rubocop/cop/layout/condition_position.rb +12 -2
- data/lib/rubocop/cop/layout/dot_position.rb +1 -1
- data/lib/rubocop/cop/layout/else_alignment.rb +8 -0
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +2 -1
- data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +68 -0
- data/lib/rubocop/cop/layout/end_of_line.rb +2 -2
- data/lib/rubocop/cop/layout/first_array_element_indentation.rb +16 -10
- data/lib/rubocop/cop/layout/first_hash_element_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +2 -2
- data/lib/rubocop/cop/layout/heredoc_indentation.rb +2 -2
- data/lib/rubocop/cop/layout/{tab.rb → indentation_style.rb} +48 -6
- data/lib/rubocop/cop/layout/leading_comment_space.rb +34 -3
- data/lib/rubocop/cop/layout/line_length.rb +36 -4
- data/lib/rubocop/cop/layout/multiline_block_layout.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +0 -4
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +13 -4
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +3 -3
- data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +133 -0
- data/lib/rubocop/cop/layout/space_around_operators.rb +37 -2
- data/lib/rubocop/cop/layout/space_before_first_arg.rb +8 -0
- data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_block_braces.rb +2 -2
- data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +2 -9
- data/lib/rubocop/cop/layout/space_inside_range_literal.rb +2 -2
- data/lib/rubocop/cop/layout/trailing_whitespace.rb +2 -2
- data/lib/rubocop/cop/lint/ambiguous_operator.rb +38 -0
- data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +14 -0
- data/lib/rubocop/cop/lint/boolean_symbol.rb +12 -0
- data/lib/rubocop/cop/lint/debugger.rb +2 -2
- data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -5
- data/lib/rubocop/cop/lint/empty_when.rb +29 -6
- data/lib/rubocop/cop/lint/ensure_return.rb +18 -1
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -1
- data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +1 -1
- data/lib/rubocop/cop/lint/inherit_exception.rb +1 -1
- data/lib/rubocop/cop/lint/interpolation_check.rb +1 -1
- data/lib/rubocop/cop/lint/literal_as_condition.rb +10 -13
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/loop.rb +6 -4
- data/lib/rubocop/cop/lint/multiple_comparison.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +2 -2
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +2 -2
- data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +21 -9
- data/lib/rubocop/cop/lint/percent_string_array.rb +2 -2
- data/lib/rubocop/cop/lint/raise_exception.rb +75 -0
- data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +1 -6
- data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +12 -7
- data/lib/rubocop/cop/lint/redundant_string_coercion.rb +1 -1
- data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -1
- data/lib/rubocop/cop/lint/struct_new_override.rb +58 -0
- data/lib/rubocop/cop/lint/suppressed_exception.rb +12 -28
- data/lib/rubocop/cop/lint/unified_integer.rb +0 -2
- data/lib/rubocop/cop/lint/unused_method_argument.rb +32 -6
- data/lib/rubocop/cop/lint/uri_regexp.rb +4 -4
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +12 -0
- data/lib/rubocop/cop/lint/useless_assignment.rb +3 -2
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +5 -0
- data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -0
- data/lib/rubocop/cop/migration/department_name.rb +36 -10
- data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +4 -0
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +6 -1
- data/lib/rubocop/cop/mixin/frozen_string_literal.rb +16 -1
- data/lib/rubocop/cop/mixin/hash_transform_method.rb +178 -0
- data/lib/rubocop/cop/mixin/line_length_help.rb +2 -1
- data/lib/rubocop/cop/mixin/method_complexity.rb +5 -0
- data/lib/rubocop/cop/mixin/parser_diagnostic.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +7 -22
- data/lib/rubocop/cop/mixin/target_ruby_version.rb +5 -1
- data/lib/rubocop/cop/mixin/trailing_comma.rb +3 -10
- data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +1 -1
- data/lib/rubocop/cop/naming/constant_name.rb +2 -1
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +1 -1
- data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
- data/lib/rubocop/cop/naming/method_name.rb +26 -0
- data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
- data/lib/rubocop/cop/registry.rb +11 -4
- data/lib/rubocop/cop/style/access_modifier_declarations.rb +26 -6
- data/lib/rubocop/cop/style/alias.rb +4 -4
- data/lib/rubocop/cop/style/and_or.rb +5 -6
- data/lib/rubocop/cop/style/array_join.rb +1 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +60 -1
- data/lib/rubocop/cop/style/case_equality.rb +24 -1
- data/lib/rubocop/cop/style/character_literal.rb +2 -2
- data/lib/rubocop/cop/style/collection_methods.rb +2 -0
- data/lib/rubocop/cop/style/conditional_assignment.rb +8 -8
- data/lib/rubocop/cop/style/copyright.rb +1 -1
- data/lib/rubocop/cop/style/dir.rb +1 -1
- data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +49 -0
- data/lib/rubocop/cop/style/documentation.rb +43 -5
- data/lib/rubocop/cop/style/double_cop_disable_directive.rb +1 -1
- data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
- data/lib/rubocop/cop/style/each_with_object.rb +3 -3
- data/lib/rubocop/cop/style/empty_method.rb +1 -5
- data/lib/rubocop/cop/style/end_block.rb +6 -0
- data/lib/rubocop/cop/style/even_odd.rb +1 -1
- data/lib/rubocop/cop/style/expand_path_arguments.rb +3 -3
- data/lib/rubocop/cop/style/exponential_notation.rb +119 -0
- data/lib/rubocop/cop/style/format_string.rb +2 -2
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +89 -11
- data/lib/rubocop/cop/style/guard_clause.rb +25 -2
- data/lib/rubocop/cop/style/hash_each_methods.rb +89 -0
- data/lib/rubocop/cop/style/hash_syntax.rb +3 -5
- data/lib/rubocop/cop/style/hash_transform_keys.rb +83 -0
- data/lib/rubocop/cop/style/hash_transform_values.rb +80 -0
- data/lib/rubocop/cop/style/if_unless_modifier.rb +23 -3
- data/lib/rubocop/cop/style/if_with_semicolon.rb +16 -0
- data/lib/rubocop/cop/style/inverse_methods.rb +9 -5
- data/lib/rubocop/cop/style/lambda.rb +3 -2
- data/lib/rubocop/cop/style/lambda_call.rb +1 -21
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +5 -0
- data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +5 -4
- data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
- data/lib/rubocop/cop/style/module_function.rb +58 -12
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +1 -1
- data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
- data/lib/rubocop/cop/style/multiline_when_then.rb +16 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +2 -4
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +4 -4
- data/lib/rubocop/cop/style/next.rb +2 -2
- data/lib/rubocop/cop/style/nil_comparison.rb +1 -1
- data/lib/rubocop/cop/style/non_nil_check.rb +4 -4
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +1 -1
- data/lib/rubocop/cop/style/numeric_literals.rb +1 -1
- data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
- data/lib/rubocop/cop/style/one_line_conditional.rb +4 -3
- data/lib/rubocop/cop/style/optional_arguments.rb +1 -1
- data/lib/rubocop/cop/style/or_assignment.rb +4 -3
- data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
- data/lib/rubocop/cop/style/perl_backrefs.rb +2 -2
- data/lib/rubocop/cop/style/proc.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +1 -1
- data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
- data/lib/rubocop/cop/style/redundant_condition.rb +18 -6
- data/lib/rubocop/cop/style/redundant_conditional.rb +1 -1
- data/lib/rubocop/cop/style/redundant_exception.rb +3 -3
- data/lib/rubocop/cop/style/redundant_interpolation.rb +2 -2
- data/lib/rubocop/cop/style/redundant_percent_q.rb +2 -2
- data/lib/rubocop/cop/style/redundant_return.rb +5 -7
- data/lib/rubocop/cop/style/redundant_self.rb +1 -1
- data/lib/rubocop/cop/style/redundant_sort.rb +2 -2
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
- data/lib/rubocop/cop/style/return_nil.rb +1 -1
- data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
- data/lib/rubocop/cop/style/self_assignment.rb +1 -1
- data/lib/rubocop/cop/style/slicing_with_range.rb +39 -0
- data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +1 -4
- data/lib/rubocop/cop/style/string_hash_keys.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +3 -3
- data/lib/rubocop/cop/style/symbol_literal.rb +2 -2
- data/lib/rubocop/cop/style/ternary_parentheses.rb +2 -3
- data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +35 -22
- data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +41 -0
- data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +88 -0
- data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +44 -0
- data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
- data/lib/rubocop/cop/style/unpack_first.rb +0 -4
- data/lib/rubocop/cop/style/variable_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
- data/lib/rubocop/cop/style/word_array.rb +1 -1
- data/lib/rubocop/cop/style/zero_length_predicate.rb +1 -1
- data/lib/rubocop/cop/util.rb +24 -0
- data/lib/rubocop/cop/variable_force.rb +4 -1
- data/lib/rubocop/cop/variable_force/assignment.rb +1 -0
- data/lib/rubocop/cop/variable_force/scope.rb +1 -0
- data/lib/rubocop/cop/variable_force/variable.rb +1 -0
- data/lib/rubocop/formatter/clang_style_formatter.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +1 -1
- data/lib/rubocop/formatter/junit_formatter.rb +74 -0
- data/lib/rubocop/formatter/pacman_formatter.rb +1 -1
- data/lib/rubocop/formatter/tap_formatter.rb +1 -1
- data/lib/rubocop/name_similarity.rb +12 -9
- data/lib/rubocop/node_pattern.rb +96 -10
- data/lib/rubocop/options.rb +18 -5
- data/lib/rubocop/processed_source.rb +1 -4
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/rspec/expect_offense.rb +1 -1
- data/lib/rubocop/rspec/shared_contexts.rb +0 -4
- data/lib/rubocop/runner.rb +7 -2
- data/lib/rubocop/target_finder.rb +6 -4
- data/lib/rubocop/target_ruby.rb +2 -2
- data/lib/rubocop/version.rb +1 -1
- metadata +35 -25
- data/lib/rubocop/cop/lint/end_in_method.rb +0 -40
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +0 -209
- data/lib/rubocop/formatter/disabled_lines_formatter.rb +0 -57
- data/lib/rubocop/string_util.rb +0 -14
data/lib/rubocop.rb
CHANGED
@@ -14,7 +14,6 @@ require_relative 'rubocop/core_ext/string'
|
|
14
14
|
require_relative 'rubocop/path_util'
|
15
15
|
require_relative 'rubocop/file_finder'
|
16
16
|
require_relative 'rubocop/platform'
|
17
|
-
require_relative 'rubocop/string_util'
|
18
17
|
require_relative 'rubocop/name_similarity'
|
19
18
|
require_relative 'rubocop/node_pattern'
|
20
19
|
require_relative 'rubocop/string_interpreter'
|
@@ -37,6 +36,7 @@ require_relative 'rubocop/ast/node/args_node'
|
|
37
36
|
require_relative 'rubocop/ast/node/array_node'
|
38
37
|
require_relative 'rubocop/ast/node/block_node'
|
39
38
|
require_relative 'rubocop/ast/node/break_node'
|
39
|
+
require_relative 'rubocop/ast/node/case_match_node'
|
40
40
|
require_relative 'rubocop/ast/node/case_node'
|
41
41
|
require_relative 'rubocop/ast/node/class_node'
|
42
42
|
require_relative 'rubocop/ast/node/def_node'
|
@@ -120,6 +120,7 @@ require_relative 'rubocop/cop/mixin/enforce_superclass'
|
|
120
120
|
require_relative 'rubocop/cop/mixin/first_element_line_break'
|
121
121
|
require_relative 'rubocop/cop/mixin/frozen_string_literal'
|
122
122
|
require_relative 'rubocop/cop/mixin/hash_alignment_styles'
|
123
|
+
require_relative 'rubocop/cop/mixin/hash_transform_method'
|
123
124
|
require_relative 'rubocop/cop/mixin/ignored_pattern'
|
124
125
|
require_relative 'rubocop/cop/mixin/ignored_methods'
|
125
126
|
require_relative 'rubocop/cop/mixin/integer_node'
|
@@ -211,6 +212,7 @@ require_relative 'rubocop/cop/layout/empty_line_after_magic_comment'
|
|
211
212
|
require_relative 'rubocop/cop/layout/empty_line_between_defs'
|
212
213
|
require_relative 'rubocop/cop/layout/empty_lines_around_access_modifier'
|
213
214
|
require_relative 'rubocop/cop/layout/empty_lines_around_arguments'
|
215
|
+
require_relative 'rubocop/cop/layout/empty_lines_around_attribute_accessor'
|
214
216
|
require_relative 'rubocop/cop/layout/empty_lines_around_begin_body'
|
215
217
|
require_relative 'rubocop/cop/layout/empty_lines_around_block_body'
|
216
218
|
require_relative 'rubocop/cop/layout/empty_lines_around_class_body'
|
@@ -233,6 +235,7 @@ require_relative 'rubocop/cop/layout/hash_alignment'
|
|
233
235
|
require_relative 'rubocop/cop/layout/heredoc_argument_closing_parenthesis'
|
234
236
|
require_relative 'rubocop/cop/layout/heredoc_indentation'
|
235
237
|
require_relative 'rubocop/cop/layout/indentation_consistency'
|
238
|
+
require_relative 'rubocop/cop/layout/indentation_style'
|
236
239
|
require_relative 'rubocop/cop/layout/indentation_width'
|
237
240
|
require_relative 'rubocop/cop/layout/initial_indentation'
|
238
241
|
require_relative 'rubocop/cop/layout/leading_comment_space'
|
@@ -259,6 +262,7 @@ require_relative 'rubocop/cop/layout/space_after_semicolon'
|
|
259
262
|
require_relative 'rubocop/cop/layout/space_around_block_parameters'
|
260
263
|
require_relative 'rubocop/cop/layout/space_around_equals_in_parameter_default'
|
261
264
|
require_relative 'rubocop/cop/layout/space_around_keyword'
|
265
|
+
require_relative 'rubocop/cop/layout/space_around_method_call_operator'
|
262
266
|
require_relative 'rubocop/cop/layout/space_around_operators'
|
263
267
|
require_relative 'rubocop/cop/layout/space_before_block_braces'
|
264
268
|
require_relative 'rubocop/cop/layout/space_before_comma'
|
@@ -275,7 +279,6 @@ require_relative 'rubocop/cop/layout/space_inside_percent_literal_delimiters'
|
|
275
279
|
require_relative 'rubocop/cop/layout/space_inside_range_literal'
|
276
280
|
require_relative 'rubocop/cop/layout/space_inside_reference_brackets'
|
277
281
|
require_relative 'rubocop/cop/layout/space_inside_string_interpolation'
|
278
|
-
require_relative 'rubocop/cop/layout/tab'
|
279
282
|
require_relative 'rubocop/cop/layout/trailing_empty_lines'
|
280
283
|
require_relative 'rubocop/cop/layout/trailing_whitespace'
|
281
284
|
|
@@ -298,7 +301,6 @@ require_relative 'rubocop/cop/lint/empty_ensure'
|
|
298
301
|
require_relative 'rubocop/cop/lint/empty_expression'
|
299
302
|
require_relative 'rubocop/cop/lint/empty_interpolation'
|
300
303
|
require_relative 'rubocop/cop/lint/empty_when'
|
301
|
-
require_relative 'rubocop/cop/lint/end_in_method'
|
302
304
|
require_relative 'rubocop/cop/lint/ensure_return'
|
303
305
|
require_relative 'rubocop/cop/lint/erb_new_arguments'
|
304
306
|
require_relative 'rubocop/cop/lint/flip_flop'
|
@@ -324,6 +326,7 @@ require_relative 'rubocop/cop/lint/ordered_magic_comments'
|
|
324
326
|
require_relative 'rubocop/cop/lint/parentheses_as_grouped_expression'
|
325
327
|
require_relative 'rubocop/cop/lint/percent_string_array'
|
326
328
|
require_relative 'rubocop/cop/lint/percent_symbol_array'
|
329
|
+
require_relative 'rubocop/cop/lint/raise_exception'
|
327
330
|
require_relative 'rubocop/cop/lint/rand_one'
|
328
331
|
require_relative 'rubocop/cop/lint/redundant_cop_disable_directive'
|
329
332
|
require_relative 'rubocop/cop/lint/redundant_cop_enable_directive'
|
@@ -345,6 +348,7 @@ require_relative 'rubocop/cop/lint/send_with_mixin_argument'
|
|
345
348
|
require_relative 'rubocop/cop/lint/shadowed_argument'
|
346
349
|
require_relative 'rubocop/cop/lint/shadowed_exception'
|
347
350
|
require_relative 'rubocop/cop/lint/shadowing_outer_local_variable'
|
351
|
+
require_relative 'rubocop/cop/lint/struct_new_override'
|
348
352
|
require_relative 'rubocop/cop/lint/suppressed_exception'
|
349
353
|
require_relative 'rubocop/cop/lint/syntax'
|
350
354
|
require_relative 'rubocop/cop/lint/to_json'
|
@@ -402,7 +406,6 @@ require_relative 'rubocop/cop/style/bare_percent_literals'
|
|
402
406
|
require_relative 'rubocop/cop/style/begin_block'
|
403
407
|
require_relative 'rubocop/cop/style/block_comments'
|
404
408
|
require_relative 'rubocop/cop/style/block_delimiters'
|
405
|
-
require_relative 'rubocop/cop/style/braces_around_hash_parameters'
|
406
409
|
require_relative 'rubocop/cop/style/case_equality'
|
407
410
|
require_relative 'rubocop/cop/style/character_literal'
|
408
411
|
require_relative 'rubocop/cop/style/class_and_module_children'
|
@@ -421,6 +424,7 @@ require_relative 'rubocop/cop/style/copyright'
|
|
421
424
|
require_relative 'rubocop/cop/style/date_time'
|
422
425
|
require_relative 'rubocop/cop/style/def_with_parentheses'
|
423
426
|
require_relative 'rubocop/cop/style/dir'
|
427
|
+
require_relative 'rubocop/cop/style/disable_cops_within_source_code_directive'
|
424
428
|
require_relative 'rubocop/cop/style/documentation_method'
|
425
429
|
require_relative 'rubocop/cop/style/documentation'
|
426
430
|
require_relative 'rubocop/cop/style/double_cop_disable_directive'
|
@@ -438,6 +442,7 @@ require_relative 'rubocop/cop/style/end_block'
|
|
438
442
|
require_relative 'rubocop/cop/style/eval_with_location'
|
439
443
|
require_relative 'rubocop/cop/style/even_odd'
|
440
444
|
require_relative 'rubocop/cop/style/expand_path_arguments'
|
445
|
+
require_relative 'rubocop/cop/style/exponential_notation'
|
441
446
|
require_relative 'rubocop/cop/style/float_division'
|
442
447
|
require_relative 'rubocop/cop/style/for'
|
443
448
|
require_relative 'rubocop/cop/style/format_string'
|
@@ -445,7 +450,10 @@ require_relative 'rubocop/cop/style/format_string_token'
|
|
445
450
|
require_relative 'rubocop/cop/style/frozen_string_literal_comment'
|
446
451
|
require_relative 'rubocop/cop/style/global_vars'
|
447
452
|
require_relative 'rubocop/cop/style/guard_clause'
|
453
|
+
require_relative 'rubocop/cop/style/hash_each_methods'
|
448
454
|
require_relative 'rubocop/cop/style/hash_syntax'
|
455
|
+
require_relative 'rubocop/cop/style/hash_transform_keys'
|
456
|
+
require_relative 'rubocop/cop/style/hash_transform_values'
|
449
457
|
require_relative 'rubocop/cop/style/identical_conditional_branches'
|
450
458
|
require_relative 'rubocop/cop/style/if_inside_else'
|
451
459
|
require_relative 'rubocop/cop/style/if_unless_modifier'
|
@@ -534,6 +542,7 @@ require_relative 'rubocop/cop/style/send'
|
|
534
542
|
require_relative 'rubocop/cop/style/signal_exception'
|
535
543
|
require_relative 'rubocop/cop/style/single_line_block_params'
|
536
544
|
require_relative 'rubocop/cop/style/single_line_methods'
|
545
|
+
require_relative 'rubocop/cop/style/slicing_with_range'
|
537
546
|
require_relative 'rubocop/cop/style/special_global_vars'
|
538
547
|
require_relative 'rubocop/cop/style/stabby_lambda_parentheses'
|
539
548
|
require_relative 'rubocop/cop/style/stderr_puts'
|
@@ -552,6 +561,7 @@ require_relative 'rubocop/cop/style/trailing_body_on_method_definition'
|
|
552
561
|
require_relative 'rubocop/cop/style/trailing_body_on_module'
|
553
562
|
require_relative 'rubocop/cop/style/trailing_comma_in_arguments'
|
554
563
|
require_relative 'rubocop/cop/style/trailing_comma_in_array_literal'
|
564
|
+
require_relative 'rubocop/cop/style/trailing_comma_in_block_args'
|
555
565
|
require_relative 'rubocop/cop/style/trailing_comma_in_hash_literal'
|
556
566
|
require_relative 'rubocop/cop/style/trailing_method_end_statement'
|
557
567
|
require_relative 'rubocop/cop/style/trailing_underscore_variable'
|
@@ -579,12 +589,12 @@ require_relative 'rubocop/formatter/simple_text_formatter'
|
|
579
589
|
# relies on simple text
|
580
590
|
require_relative 'rubocop/formatter/clang_style_formatter'
|
581
591
|
require_relative 'rubocop/formatter/disabled_config_formatter'
|
582
|
-
require_relative 'rubocop/formatter/disabled_lines_formatter'
|
583
592
|
require_relative 'rubocop/formatter/emacs_style_formatter'
|
584
593
|
require_relative 'rubocop/formatter/file_list_formatter'
|
585
594
|
require_relative 'rubocop/formatter/fuubar_style_formatter'
|
586
595
|
require_relative 'rubocop/formatter/html_formatter'
|
587
596
|
require_relative 'rubocop/formatter/json_formatter'
|
597
|
+
require_relative 'rubocop/formatter/junit_formatter'
|
588
598
|
require_relative 'rubocop/formatter/offense_count_formatter'
|
589
599
|
require_relative 'rubocop/formatter/progress_formatter'
|
590
600
|
require_relative 'rubocop/formatter/quiet_formatter'
|
data/lib/rubocop/ast/builder.rb
CHANGED
data/lib/rubocop/ast/node.rb
CHANGED
@@ -98,7 +98,7 @@ module RuboCop
|
|
98
98
|
@mutable_attributes.frozen?
|
99
99
|
end
|
100
100
|
|
101
|
-
protected :parent=
|
101
|
+
protected :parent=
|
102
102
|
|
103
103
|
# Override `AST::Node#updated` so that `AST::Processor` does not try to
|
104
104
|
# mutate our ASTs. Since we keep references from children to parents and
|
@@ -116,7 +116,7 @@ module RuboCop
|
|
116
116
|
#
|
117
117
|
# @return [Integer] the index of the receiver node in its siblings
|
118
118
|
def sibling_index
|
119
|
-
parent
|
119
|
+
parent&.children&.index { |sibling| sibling.equal?(self) }
|
120
120
|
end
|
121
121
|
|
122
122
|
# Common destructuring method. This can be used to normalize
|
@@ -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
|
@@ -303,7 +291,7 @@ module RuboCop
|
|
303
291
|
## Destructuring
|
304
292
|
|
305
293
|
def_node_matcher :receiver, <<~PATTERN
|
306
|
-
{(send $_ ...) (block (send $_ ...) ...)}
|
294
|
+
{(send $_ ...) ({block numblock} (send $_ ...) ...)}
|
307
295
|
PATTERN
|
308
296
|
|
309
297
|
def_node_matcher :str_content, '(str $_)'
|
@@ -325,9 +313,8 @@ module RuboCop
|
|
325
313
|
(casgn $_ $_ (send (const nil? {:Class :Module}) :new ...))
|
326
314
|
(casgn $_ $_ (block (send (const nil? {:Class :Module}) :new ...) ...))}
|
327
315
|
PATTERN
|
328
|
-
|
316
|
+
|
329
317
|
private :defined_module0
|
330
|
-
# rubocop:enable Style/AccessModifierDeclarations
|
331
318
|
|
332
319
|
def defined_module
|
333
320
|
namespace, name = *defined_module0
|
@@ -481,7 +468,13 @@ module RuboCop
|
|
481
468
|
irange_type? || erange_type?
|
482
469
|
end
|
483
470
|
|
484
|
-
|
471
|
+
def guard_clause?
|
472
|
+
node = and_type? || or_type? ? rhs : self
|
473
|
+
|
474
|
+
node.match_guard_clause?
|
475
|
+
end
|
476
|
+
|
477
|
+
def_node_matcher :match_guard_clause?, <<~PATTERN
|
485
478
|
[${(send nil? {:raise :fail} ...) return break next} single_line?]
|
486
479
|
PATTERN
|
487
480
|
|
@@ -491,7 +484,7 @@ module RuboCop
|
|
491
484
|
(send (const nil? :Proc) :new)}
|
492
485
|
PATTERN
|
493
486
|
|
494
|
-
def_node_matcher :lambda?, '(block (send nil? :lambda) ...)'
|
487
|
+
def_node_matcher :lambda?, '({block numblock} (send nil? :lambda) ...)'
|
495
488
|
def_node_matcher :lambda_or_proc?, '{lambda? proc?}'
|
496
489
|
|
497
490
|
def_node_matcher :class_constructor?, <<~PATTERN
|
@@ -18,6 +18,19 @@ module RuboCop
|
|
18
18
|
each_child_node.to_a
|
19
19
|
end
|
20
20
|
|
21
|
+
# Calls the given block for all values in the `array` literal.
|
22
|
+
#
|
23
|
+
# @yieldparam [Node] node each node
|
24
|
+
# @return [self] if a block is given
|
25
|
+
# @return [Enumerator] if no block is given
|
26
|
+
def each_value(&block)
|
27
|
+
return to_enum(__method__) unless block_given?
|
28
|
+
|
29
|
+
values.each(&block)
|
30
|
+
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
21
34
|
# Checks whether the `array` literal is delimited by square brackets.
|
22
35
|
#
|
23
36
|
# @return [Boolean] whether the array is enclosed in square brackets
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module AST
|
5
|
+
# A node extension for `case_match` nodes. This will be used in place of
|
6
|
+
# a plain node when the builder constructs the AST, making its methods
|
7
|
+
# available to all `case_match` nodes within RuboCop.
|
8
|
+
class CaseMatchNode < Node
|
9
|
+
include ConditionalNode
|
10
|
+
|
11
|
+
# Returns the keyword of the `case` statement as a string.
|
12
|
+
#
|
13
|
+
# @return [String] the keyword of the `case` statement
|
14
|
+
def keyword
|
15
|
+
'case'
|
16
|
+
end
|
17
|
+
|
18
|
+
# Calls the given block for each `in_pattern` node in the `in` statement.
|
19
|
+
# If no block is given, an `Enumerator` is returned.
|
20
|
+
#
|
21
|
+
# @return [self] if a block is given
|
22
|
+
# @return [Enumerator] if no block is given
|
23
|
+
def each_in_pattern
|
24
|
+
return in_pattern_branches.to_enum(__method__) unless block_given?
|
25
|
+
|
26
|
+
in_pattern_branches.each do |condition|
|
27
|
+
yield condition
|
28
|
+
end
|
29
|
+
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns an array of all the when branches in the `case` statement.
|
34
|
+
#
|
35
|
+
# @return [Array<Node>] an array of `in_pattern` nodes
|
36
|
+
def in_pattern_branches
|
37
|
+
node_parts[1...-1]
|
38
|
+
end
|
39
|
+
|
40
|
+
# Returns the else branch of the `case` statement, if any.
|
41
|
+
#
|
42
|
+
# @return [Node] the else branch node of the `case` statement
|
43
|
+
# @return [nil] if the case statement does not have an else branch.
|
44
|
+
def else_branch
|
45
|
+
node_parts[-1]
|
46
|
+
end
|
47
|
+
|
48
|
+
# Checks whether this case statement has an `else` branch.
|
49
|
+
#
|
50
|
+
# @return [Boolean] whether the `case` statement has an `else` branch
|
51
|
+
def else?
|
52
|
+
!loc.else.nil?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -121,6 +121,14 @@ module RuboCop
|
|
121
121
|
loc.respond_to?(:dot) && loc.dot && loc.dot.is?('::')
|
122
122
|
end
|
123
123
|
|
124
|
+
# Checks whether the dispatched method uses a safe navigation operator to
|
125
|
+
# connect the receiver and the method name.
|
126
|
+
#
|
127
|
+
# @return [Boolean] whether the method was called with a connecting dot
|
128
|
+
def safe_navigation?
|
129
|
+
loc.respond_to?(:dot) && loc.dot && loc.dot.is?('&.')
|
130
|
+
end
|
131
|
+
|
124
132
|
# Checks whether the *explicit* receiver of this method dispatch is
|
125
133
|
# `self`.
|
126
134
|
#
|
@@ -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
|
@@ -21,7 +21,7 @@ module RuboCop
|
|
21
21
|
arg restarg blockarg shadowarg
|
22
22
|
kwrestarg zsuper lambda redo retry
|
23
23
|
forward_args forwarded_args
|
24
|
-
match_var match_nil_pattern].freeze
|
24
|
+
match_var match_nil_pattern empty_else].freeze
|
25
25
|
ONE_CHILD_NODE = %i[splat kwsplat block_pass not break next
|
26
26
|
preexe postexe match_current_line defined?
|
27
27
|
arg_expr pin match_rest if_guard unless_guard
|
@@ -31,7 +31,7 @@ module RuboCop
|
|
31
31
|
undef alias args super yield or and
|
32
32
|
while_post until_post iflipflop eflipflop
|
33
33
|
match_with_lvasgn begin kwbegin return
|
34
|
-
in_match
|
34
|
+
in_match match_alt
|
35
35
|
match_as array_pattern array_pattern_with_tail
|
36
36
|
hash_pattern const_pattern].freeze
|
37
37
|
SECOND_CHILD_ONLY = %i[lvasgn ivasgn cvasgn gvasgn optarg kwarg
|
@@ -178,13 +178,24 @@ module RuboCop
|
|
178
178
|
nil
|
179
179
|
end
|
180
180
|
|
181
|
-
alias on_rescue
|
182
|
-
alias on_resbody
|
183
|
-
alias on_ensure
|
184
|
-
alias on_for
|
185
|
-
alias on_when
|
186
|
-
alias
|
187
|
-
alias
|
181
|
+
alias on_rescue on_case
|
182
|
+
alias on_resbody on_case
|
183
|
+
alias on_ensure on_case
|
184
|
+
alias on_for on_case
|
185
|
+
alias on_when on_case
|
186
|
+
alias on_case_match on_case
|
187
|
+
alias on_in_pattern on_case
|
188
|
+
alias on_irange on_case
|
189
|
+
alias on_erange on_case
|
190
|
+
|
191
|
+
def on_numblock(node)
|
192
|
+
children = node.children
|
193
|
+
child = children[0]
|
194
|
+
send(:"on_#{child.type}", child)
|
195
|
+
return unless (child = children[2])
|
196
|
+
|
197
|
+
send(:"on_#{child.type}", child)
|
198
|
+
end
|
188
199
|
end
|
189
200
|
end
|
190
201
|
end
|
data/lib/rubocop/cli.rb
CHANGED
@@ -35,8 +35,8 @@ module RuboCop
|
|
35
35
|
if @options[:init]
|
36
36
|
run_command(:init)
|
37
37
|
else
|
38
|
-
validate_options_vs_config
|
39
38
|
act_on_options
|
39
|
+
validate_options_vs_config
|
40
40
|
apply_default_formatter
|
41
41
|
execute_runners
|
42
42
|
end
|
@@ -83,10 +83,7 @@ module RuboCop
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def act_on_options
|
86
|
-
|
87
|
-
ConfigLoader.auto_gen_config = @options[:auto_gen_config]
|
88
|
-
ConfigLoader.ignore_parent_exclusion = @options[:ignore_parent_exclusion]
|
89
|
-
ConfigLoader.options_config = @options[:config]
|
86
|
+
set_options_to_config_loader
|
90
87
|
|
91
88
|
@config_store.options_config = @options[:config] if @options[:config]
|
92
89
|
@config_store.force_default_config! if @options[:force_default_config]
|
@@ -102,6 +99,15 @@ module RuboCop
|
|
102
99
|
end
|
103
100
|
end
|
104
101
|
|
102
|
+
def set_options_to_config_loader
|
103
|
+
ConfigLoader.debug = @options[:debug]
|
104
|
+
ConfigLoader.auto_gen_config = @options[:auto_gen_config]
|
105
|
+
ConfigLoader.disable_pending_cops = @options[:disable_pending_cops]
|
106
|
+
ConfigLoader.enable_pending_cops = @options[:enable_pending_cops]
|
107
|
+
ConfigLoader.ignore_parent_exclusion = @options[:ignore_parent_exclusion]
|
108
|
+
ConfigLoader.options_config = @options[:config]
|
109
|
+
end
|
110
|
+
|
105
111
|
def handle_exiting_options
|
106
112
|
return unless Options::EXITING_OPTIONS.any? { |o| @options.key? o }
|
107
113
|
|