rubocop 0.49.1 → 0.50.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/bin/rubocop +1 -1
- data/config/default.yml +160 -99
- data/config/disabled.yml +4 -5
- data/config/enabled.yml +149 -47
- data/lib/rubocop.rb +41 -14
- data/lib/rubocop/ast/builder.rb +4 -1
- data/lib/rubocop/ast/node.rb +36 -42
- data/lib/rubocop/ast/node/args_node.rb +1 -13
- data/lib/rubocop/ast/node/array_node.rb +9 -0
- data/lib/rubocop/ast/node/block_node.rb +9 -0
- data/lib/rubocop/ast/node/def_node.rb +71 -0
- data/lib/rubocop/ast/node/for_node.rb +8 -0
- data/lib/rubocop/ast/node/if_node.rb +10 -2
- data/lib/rubocop/ast/node/mixin/collection_node.rb +15 -0
- data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +174 -0
- data/lib/rubocop/ast/node/mixin/method_identifier_predicates.rb +89 -0
- data/lib/rubocop/ast/node/mixin/parameterized_node.rb +18 -31
- data/lib/rubocop/ast/node/regexp_node.rb +35 -0
- data/lib/rubocop/ast/node/send_node.rb +1 -154
- data/lib/rubocop/ast/node/super_node.rb +3 -24
- data/lib/rubocop/ast/node/yield_node.rb +21 -0
- data/lib/rubocop/ast/traversal.rb +6 -6
- data/lib/rubocop/cli.rb +7 -3
- data/lib/rubocop/config.rb +45 -8
- data/lib/rubocop/config_loader.rb +7 -5
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +3 -3
- data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +64 -0
- data/lib/rubocop/cop/bundler/ordered_gems.rb +12 -12
- data/lib/rubocop/cop/commissioner.rb +8 -2
- data/lib/rubocop/cop/cop.rb +3 -1
- data/lib/rubocop/cop/generator.rb +94 -21
- data/lib/rubocop/cop/internal_affairs.rb +3 -0
- data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +14 -3
- data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +43 -0
- data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +46 -0
- data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +49 -0
- data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +1 -1
- data/lib/rubocop/cop/layout/access_modifier_indentation.rb +2 -3
- data/lib/rubocop/cop/layout/align_array.rb +2 -2
- data/lib/rubocop/cop/layout/align_hash.rb +2 -2
- data/lib/rubocop/cop/layout/align_parameters.rb +5 -11
- data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +5 -5
- data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/dot_position.rb +9 -0
- data/lib/rubocop/cop/layout/else_alignment.rb +30 -13
- data/lib/rubocop/cop/layout/empty_line_between_defs.rb +4 -0
- data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +20 -4
- data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +3 -3
- data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +3 -3
- data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +3 -3
- data/lib/rubocop/cop/layout/first_parameter_indentation.rb +5 -2
- data/lib/rubocop/cop/layout/indent_heredoc.rb +19 -24
- data/lib/rubocop/cop/layout/indentation_consistency.rb +1 -2
- data/lib/rubocop/cop/layout/indentation_width.rb +12 -8
- data/lib/rubocop/cop/layout/leading_comment_space.rb +33 -18
- data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +20 -17
- data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +3 -3
- data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +6 -0
- data/lib/rubocop/cop/layout/space_after_colon.rb +7 -0
- data/lib/rubocop/cop/layout/space_after_comma.rb +10 -0
- data/lib/rubocop/cop/layout/space_after_method_name.rb +5 -3
- data/lib/rubocop/cop/layout/space_after_not.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +13 -4
- data/lib/rubocop/cop/layout/space_around_keyword.rb +9 -5
- data/lib/rubocop/cop/layout/space_before_block_braces.rb +54 -5
- data/lib/rubocop/cop/layout/space_before_comment.rb +7 -0
- data/lib/rubocop/cop/layout/space_before_semicolon.rb +7 -0
- data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_range_literal.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +8 -4
- data/lib/rubocop/cop/layout/tab.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_block_association.rb +4 -2
- data/lib/rubocop/cop/lint/assignment_in_condition.rb +15 -1
- data/lib/rubocop/cop/lint/block_alignment.rb +15 -6
- data/lib/rubocop/cop/lint/boolean_symbol.rb +38 -0
- data/lib/rubocop/cop/lint/condition_position.rb +5 -1
- data/lib/rubocop/cop/lint/debugger.rb +16 -9
- data/lib/rubocop/cop/lint/def_end_alignment.rb +4 -4
- data/lib/rubocop/cop/lint/duplicate_case_condition.rb +3 -3
- data/lib/rubocop/cop/lint/duplicate_methods.rb +73 -5
- data/lib/rubocop/cop/lint/duplicated_key.rb +1 -1
- data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -1
- data/lib/rubocop/cop/lint/else_layout.rb +1 -1
- data/lib/rubocop/cop/lint/empty_expression.rb +1 -1
- data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/empty_when.rb +1 -1
- data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
- data/lib/rubocop/cop/lint/float_out_of_range.rb +5 -5
- data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +35 -40
- data/lib/rubocop/cop/lint/handle_exceptions.rb +1 -1
- data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +18 -13
- data/lib/rubocop/cop/lint/inherit_exception.rb +8 -7
- data/lib/rubocop/cop/lint/interpolation_check.rb +36 -0
- data/lib/rubocop/cop/lint/literal_in_condition.rb +3 -3
- data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
- data/lib/rubocop/cop/lint/multiple_compare.rb +1 -1
- data/lib/rubocop/cop/lint/nested_method_definition.rb +5 -7
- data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
- data/lib/rubocop/cop/lint/percent_string_array.rb +3 -12
- data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
- data/lib/rubocop/cop/lint/rand_one.rb +7 -1
- data/lib/rubocop/cop/lint/redundant_with_index.rb +77 -0
- data/lib/rubocop/cop/lint/require_parentheses.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
- data/lib/rubocop/cop/lint/rescue_type.rb +13 -6
- data/lib/rubocop/cop/lint/rescue_without_error_class.rb +38 -0
- data/lib/rubocop/cop/lint/return_in_void_context.rb +63 -0
- data/lib/rubocop/cop/lint/script_permission.rb +6 -0
- data/lib/rubocop/cop/lint/syntax.rb +17 -20
- data/lib/rubocop/cop/lint/unified_integer.rb +3 -2
- data/lib/rubocop/cop/lint/unneeded_disable.rb +1 -1
- data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +1 -1
- data/lib/rubocop/cop/lint/unreachable_code.rb +53 -8
- data/lib/rubocop/cop/lint/uri_escape_unescape.rb +74 -0
- data/lib/rubocop/cop/lint/uri_regexp.rb +73 -0
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +4 -8
- data/lib/rubocop/cop/lint/useless_setter_call.rb +10 -11
- data/lib/rubocop/cop/lint/void.rb +29 -23
- data/lib/rubocop/cop/metrics/line_length.rb +2 -2
- data/lib/rubocop/cop/metrics/method_length.rb +8 -3
- data/lib/rubocop/cop/metrics/parameter_lists.rb +5 -2
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/enforce_superclass.rb +2 -2
- data/lib/rubocop/cop/mixin/first_element_line_break.rb +12 -3
- data/lib/rubocop/cop/mixin/heredoc.rb +28 -0
- data/lib/rubocop/cop/mixin/method_complexity.rb +9 -6
- data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +68 -31
- data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +18 -0
- data/lib/rubocop/cop/mixin/negative_conditional.rb +1 -1
- data/lib/rubocop/cop/mixin/percent_array.rb +52 -0
- data/lib/rubocop/cop/mixin/string_help.rb +1 -1
- data/lib/rubocop/cop/{style → naming}/accessor_method_name.rb +11 -12
- data/lib/rubocop/cop/{style → naming}/ascii_identifiers.rb +1 -1
- data/lib/rubocop/cop/{style/op_method.rb → naming/binary_operator_parameter_name.rb} +2 -2
- data/lib/rubocop/cop/{style → naming}/class_and_module_camel_case.rb +1 -1
- data/lib/rubocop/cop/{style → naming}/constant_name.rb +1 -1
- data/lib/rubocop/cop/{style → naming}/file_name.rb +8 -4
- data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +68 -0
- data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +58 -0
- data/lib/rubocop/cop/{style → naming}/method_name.rb +1 -1
- data/lib/rubocop/cop/{style → naming}/predicate_name.rb +6 -7
- data/lib/rubocop/cop/{style → naming}/variable_name.rb +11 -15
- data/lib/rubocop/cop/{style → naming}/variable_number.rb +1 -1
- data/lib/rubocop/cop/performance/caller.rb +39 -11
- data/lib/rubocop/cop/performance/casecmp.rb +4 -4
- data/lib/rubocop/cop/performance/compare_with_block.rb +4 -4
- data/lib/rubocop/cop/performance/double_start_end_with.rb +4 -4
- data/lib/rubocop/cop/performance/end_with.rb +3 -3
- data/lib/rubocop/cop/performance/fixed_size.rb +1 -1
- data/lib/rubocop/cop/performance/hash_each_methods.rb +66 -25
- data/lib/rubocop/cop/performance/lstrip_rstrip.rb +2 -2
- data/lib/rubocop/cop/performance/range_include.rb +2 -2
- data/lib/rubocop/cop/performance/redundant_block_call.rb +6 -6
- data/lib/rubocop/cop/performance/redundant_match.rb +5 -5
- data/lib/rubocop/cop/performance/redundant_merge.rb +39 -23
- data/lib/rubocop/cop/performance/redundant_sort_by.rb +2 -2
- data/lib/rubocop/cop/performance/regexp_match.rb +13 -5
- data/lib/rubocop/cop/performance/size.rb +1 -1
- data/lib/rubocop/cop/performance/start_with.rb +3 -3
- data/lib/rubocop/cop/performance/times_map.rb +23 -12
- data/lib/rubocop/cop/performance/unfreeze_string.rb +50 -0
- data/lib/rubocop/cop/performance/uri_default_parser.rb +47 -0
- data/lib/rubocop/cop/rails/active_support_aliases.rb +1 -1
- data/lib/rubocop/cop/rails/delegate.rb +36 -7
- data/lib/rubocop/cop/rails/delegate_allow_blank.rb +1 -1
- data/lib/rubocop/cop/rails/enum_uniqueness.rb +2 -2
- data/lib/rubocop/cop/rails/file_path.rb +3 -4
- data/lib/rubocop/cop/rails/find_each.rb +1 -1
- data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +48 -0
- data/lib/rubocop/cop/rails/http_positional_arguments.rb +5 -5
- data/lib/rubocop/cop/rails/not_null_column.rb +1 -1
- data/lib/rubocop/cop/rails/pluralization_grammar.rb +2 -2
- data/lib/rubocop/cop/rails/relative_date_constant.rb +1 -1
- data/lib/rubocop/cop/rails/request_referer.rb +2 -2
- data/lib/rubocop/cop/rails/reversible_migration.rb +12 -12
- data/lib/rubocop/cop/rails/save_bang.rb +8 -6
- data/lib/rubocop/cop/rails/scope_args.rb +1 -1
- data/lib/rubocop/cop/security/eval.rb +2 -2
- data/lib/rubocop/cop/security/json_load.rb +2 -2
- data/lib/rubocop/cop/security/marshal_load.rb +2 -2
- data/lib/rubocop/cop/security/yaml_load.rb +2 -2
- data/lib/rubocop/cop/style/alias.rb +44 -20
- data/lib/rubocop/cop/style/and_or.rb +48 -34
- data/lib/rubocop/cop/style/auto_resource_cleanup.rb +1 -1
- data/lib/rubocop/cop/style/block_comments.rb +3 -1
- data/lib/rubocop/cop/style/block_delimiters.rb +2 -1
- data/lib/rubocop/cop/style/command_literal.rb +20 -9
- data/lib/rubocop/cop/style/conditional_assignment.rb +30 -28
- data/lib/rubocop/cop/style/copyright.rb +10 -10
- data/lib/rubocop/cop/style/def_with_parentheses.rb +6 -5
- data/lib/rubocop/cop/style/dir.rb +52 -0
- data/lib/rubocop/cop/style/documentation_method.rb +2 -6
- data/lib/rubocop/cop/style/empty_case_condition.rb +1 -1
- data/lib/rubocop/cop/style/empty_else.rb +3 -2
- data/lib/rubocop/cop/style/empty_literal.rb +1 -2
- data/lib/rubocop/cop/style/empty_method.rb +27 -17
- data/lib/rubocop/cop/style/flip_flop.rb +2 -2
- data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
- data/lib/rubocop/cop/style/guard_clause.rb +4 -2
- data/lib/rubocop/cop/style/hash_syntax.rb +10 -10
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +5 -1
- data/lib/rubocop/cop/style/if_with_semicolon.rb +1 -1
- data/lib/rubocop/cop/style/implicit_runtime_error.rb +4 -3
- data/lib/rubocop/cop/style/inline_comment.rb +1 -1
- data/lib/rubocop/cop/style/inverse_methods.rb +20 -8
- data/lib/rubocop/cop/style/lambda.rb +19 -9
- data/lib/rubocop/cop/style/lambda_call.rb +22 -1
- data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +4 -20
- data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +6 -4
- data/lib/rubocop/cop/style/method_def_parentheses.rb +18 -26
- data/lib/rubocop/cop/style/method_missing.rb +5 -18
- data/lib/rubocop/cop/style/min_max.rb +67 -0
- data/lib/rubocop/cop/style/missing_else.rb +16 -3
- data/lib/rubocop/cop/style/mixin_grouping.rb +2 -2
- data/lib/rubocop/cop/style/module_function.rb +8 -4
- data/lib/rubocop/cop/style/multiline_if_modifier.rb +5 -1
- data/lib/rubocop/cop/style/multiline_memoization.rb +25 -3
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/multiple_comparison.rb +1 -1
- data/lib/rubocop/cop/style/mutable_constant.rb +2 -6
- data/lib/rubocop/cop/style/negated_if.rb +8 -4
- data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +8 -8
- data/lib/rubocop/cop/style/nested_ternary_operator.rb +1 -1
- data/lib/rubocop/cop/style/non_nil_check.rb +14 -14
- data/lib/rubocop/cop/style/numeric_literal_prefix.rb +6 -2
- data/lib/rubocop/cop/style/numeric_literals.rb +2 -2
- data/lib/rubocop/cop/style/numeric_predicate.rb +8 -4
- data/lib/rubocop/cop/style/one_line_conditional.rb +8 -3
- data/lib/rubocop/cop/style/option_hash.rb +1 -1
- data/lib/rubocop/cop/style/optional_arguments.rb +1 -2
- data/lib/rubocop/cop/style/or_assignment.rb +88 -0
- data/lib/rubocop/cop/style/parallel_assignment.rb +2 -2
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +12 -11
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
- data/lib/rubocop/cop/style/percent_q_literals.rb +2 -2
- data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
- data/lib/rubocop/cop/style/proc.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +16 -17
- data/lib/rubocop/cop/style/redundant_begin.rb +6 -5
- data/lib/rubocop/cop/style/redundant_conditional.rb +95 -0
- data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
- data/lib/rubocop/cop/style/redundant_parentheses.rb +13 -11
- data/lib/rubocop/cop/style/redundant_return.rb +23 -11
- data/lib/rubocop/cop/style/redundant_self.rb +18 -9
- data/lib/rubocop/cop/style/regexp_literal.rb +12 -4
- data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
- data/lib/rubocop/cop/style/return_nil.rb +98 -0
- data/lib/rubocop/cop/style/safe_navigation.rb +80 -43
- data/lib/rubocop/cop/style/single_line_block_params.rb +14 -13
- data/lib/rubocop/cop/style/single_line_methods.rb +9 -13
- data/lib/rubocop/cop/style/special_global_vars.rb +3 -3
- data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +17 -39
- data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +22 -1
- data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
- data/lib/rubocop/cop/style/symbol_array.rb +5 -25
- data/lib/rubocop/cop/style/symbol_literal.rb +1 -1
- data/lib/rubocop/cop/style/symbol_proc.rb +3 -18
- data/lib/rubocop/cop/style/ternary_parentheses.rb +14 -10
- data/lib/rubocop/cop/style/trailing_underscore_variable.rb +28 -9
- data/lib/rubocop/cop/style/trivial_accessors.rb +39 -56
- data/lib/rubocop/cop/style/unless_else.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_capital_w.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_interpolation.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_percent_q.rb +1 -1
- data/lib/rubocop/cop/style/variable_interpolation.rb +8 -3
- data/lib/rubocop/cop/style/word_array.rb +7 -24
- data/lib/rubocop/cop/style/yoda_condition.rb +49 -14
- data/lib/rubocop/cop/style/zero_length_predicate.rb +25 -18
- data/lib/rubocop/cop/team.rb +16 -8
- data/lib/rubocop/cop/util.rb +11 -0
- data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +2 -1
- data/lib/rubocop/formatter/offense_count_formatter.rb +2 -0
- data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
- data/lib/rubocop/formatter/tap_formatter.rb +71 -0
- data/lib/rubocop/formatter/worst_offenders_formatter.rb +2 -0
- data/lib/rubocop/node_pattern.rb +44 -26
- data/lib/rubocop/options.rb +1 -0
- data/lib/rubocop/processed_source.rb +3 -1
- data/lib/rubocop/remote_config.rb +5 -1
- data/lib/rubocop/result_cache.rb +1 -0
- data/lib/rubocop/rspec/cop_helper.rb +10 -10
- data/lib/rubocop/rspec/expect_offense.rb +6 -8
- data/lib/rubocop/rspec/shared_examples.rb +8 -8
- data/lib/rubocop/string_util.rb +2 -0
- data/lib/rubocop/version.rb +1 -1
- metadata +51 -18
- data/lib/rubocop/cop/mixin/access_modifier_node.rb +0 -41
- data/lib/rubocop/cop/mixin/on_method_def.rb +0 -44
data/lib/rubocop.rb
CHANGED
@@ -5,6 +5,7 @@ require 'rainbow'
|
|
5
5
|
|
6
6
|
require 'English'
|
7
7
|
require 'set'
|
8
|
+
require 'forwardable'
|
8
9
|
require 'powerpack/array/butfirst'
|
9
10
|
require 'powerpack/enumerable/drop_last'
|
10
11
|
require 'powerpack/hash/symbolize_keys'
|
@@ -22,9 +23,12 @@ require 'rubocop/node_pattern'
|
|
22
23
|
require 'rubocop/string_interpreter'
|
23
24
|
require 'rubocop/ast/sexp'
|
24
25
|
require 'rubocop/ast/node'
|
26
|
+
require 'rubocop/ast/node/mixin/method_identifier_predicates'
|
25
27
|
require 'rubocop/ast/node/mixin/binary_operator_node'
|
28
|
+
require 'rubocop/ast/node/mixin/collection_node'
|
26
29
|
require 'rubocop/ast/node/mixin/conditional_node'
|
27
30
|
require 'rubocop/ast/node/mixin/hash_element_node'
|
31
|
+
require 'rubocop/ast/node/mixin/method_dispatch_node'
|
28
32
|
require 'rubocop/ast/node/mixin/modifier_node'
|
29
33
|
require 'rubocop/ast/node/mixin/parameterized_node'
|
30
34
|
require 'rubocop/ast/node/mixin/predicate_operator_node'
|
@@ -33,6 +37,7 @@ require 'rubocop/ast/node/args_node'
|
|
33
37
|
require 'rubocop/ast/node/array_node'
|
34
38
|
require 'rubocop/ast/node/block_node'
|
35
39
|
require 'rubocop/ast/node/case_node'
|
40
|
+
require 'rubocop/ast/node/def_node'
|
36
41
|
require 'rubocop/ast/node/ensure_node'
|
37
42
|
require 'rubocop/ast/node/for_node'
|
38
43
|
require 'rubocop/ast/node/hash_node'
|
@@ -40,12 +45,14 @@ require 'rubocop/ast/node/if_node'
|
|
40
45
|
require 'rubocop/ast/node/keyword_splat_node'
|
41
46
|
require 'rubocop/ast/node/or_node'
|
42
47
|
require 'rubocop/ast/node/pair_node'
|
48
|
+
require 'rubocop/ast/node/regexp_node'
|
43
49
|
require 'rubocop/ast/node/resbody_node'
|
44
50
|
require 'rubocop/ast/node/send_node'
|
45
51
|
require 'rubocop/ast/node/super_node'
|
46
52
|
require 'rubocop/ast/node/until_node'
|
47
53
|
require 'rubocop/ast/node/when_node'
|
48
54
|
require 'rubocop/ast/node/while_node'
|
55
|
+
require 'rubocop/ast/node/yield_node'
|
49
56
|
require 'rubocop/ast/builder'
|
50
57
|
require 'rubocop/ast/traversal'
|
51
58
|
require 'rubocop/error'
|
@@ -74,7 +81,6 @@ require 'rubocop/cop/variable_force/reference'
|
|
74
81
|
require 'rubocop/cop/variable_force/scope'
|
75
82
|
require 'rubocop/cop/variable_force/variable_table'
|
76
83
|
|
77
|
-
require 'rubocop/cop/mixin/access_modifier_node'
|
78
84
|
require 'rubocop/cop/mixin/annotation_comment'
|
79
85
|
require 'rubocop/cop/mixin/array_hash_indentation'
|
80
86
|
require 'rubocop/cop/mixin/array_min_size'
|
@@ -99,17 +105,18 @@ require 'rubocop/cop/mixin/frozen_string_literal'
|
|
99
105
|
require 'rubocop/cop/mixin/hash_alignment'
|
100
106
|
require 'rubocop/cop/mixin/ignored_pattern'
|
101
107
|
require 'rubocop/cop/mixin/integer_node'
|
102
|
-
require 'rubocop/cop/mixin/on_method_def'
|
103
108
|
require 'rubocop/cop/mixin/match_range'
|
104
|
-
require 'rubocop/cop/mixin/method_complexity'
|
109
|
+
require 'rubocop/cop/mixin/method_complexity'
|
105
110
|
require 'rubocop/cop/mixin/method_preference'
|
106
111
|
require 'rubocop/cop/mixin/min_body_length'
|
107
112
|
require 'rubocop/cop/mixin/multiline_expression_indentation'
|
108
113
|
require 'rubocop/cop/mixin/multiline_literal_brace_layout'
|
109
114
|
require 'rubocop/cop/mixin/negative_conditional'
|
115
|
+
require 'rubocop/cop/mixin/heredoc'
|
110
116
|
require 'rubocop/cop/mixin/on_normal_if_unless'
|
111
117
|
require 'rubocop/cop/mixin/parentheses'
|
112
118
|
require 'rubocop/cop/mixin/parser_diagnostic'
|
119
|
+
require 'rubocop/cop/mixin/percent_array'
|
113
120
|
require 'rubocop/cop/mixin/percent_literal'
|
114
121
|
require 'rubocop/cop/mixin/preceding_following_alignment'
|
115
122
|
require 'rubocop/cop/mixin/rescue_node'
|
@@ -129,6 +136,7 @@ require 'rubocop/cop/mixin/trailing_comma'
|
|
129
136
|
require 'rubocop/cop/mixin/unused_argument'
|
130
137
|
|
131
138
|
require 'rubocop/cop/bundler/duplicated_gem'
|
139
|
+
require 'rubocop/cop/bundler/insecure_protocol_source'
|
132
140
|
require 'rubocop/cop/bundler/ordered_gems'
|
133
141
|
|
134
142
|
require 'rubocop/cop/layout/access_modifier_indentation'
|
@@ -207,6 +215,7 @@ require 'rubocop/cop/lint/ambiguous_operator'
|
|
207
215
|
require 'rubocop/cop/lint/ambiguous_regexp_literal'
|
208
216
|
require 'rubocop/cop/lint/assignment_in_condition'
|
209
217
|
require 'rubocop/cop/lint/block_alignment'
|
218
|
+
require 'rubocop/cop/lint/boolean_symbol'
|
210
219
|
require 'rubocop/cop/lint/circular_argument_reference'
|
211
220
|
require 'rubocop/cop/lint/condition_position'
|
212
221
|
require 'rubocop/cop/lint/debugger'
|
@@ -230,6 +239,7 @@ require 'rubocop/cop/lint/handle_exceptions'
|
|
230
239
|
require 'rubocop/cop/lint/implicit_string_concatenation'
|
231
240
|
require 'rubocop/cop/lint/inherit_exception'
|
232
241
|
require 'rubocop/cop/lint/ineffective_access_modifier'
|
242
|
+
require 'rubocop/cop/lint/interpolation_check'
|
233
243
|
require 'rubocop/cop/lint/invalid_character_literal'
|
234
244
|
require 'rubocop/cop/lint/literal_in_condition'
|
235
245
|
require 'rubocop/cop/lint/literal_in_interpolation'
|
@@ -242,9 +252,12 @@ require 'rubocop/cop/lint/parentheses_as_grouped_expression'
|
|
242
252
|
require 'rubocop/cop/lint/percent_string_array'
|
243
253
|
require 'rubocop/cop/lint/percent_symbol_array'
|
244
254
|
require 'rubocop/cop/lint/rand_one'
|
255
|
+
require 'rubocop/cop/lint/redundant_with_index'
|
245
256
|
require 'rubocop/cop/lint/require_parentheses'
|
246
257
|
require 'rubocop/cop/lint/rescue_exception'
|
247
258
|
require 'rubocop/cop/lint/rescue_type'
|
259
|
+
require 'rubocop/cop/lint/rescue_without_error_class'
|
260
|
+
require 'rubocop/cop/lint/return_in_void_context'
|
248
261
|
require 'rubocop/cop/lint/safe_navigation_chain'
|
249
262
|
require 'rubocop/cop/lint/script_permission'
|
250
263
|
require 'rubocop/cop/lint/shadowed_exception'
|
@@ -258,6 +271,8 @@ require 'rubocop/cop/lint/unneeded_splat_expansion'
|
|
258
271
|
require 'rubocop/cop/lint/unreachable_code'
|
259
272
|
require 'rubocop/cop/lint/unused_block_argument'
|
260
273
|
require 'rubocop/cop/lint/unused_method_argument'
|
274
|
+
require 'rubocop/cop/lint/uri_escape_unescape'
|
275
|
+
require 'rubocop/cop/lint/uri_regexp'
|
261
276
|
require 'rubocop/cop/lint/useless_access_modifier'
|
262
277
|
require 'rubocop/cop/lint/useless_assignment'
|
263
278
|
require 'rubocop/cop/lint/useless_comparison'
|
@@ -276,6 +291,19 @@ require 'rubocop/cop/metrics/module_length'
|
|
276
291
|
require 'rubocop/cop/metrics/parameter_lists'
|
277
292
|
require 'rubocop/cop/metrics/perceived_complexity'
|
278
293
|
|
294
|
+
require 'rubocop/cop/naming/accessor_method_name'
|
295
|
+
require 'rubocop/cop/naming/ascii_identifiers'
|
296
|
+
require 'rubocop/cop/naming/class_and_module_camel_case'
|
297
|
+
require 'rubocop/cop/naming/constant_name'
|
298
|
+
require 'rubocop/cop/naming/file_name'
|
299
|
+
require 'rubocop/cop/naming/heredoc_delimiter_case'
|
300
|
+
require 'rubocop/cop/naming/heredoc_delimiter_naming'
|
301
|
+
require 'rubocop/cop/naming/method_name'
|
302
|
+
require 'rubocop/cop/naming/binary_operator_parameter_name'
|
303
|
+
require 'rubocop/cop/naming/predicate_name'
|
304
|
+
require 'rubocop/cop/naming/variable_name'
|
305
|
+
require 'rubocop/cop/naming/variable_number'
|
306
|
+
|
279
307
|
require 'rubocop/cop/performance/caller'
|
280
308
|
require 'rubocop/cop/performance/case_when_splat'
|
281
309
|
require 'rubocop/cop/performance/casecmp'
|
@@ -300,13 +328,13 @@ require 'rubocop/cop/performance/compare_with_block'
|
|
300
328
|
require 'rubocop/cop/performance/start_with'
|
301
329
|
require 'rubocop/cop/performance/string_replacement'
|
302
330
|
require 'rubocop/cop/performance/times_map'
|
331
|
+
require 'rubocop/cop/performance/unfreeze_string'
|
332
|
+
require 'rubocop/cop/performance/uri_default_parser'
|
303
333
|
|
304
|
-
require 'rubocop/cop/style/accessor_method_name'
|
305
334
|
require 'rubocop/cop/style/alias'
|
306
335
|
require 'rubocop/cop/style/and_or'
|
307
336
|
require 'rubocop/cop/style/array_join'
|
308
337
|
require 'rubocop/cop/style/ascii_comments'
|
309
|
-
require 'rubocop/cop/style/ascii_identifiers'
|
310
338
|
require 'rubocop/cop/style/attr'
|
311
339
|
require 'rubocop/cop/style/auto_resource_cleanup'
|
312
340
|
require 'rubocop/cop/style/bare_percent_literals'
|
@@ -316,7 +344,6 @@ require 'rubocop/cop/style/block_delimiters'
|
|
316
344
|
require 'rubocop/cop/style/braces_around_hash_parameters'
|
317
345
|
require 'rubocop/cop/style/case_equality'
|
318
346
|
require 'rubocop/cop/style/character_literal'
|
319
|
-
require 'rubocop/cop/style/class_and_module_camel_case'
|
320
347
|
require 'rubocop/cop/style/class_and_module_children'
|
321
348
|
require 'rubocop/cop/style/class_check'
|
322
349
|
require 'rubocop/cop/style/class_methods'
|
@@ -326,10 +353,9 @@ require 'rubocop/cop/style/colon_method_call'
|
|
326
353
|
require 'rubocop/cop/style/command_literal'
|
327
354
|
require 'rubocop/cop/style/comment_annotation'
|
328
355
|
require 'rubocop/cop/style/conditional_assignment'
|
329
|
-
require 'rubocop/cop/style/constant_name'
|
330
356
|
require 'rubocop/cop/style/copyright'
|
331
357
|
require 'rubocop/cop/style/def_with_parentheses'
|
332
|
-
require 'rubocop/cop/style/
|
358
|
+
require 'rubocop/cop/style/dir'
|
333
359
|
require 'rubocop/cop/style/documentation_method'
|
334
360
|
require 'rubocop/cop/style/documentation'
|
335
361
|
require 'rubocop/cop/style/double_negation'
|
@@ -342,7 +368,6 @@ require 'rubocop/cop/style/empty_method'
|
|
342
368
|
require 'rubocop/cop/style/encoding'
|
343
369
|
require 'rubocop/cop/style/end_block'
|
344
370
|
require 'rubocop/cop/style/even_odd'
|
345
|
-
require 'rubocop/cop/style/file_name'
|
346
371
|
require 'rubocop/cop/style/flip_flop'
|
347
372
|
require 'rubocop/cop/style/for'
|
348
373
|
require 'rubocop/cop/style/format_string'
|
@@ -367,8 +392,8 @@ require 'rubocop/cop/style/method_call_without_args_parentheses'
|
|
367
392
|
require 'rubocop/cop/style/method_call_with_args_parentheses'
|
368
393
|
require 'rubocop/cop/style/method_called_on_do_end_block'
|
369
394
|
require 'rubocop/cop/style/method_def_parentheses'
|
370
|
-
require 'rubocop/cop/style/method_name'
|
371
395
|
require 'rubocop/cop/style/method_missing'
|
396
|
+
require 'rubocop/cop/style/min_max'
|
372
397
|
require 'rubocop/cop/style/missing_else'
|
373
398
|
require 'rubocop/cop/style/mixin_grouping'
|
374
399
|
require 'rubocop/cop/style/module_function'
|
@@ -392,7 +417,7 @@ require 'rubocop/cop/style/numeric_literals'
|
|
392
417
|
require 'rubocop/cop/style/numeric_literal_prefix'
|
393
418
|
require 'rubocop/cop/style/numeric_predicate'
|
394
419
|
require 'rubocop/cop/style/one_line_conditional'
|
395
|
-
require 'rubocop/cop/style/
|
420
|
+
require 'rubocop/cop/style/or_assignment'
|
396
421
|
require 'rubocop/cop/style/option_hash'
|
397
422
|
require 'rubocop/cop/style/optional_arguments'
|
398
423
|
require 'rubocop/cop/style/parallel_assignment'
|
@@ -400,7 +425,7 @@ require 'rubocop/cop/style/parentheses_around_condition'
|
|
400
425
|
require 'rubocop/cop/style/percent_literal_delimiters'
|
401
426
|
require 'rubocop/cop/style/percent_q_literals'
|
402
427
|
require 'rubocop/cop/style/perl_backrefs'
|
403
|
-
require 'rubocop/cop/style/
|
428
|
+
require 'rubocop/cop/style/preferred_hash_methods'
|
404
429
|
require 'rubocop/cop/style/proc'
|
405
430
|
require 'rubocop/cop/style/raise_args'
|
406
431
|
require 'rubocop/cop/style/redundant_begin'
|
@@ -409,8 +434,10 @@ require 'rubocop/cop/style/redundant_freeze'
|
|
409
434
|
require 'rubocop/cop/style/redundant_parentheses'
|
410
435
|
require 'rubocop/cop/style/redundant_return'
|
411
436
|
require 'rubocop/cop/style/redundant_self'
|
437
|
+
require 'rubocop/cop/style/redundant_conditional'
|
412
438
|
require 'rubocop/cop/style/regexp_literal'
|
413
439
|
require 'rubocop/cop/style/rescue_modifier'
|
440
|
+
require 'rubocop/cop/style/return_nil'
|
414
441
|
require 'rubocop/cop/style/safe_navigation'
|
415
442
|
require 'rubocop/cop/style/self_assignment'
|
416
443
|
require 'rubocop/cop/style/semicolon'
|
@@ -437,8 +464,6 @@ require 'rubocop/cop/style/unneeded_capital_w'
|
|
437
464
|
require 'rubocop/cop/style/unneeded_interpolation'
|
438
465
|
require 'rubocop/cop/style/unneeded_percent_q'
|
439
466
|
require 'rubocop/cop/style/variable_interpolation'
|
440
|
-
require 'rubocop/cop/style/variable_name'
|
441
|
-
require 'rubocop/cop/style/variable_number'
|
442
467
|
require 'rubocop/cop/style/when_then'
|
443
468
|
require 'rubocop/cop/style/while_until_do'
|
444
469
|
require 'rubocop/cop/style/while_until_modifier'
|
@@ -461,6 +486,7 @@ require 'rubocop/cop/rails/file_path'
|
|
461
486
|
require 'rubocop/cop/rails/find_by'
|
462
487
|
require 'rubocop/cop/rails/find_each'
|
463
488
|
require 'rubocop/cop/rails/has_and_belongs_to_many'
|
489
|
+
require 'rubocop/cop/rails/has_many_or_has_one_dependent'
|
464
490
|
require 'rubocop/cop/rails/http_positional_arguments'
|
465
491
|
require 'rubocop/cop/rails/not_null_column'
|
466
492
|
require 'rubocop/cop/rails/output_safety'
|
@@ -498,6 +524,7 @@ require 'rubocop/formatter/html_formatter'
|
|
498
524
|
require 'rubocop/formatter/json_formatter'
|
499
525
|
require 'rubocop/formatter/offense_count_formatter'
|
500
526
|
require 'rubocop/formatter/progress_formatter'
|
527
|
+
require 'rubocop/formatter/tap_formatter'
|
501
528
|
require 'rubocop/formatter/worst_offenders_formatter'
|
502
529
|
|
503
530
|
require 'rubocop/formatter/formatter_set'
|
data/lib/rubocop/ast/builder.rb
CHANGED
@@ -19,6 +19,7 @@ module RuboCop
|
|
19
19
|
ArrayNode => [:array],
|
20
20
|
BlockNode => [:block],
|
21
21
|
CaseNode => [:case],
|
22
|
+
DefNode => %i[def defs],
|
22
23
|
EnsureNode => [:ensure],
|
23
24
|
ForNode => [:for],
|
24
25
|
HashNode => [:hash],
|
@@ -26,12 +27,14 @@ module RuboCop
|
|
26
27
|
KeywordSplatNode => [:kwsplat],
|
27
28
|
OrNode => [:or],
|
28
29
|
PairNode => [:pair],
|
30
|
+
RegexpNode => [:regexp],
|
29
31
|
ResbodyNode => [:resbody],
|
30
32
|
SendNode => %i[csend send],
|
31
33
|
SuperNode => %i[super zsuper],
|
32
34
|
UntilNode => %i[until until_post],
|
33
35
|
WhenNode => [:when],
|
34
|
-
WhileNode => %i[while while_post]
|
36
|
+
WhileNode => %i[while while_post],
|
37
|
+
YieldNode => [:yield]
|
35
38
|
}.freeze
|
36
39
|
|
37
40
|
# Generates {Node} from the given information.
|
data/lib/rubocop/ast/node.rb
CHANGED
@@ -20,8 +20,10 @@ module RuboCop
|
|
20
20
|
#
|
21
21
|
class Node < Parser::AST::Node # rubocop:disable Metrics/ClassLength
|
22
22
|
include RuboCop::AST::Sexp
|
23
|
+
extend NodePattern::Macros
|
23
24
|
|
24
|
-
|
25
|
+
# <=> isn't included here, because it doesn't return a boolean.
|
26
|
+
COMPARISON_OPERATORS = %i[== === != <= >= > <].freeze
|
25
27
|
|
26
28
|
TRUTHY_LITERALS = %i[str dstr xstr int float sym dsym array
|
27
29
|
hash regexp true irange erange complex
|
@@ -44,19 +46,6 @@ module RuboCop
|
|
44
46
|
OPERATOR_KEYWORDS = %i[and or].freeze
|
45
47
|
SPECIAL_KEYWORDS = %w[__FILE__ __LINE__ __ENCODING__].freeze
|
46
48
|
|
47
|
-
# def_matcher can be used to define a pattern-matching method on Node
|
48
|
-
class << self
|
49
|
-
def def_matcher(method_name, pattern_str)
|
50
|
-
compiler = RuboCop::NodePattern::Compiler.new(pattern_str, 'self')
|
51
|
-
src = "def #{method_name}(" \
|
52
|
-
"#{compiler.emit_param_list});" \
|
53
|
-
"#{compiler.emit_method_code};end"
|
54
|
-
|
55
|
-
location = caller_locations(1, 1).first
|
56
|
-
class_eval(src, location.path, location.lineno)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
49
|
# @see http://rubydoc.info/gems/ast/AST/Node:initialize
|
61
50
|
def initialize(type, children = [], properties = {})
|
62
51
|
@mutable_attributes = {}
|
@@ -271,12 +260,17 @@ module RuboCop
|
|
271
260
|
|
272
261
|
## Destructuring
|
273
262
|
|
274
|
-
|
275
|
-
|
276
|
-
|
263
|
+
def_node_matcher :receiver, <<-PATTERN
|
264
|
+
{(send $_ ...) (block (send $_ ...) ...)}
|
265
|
+
PATTERN
|
266
|
+
|
267
|
+
def_node_matcher :method_name, <<-PATTERN
|
268
|
+
{(send _ $_ ...) (block (send _ $_ ...) ...)}
|
269
|
+
PATTERN
|
270
|
+
|
277
271
|
# Note: for masgn, #asgn_rhs will be an array node
|
278
|
-
|
279
|
-
|
272
|
+
def_node_matcher :asgn_rhs, '[assignment? (... $_)]'
|
273
|
+
def_node_matcher :str_content, '(str $_)'
|
280
274
|
|
281
275
|
def const_name
|
282
276
|
return unless const_type?
|
@@ -288,7 +282,7 @@ module RuboCop
|
|
288
282
|
end
|
289
283
|
end
|
290
284
|
|
291
|
-
|
285
|
+
def_node_matcher :defined_module0, <<-PATTERN
|
292
286
|
{(class (const $_ $_) ...)
|
293
287
|
(module (const $_ $_) ...)
|
294
288
|
(casgn $_ $_ (send (const nil {:Class :Module}) :new ...))
|
@@ -332,10 +326,15 @@ module RuboCop
|
|
332
326
|
method_name.to_s.end_with?('='.freeze)
|
333
327
|
end
|
334
328
|
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
329
|
+
def_node_matcher :equals_asgn?, <<-PATTERN
|
330
|
+
{lvasgn ivasgn cvasgn gvasgn casgn masgn}
|
331
|
+
PATTERN
|
332
|
+
|
333
|
+
def_node_matcher :shorthand_asgn?, '{op_asgn or_asgn and_asgn}'
|
334
|
+
|
335
|
+
def_node_matcher :assignment?, <<-PATTERN
|
336
|
+
{equals_asgn? shorthand_asgn? asgn_method_call?}
|
337
|
+
PATTERN
|
339
338
|
|
340
339
|
def literal?
|
341
340
|
LITERALS.include?(type)
|
@@ -368,7 +367,7 @@ module RuboCop
|
|
368
367
|
case type
|
369
368
|
when :send
|
370
369
|
receiver, method_name, *args = *self
|
371
|
-
COMPARISON_OPERATORS.include?(method_name) &&
|
370
|
+
[*COMPARISON_OPERATORS, :!, :<=>].include?(method_name) &&
|
372
371
|
receiver.send(recursive_kind) &&
|
373
372
|
args.all?(&recursive_kind)
|
374
373
|
when :begin, :pair, *OPERATOR_KEYWORDS, *COMPOSITE_LITERALS
|
@@ -439,24 +438,25 @@ module RuboCop
|
|
439
438
|
int_type? || float_type?
|
440
439
|
end
|
441
440
|
|
442
|
-
|
441
|
+
def_node_matcher :guard_clause?, <<-PATTERN
|
443
442
|
[{(send nil {:raise :fail} ...) return break next} single_line?]
|
444
443
|
PATTERN
|
445
444
|
|
446
|
-
|
447
|
-
def_matcher :proc?, <<-PATTERN
|
445
|
+
def_node_matcher :proc?, <<-PATTERN
|
448
446
|
{(block (send nil :proc) ...)
|
449
447
|
(block (send (const nil :Proc) :new) ...)
|
450
448
|
(send (const nil :Proc) :new)}
|
451
449
|
PATTERN
|
452
|
-
def_matcher :lambda_or_proc?, '{lambda? proc?}'
|
453
450
|
|
454
|
-
|
451
|
+
def_node_matcher :lambda?, '(block (send nil :lambda) ...)'
|
452
|
+
def_node_matcher :lambda_or_proc?, '{lambda? proc?}'
|
453
|
+
|
454
|
+
def_node_matcher :class_constructor?, <<-PATTERN
|
455
455
|
{ (send (const nil {:Class :Module}) :new ...)
|
456
456
|
(block (send (const nil {:Class :Module}) :new ...) ...)}
|
457
457
|
PATTERN
|
458
458
|
|
459
|
-
|
459
|
+
def_node_matcher :module_definition?, <<-PATTERN
|
460
460
|
{class module (casgn _ _ class_constructor?)}
|
461
461
|
PATTERN
|
462
462
|
|
@@ -468,7 +468,7 @@ module RuboCop
|
|
468
468
|
# So, does the return value of this node matter? If we changed it to
|
469
469
|
# `(...; nil)`, might that affect anything?
|
470
470
|
#
|
471
|
-
# rubocop:disable Metrics/MethodLength
|
471
|
+
# rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
|
472
472
|
def value_used?
|
473
473
|
# Be conservative and return true if we're not sure.
|
474
474
|
return false if parent.nil?
|
@@ -490,7 +490,7 @@ module RuboCop
|
|
490
490
|
true
|
491
491
|
end
|
492
492
|
end
|
493
|
-
# rubocop:enable Metrics/MethodLength
|
493
|
+
# rubocop:enable Metrics/MethodLength, Metrics/CyclomaticComplexity
|
494
494
|
|
495
495
|
# Some expressions are evaluated for their value, some for their side
|
496
496
|
# effects, and some for both.
|
@@ -596,15 +596,9 @@ module RuboCop
|
|
596
596
|
end
|
597
597
|
end
|
598
598
|
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
block_node.method_name == :new &&
|
603
|
-
receiver && receiver.const_type? &&
|
604
|
-
(receiver.const_name == 'Class' || receiver.const_name == 'Module') &&
|
605
|
-
block_node.parent &&
|
606
|
-
block_node.parent.casgn_type?
|
607
|
-
end
|
599
|
+
def_node_matcher :new_class_or_module_block?, <<-PATTERN
|
600
|
+
^(casgn _ _ (block (send (const _ {:Class :Module}) :new) ...))
|
601
|
+
PATTERN
|
608
602
|
end
|
609
603
|
end
|
610
604
|
end
|
@@ -6,19 +6,7 @@ module RuboCop
|
|
6
6
|
# node when the builder constructs the AST, making its methods available
|
7
7
|
# to all `args` nodes within RuboCop.
|
8
8
|
class ArgsNode < Node
|
9
|
-
|
10
|
-
#
|
11
|
-
# @return [Boolean] whether this `args` node has any arguments
|
12
|
-
def empty?
|
13
|
-
to_a.empty?
|
14
|
-
end
|
15
|
-
|
16
|
-
# The number of arguments in this `args` node.
|
17
|
-
#
|
18
|
-
# @return [Integer] the number of arguments in this `args` node
|
19
|
-
def size
|
20
|
-
to_a.size
|
21
|
-
end
|
9
|
+
include CollectionNode
|
22
10
|
end
|
23
11
|
end
|
24
12
|
end
|
@@ -43,6 +43,15 @@ module RuboCop
|
|
43
43
|
loc.begin && loc.begin.source.start_with?('%')
|
44
44
|
end
|
45
45
|
end
|
46
|
+
|
47
|
+
# Checks whether the `array` literal is delimited by either percent or
|
48
|
+
# square brackets
|
49
|
+
#
|
50
|
+
# @return [Boolean] whether the array is enclosed in percent or square
|
51
|
+
# brackets
|
52
|
+
def bracketed?
|
53
|
+
square_brackets? || percent_literal?
|
54
|
+
end
|
46
55
|
end
|
47
56
|
end
|
48
57
|
end
|