rubocop 0.72.0 → 0.73.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +13 -0
  4. data/lib/rubocop.rb +2 -0
  5. data/lib/rubocop/ast/node.rb +8 -8
  6. data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +16 -5
  7. data/lib/rubocop/ast/traversal.rb +3 -3
  8. data/lib/rubocop/cop/autocorrect_logic.rb +71 -1
  9. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
  10. data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -1
  11. data/lib/rubocop/cop/commissioner.rb +3 -9
  12. data/lib/rubocop/cop/cop.rb +36 -6
  13. data/lib/rubocop/cop/corrector.rb +2 -3
  14. data/lib/rubocop/cop/correctors/empty_line_corrector.rb +2 -2
  15. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +2 -2
  16. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
  17. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +1 -1
  18. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +1 -1
  19. data/lib/rubocop/cop/generator.rb +1 -1
  20. data/lib/rubocop/cop/internal_affairs/node_destructuring.rb +2 -2
  21. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -1
  22. data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +2 -2
  23. data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -1
  24. data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +2 -2
  25. data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +2 -2
  26. data/lib/rubocop/cop/layout/block_alignment.rb +1 -1
  27. data/lib/rubocop/cop/layout/class_structure.rb +1 -1
  28. data/lib/rubocop/cop/layout/indent_first_argument.rb +1 -1
  29. data/lib/rubocop/cop/layout/indent_heredoc.rb +3 -2
  30. data/lib/rubocop/cop/layout/indentation_width.rb +1 -1
  31. data/lib/rubocop/cop/layout/leading_comment_space.rb +28 -0
  32. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +18 -4
  33. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +14 -2
  34. data/lib/rubocop/cop/layout/tab.rb +10 -22
  35. data/lib/rubocop/cop/lint/big_decimal_new.rb +1 -1
  36. data/lib/rubocop/cop/lint/debugger.rb +3 -3
  37. data/lib/rubocop/cop/lint/duplicate_methods.rb +3 -3
  38. data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -1
  39. data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -1
  40. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -1
  41. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +1 -1
  42. data/lib/rubocop/cop/lint/inherit_exception.rb +1 -1
  43. data/lib/rubocop/cop/lint/multiple_compare.rb +1 -1
  44. data/lib/rubocop/cop/lint/nested_method_definition.rb +3 -3
  45. data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
  46. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
  47. data/lib/rubocop/cop/lint/number_conversion.rb +2 -2
  48. data/lib/rubocop/cop/lint/rand_one.rb +1 -1
  49. data/lib/rubocop/cop/lint/redundant_with_index.rb +1 -1
  50. data/lib/rubocop/cop/lint/redundant_with_object.rb +1 -1
  51. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +5 -5
  52. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
  53. data/lib/rubocop/cop/lint/unified_integer.rb +1 -1
  54. data/lib/rubocop/cop/lint/unneeded_require_statement.rb +1 -1
  55. data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +1 -1
  56. data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
  57. data/lib/rubocop/cop/lint/uri_escape_unescape.rb +1 -1
  58. data/lib/rubocop/cop/lint/uri_regexp.rb +2 -2
  59. data/lib/rubocop/cop/lint/useless_access_modifier.rb +6 -6
  60. data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
  61. data/lib/rubocop/cop/metrics/class_length.rb +1 -1
  62. data/lib/rubocop/cop/metrics/module_length.rb +1 -1
  63. data/lib/rubocop/cop/metrics/parameter_lists.rb +1 -1
  64. data/lib/rubocop/cop/mixin/def_node.rb +1 -1
  65. data/lib/rubocop/cop/mixin/empty_parameter.rb +1 -1
  66. data/lib/rubocop/cop/mixin/enforce_superclass.rb +4 -4
  67. data/lib/rubocop/cop/mixin/method_complexity.rb +1 -1
  68. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +3 -3
  69. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -1
  70. data/lib/rubocop/cop/naming/constant_name.rb +2 -2
  71. data/lib/rubocop/cop/naming/predicate_name.rb +1 -1
  72. data/lib/rubocop/cop/security/eval.rb +1 -1
  73. data/lib/rubocop/cop/security/json_load.rb +1 -1
  74. data/lib/rubocop/cop/security/marshal_load.rb +1 -1
  75. data/lib/rubocop/cop/security/open.rb +1 -1
  76. data/lib/rubocop/cop/security/yaml_load.rb +1 -1
  77. data/lib/rubocop/cop/style/alias.rb +1 -1
  78. data/lib/rubocop/cop/style/colon_method_call.rb +1 -1
  79. data/lib/rubocop/cop/style/conditional_assignment.rb +1 -1
  80. data/lib/rubocop/cop/style/constant_visibility.rb +1 -1
  81. data/lib/rubocop/cop/style/date_time.rb +3 -3
  82. data/lib/rubocop/cop/style/dir.rb +1 -1
  83. data/lib/rubocop/cop/style/documentation_method.rb +1 -1
  84. data/lib/rubocop/cop/style/double_cop_disable_directive.rb +49 -0
  85. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  86. data/lib/rubocop/cop/style/each_with_object.rb +1 -1
  87. data/lib/rubocop/cop/style/eval_with_location.rb +2 -2
  88. data/lib/rubocop/cop/style/even_odd.rb +1 -1
  89. data/lib/rubocop/cop/style/expand_path_arguments.rb +3 -3
  90. data/lib/rubocop/cop/style/float_division.rb +4 -4
  91. data/lib/rubocop/cop/style/format_string.rb +7 -7
  92. data/lib/rubocop/cop/style/hash_syntax.rb +2 -2
  93. data/lib/rubocop/cop/style/inverse_methods.rb +2 -2
  94. data/lib/rubocop/cop/style/min_max.rb +1 -1
  95. data/lib/rubocop/cop/style/mixin_usage.rb +1 -1
  96. data/lib/rubocop/cop/style/multiline_when_then.rb +55 -0
  97. data/lib/rubocop/cop/style/multiple_comparison.rb +1 -1
  98. data/lib/rubocop/cop/style/mutable_constant.rb +3 -3
  99. data/lib/rubocop/cop/style/numeric_predicate.rb +3 -3
  100. data/lib/rubocop/cop/style/option_hash.rb +1 -1
  101. data/lib/rubocop/cop/style/or_assignment.rb +2 -2
  102. data/lib/rubocop/cop/style/parentheses_around_condition.rb +1 -1
  103. data/lib/rubocop/cop/style/random_with_offset.rb +6 -6
  104. data/lib/rubocop/cop/style/redundant_conditional.rb +2 -2
  105. data/lib/rubocop/cop/style/redundant_exception.rb +2 -2
  106. data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
  107. data/lib/rubocop/cop/style/redundant_parentheses.rb +2 -2
  108. data/lib/rubocop/cop/style/redundant_sort_by.rb +1 -1
  109. data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -2
  110. data/lib/rubocop/cop/style/return_nil.rb +1 -1
  111. data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
  112. data/lib/rubocop/cop/style/sample.rb +1 -1
  113. data/lib/rubocop/cop/style/stderr_puts.rb +1 -1
  114. data/lib/rubocop/cop/style/string_hash_keys.rb +2 -2
  115. data/lib/rubocop/cop/style/strip.rb +1 -1
  116. data/lib/rubocop/cop/style/struct_inheritance.rb +3 -3
  117. data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
  118. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
  119. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  120. data/lib/rubocop/cop/style/unneeded_sort.rb +1 -1
  121. data/lib/rubocop/cop/style/unpack_first.rb +1 -1
  122. data/lib/rubocop/cop/style/zero_length_predicate.rb +5 -5
  123. data/lib/rubocop/cop/team.rb +15 -14
  124. data/lib/rubocop/error.rb +23 -0
  125. data/lib/rubocop/node_pattern.rb +2 -2
  126. data/lib/rubocop/options.rb +17 -0
  127. data/lib/rubocop/rspec/shared_contexts.rb +12 -0
  128. data/lib/rubocop/target_finder.rb +6 -4
  129. data/lib/rubocop/version.rb +1 -1
  130. metadata +4 -2
@@ -24,7 +24,7 @@ module RuboCop
24
24
  class EachWithObjectArgument < Cop
25
25
  MSG = 'The argument to each_with_object can not be immutable.'
26
26
 
27
- def_node_matcher :each_with_object?, <<-PATTERN
27
+ def_node_matcher :each_with_object?, <<~PATTERN
28
28
  ({send csend} _ :each_with_object $_)
29
29
  PATTERN
30
30
 
@@ -76,7 +76,7 @@ module RuboCop
76
76
  '`ERB.new(str, eoutvar: %<arg_value>s)` instead.'
77
77
  ].freeze
78
78
 
79
- def_node_matcher :erb_new_with_non_keyword_arguments, <<-PATTERN
79
+ def_node_matcher :erb_new_with_non_keyword_arguments, <<~PATTERN
80
80
  (send
81
81
  (const {nil? cbase} :ERB) :new $...)
82
82
  PATTERN
@@ -61,7 +61,7 @@ module RuboCop
61
61
  end
62
62
  end
63
63
 
64
- def_node_matcher :called_on_string?, <<-PATTERN
64
+ def_node_matcher :called_on_string?, <<~PATTERN
65
65
  {(send {nil? const_type?} _ (str _) ...)
66
66
  (send (str ...) ...)}
67
67
  PATTERN
@@ -53,7 +53,7 @@ module RuboCop
53
53
  ALTERNATIVE_PROTECTED = '`protected` inside a `class << self` ' \
54
54
  'block'
55
55
 
56
- def_node_search :private_class_methods, <<-PATTERN
56
+ def_node_search :private_class_methods, <<~PATTERN
57
57
  (send nil? :private_class_method $...)
58
58
  PATTERN
59
59
 
@@ -55,7 +55,7 @@ module RuboCop
55
55
  SystemExit
56
56
  ].freeze
57
57
 
58
- def_node_matcher :class_new_call?, <<-PATTERN
58
+ def_node_matcher :class_new_call?, <<~PATTERN
59
59
  (send
60
60
  (const {cbase nil?} :Class) :new
61
61
  $(const {cbase nil?} _))
@@ -24,7 +24,7 @@ module RuboCop
24
24
  class MultipleCompare < Cop
25
25
  MSG = 'Use the `&&` operator to compare multiple values.'
26
26
 
27
- def_node_matcher :multiple_compare?, <<-PATTERN
27
+ def_node_matcher :multiple_compare?, <<~PATTERN
28
28
  (send (send _ {:< :> :<= :>=} $_) {:< :> :<= :>=} _)
29
29
  PATTERN
30
30
 
@@ -87,15 +87,15 @@ module RuboCop
87
87
  class_or_module_or_struct_new_call?(child)
88
88
  end
89
89
 
90
- def_node_matcher :eval_call?, <<-PATTERN
90
+ def_node_matcher :eval_call?, <<~PATTERN
91
91
  (block (send _ {:instance_eval :class_eval :module_eval} ...) ...)
92
92
  PATTERN
93
93
 
94
- def_node_matcher :exec_call?, <<-PATTERN
94
+ def_node_matcher :exec_call?, <<~PATTERN
95
95
  (block (send _ {:instance_exec :class_exec :module_exec} ...) ...)
96
96
  PATTERN
97
97
 
98
- def_node_matcher :class_or_module_or_struct_new_call?, <<-PATTERN
98
+ def_node_matcher :class_or_module_or_struct_new_call?, <<~PATTERN
99
99
  (block (send (const nil? {:Class :Module :Struct}) :new ...) ...)
100
100
  PATTERN
101
101
  end
@@ -25,7 +25,7 @@ module RuboCop
25
25
  class NextWithoutAccumulator < Cop
26
26
  MSG = 'Use `next` with an accumulator argument in a `reduce`.'
27
27
 
28
- def_node_matcher :on_body_of_reduce, <<-PATTERN
28
+ def_node_matcher :on_body_of_reduce, <<~PATTERN
29
29
  (block (send _recv {:reduce :inject} !sym) _blockargs $(begin ...))
30
30
  PATTERN
31
31
 
@@ -74,7 +74,7 @@ module RuboCop
74
74
  end
75
75
 
76
76
  def_node_matcher :chained_send?, '(send !nil? ...)'
77
- def_node_matcher :define_method?, <<-PATTERN
77
+ def_node_matcher :define_method?, <<~PATTERN
78
78
  (send _ {:define_method :define_singleton_method} _)
79
79
  PATTERN
80
80
  end
@@ -31,11 +31,11 @@ module RuboCop
31
31
  '%<number_object>s.%<to_method>s, use stricter '\
32
32
  '%<corrected_method>s.'
33
33
 
34
- def_node_matcher :to_method, <<-PATTERN
34
+ def_node_matcher :to_method, <<~PATTERN
35
35
  (send $_ ${:to_i :to_f :to_c})
36
36
  PATTERN
37
37
 
38
- def_node_matcher :datetime?, <<-PATTERN
38
+ def_node_matcher :datetime?, <<~PATTERN
39
39
  (send (const {nil? (cbase)} {:Time :DateTime}) ...)
40
40
  PATTERN
41
41
 
@@ -24,7 +24,7 @@ module RuboCop
24
24
  MSG = '`%<method>s` always returns `0`. ' \
25
25
  'Perhaps you meant `rand(2)` or `rand`?'
26
26
 
27
- def_node_matcher :rand_one?, <<-PATTERN
27
+ def_node_matcher :rand_one?, <<~PATTERN
28
28
  (send {(const nil? :Kernel) nil?} :rand {(int {-1 1}) (float {-1.0 1.0})})
29
29
  PATTERN
30
30
 
@@ -32,7 +32,7 @@ module RuboCop
32
32
  MSG_EACH_WITH_INDEX = 'Use `each` instead of `each_with_index`.'
33
33
  MSG_WITH_INDEX = 'Remove redundant `with_index`.'
34
34
 
35
- def_node_matcher :redundant_with_index?, <<-PATTERN
35
+ def_node_matcher :redundant_with_index?, <<~PATTERN
36
36
  (block
37
37
  $(send
38
38
  _ {:each_with_index :with_index} ...)
@@ -33,7 +33,7 @@ module RuboCop
33
33
 
34
34
  MSG_WITH_OBJECT = 'Remove redundant `with_object`.'
35
35
 
36
- def_node_matcher :redundant_with_object?, <<-PATTERN
36
+ def_node_matcher :redundant_with_object?, <<~PATTERN
37
37
  (block
38
38
  $(send _ {:each_with_object :with_object}
39
39
  _)
@@ -29,11 +29,11 @@ module RuboCop
29
29
  MSG = 'Do not chain ordinary method call' \
30
30
  ' after safe navigation operator.'
31
31
 
32
- def_node_matcher :bad_method?, <<-PATTERN
33
- {
34
- (send $(csend ...) $_ ...)
35
- (send $(block (csend ...) ...) $_ ...)
36
- }
32
+ def_node_matcher :bad_method?, <<~PATTERN
33
+ {
34
+ (send $(csend ...) $_ ...)
35
+ (send $(block (csend ...) ...) $_ ...)
36
+ }
37
37
  PATTERN
38
38
 
39
39
  def on_send(node)
@@ -23,7 +23,7 @@ module RuboCop
23
23
  MSG = 'Avoid calling `empty?` with the safe navigation operator ' \
24
24
  'in conditionals.'
25
25
 
26
- def_node_matcher :safe_navigation_empty_in_conditional?, <<-PATTERN
26
+ def_node_matcher :safe_navigation_empty_in_conditional?, <<~PATTERN
27
27
  (if (csend (send ...) :empty?) ...)
28
28
  PATTERN
29
29
 
@@ -20,7 +20,7 @@ module RuboCop
20
20
  class UnifiedInteger < Cop
21
21
  MSG = 'Use `Integer` instead of `%<klass>s`.'
22
22
 
23
- def_node_matcher :fixnum_or_bignum_const, <<-PATTERN
23
+ def_node_matcher :fixnum_or_bignum_const, <<~PATTERN
24
24
  (:const {nil? (:cbase)} ${:Fixnum :Bignum})
25
25
  PATTERN
26
26
 
@@ -26,7 +26,7 @@ module RuboCop
26
26
 
27
27
  MSG = 'Remove unnecessary `require` statement.'
28
28
 
29
- def_node_matcher :unnecessary_require_statement?, <<-PATTERN
29
+ def_node_matcher :unnecessary_require_statement?, <<~PATTERN
30
30
  (send nil? :require
31
31
  (str {"enumerator" "rational" "complex" "thread"}))
32
32
  PATTERN
@@ -60,7 +60,7 @@ module RuboCop
60
60
 
61
61
  def_node_matcher :array_new?, '$(send (const nil? :Array) :new ...)'
62
62
 
63
- def_node_matcher :literal_expansion, <<-PATTERN
63
+ def_node_matcher :literal_expansion, <<~PATTERN
64
64
  (splat {$({str dstr int float array} ...) (block $#array_new? ...) $#array_new?} ...)
65
65
  PATTERN
66
66
 
@@ -51,7 +51,7 @@ module RuboCop
51
51
 
52
52
  private
53
53
 
54
- def_node_matcher :flow_command?, <<-PATTERN
54
+ def_node_matcher :flow_command?, <<~PATTERN
55
55
  {
56
56
  return next break retry redo
57
57
  (send
@@ -45,7 +45,7 @@ module RuboCop
45
45
  'Instead, use %<replacements>s depending on your specific use ' \
46
46
  'case.'
47
47
 
48
- def_node_matcher :uri_escape_unescape?, <<-PATTERN
48
+ def_node_matcher :uri_escape_unescape?, <<~PATTERN
49
49
  (send
50
50
  (const ${nil? cbase} :URI) ${:escape :encode :unescape :decode}
51
51
  ...)
@@ -18,13 +18,13 @@ module RuboCop
18
18
  'be used. Instead, use `%<top_level>sURI::DEFAULT_PARSER.' \
19
19
  'make_regexp%<arg>s`.'
20
20
 
21
- def_node_matcher :uri_regexp_with_argument?, <<-PATTERN
21
+ def_node_matcher :uri_regexp_with_argument?, <<~PATTERN
22
22
  (send
23
23
  (const ${nil? cbase} :URI) :regexp
24
24
  (str $_))
25
25
  PATTERN
26
26
 
27
- def_node_matcher :uri_regexp_without_argument?, <<-PATTERN
27
+ def_node_matcher :uri_regexp_without_argument?, <<~PATTERN
28
28
  (send
29
29
  (const ${nil? cbase} :URI) :regexp)
30
30
  PATTERN
@@ -113,19 +113,19 @@ module RuboCop
113
113
 
114
114
  private
115
115
 
116
- def_node_matcher :static_method_definition?, <<-PATTERN
116
+ def_node_matcher :static_method_definition?, <<~PATTERN
117
117
  {def (send nil? {:attr :attr_reader :attr_writer :attr_accessor} ...)}
118
118
  PATTERN
119
119
 
120
- def_node_matcher :dynamic_method_definition?, <<-PATTERN
120
+ def_node_matcher :dynamic_method_definition?, <<~PATTERN
121
121
  {(send nil? :define_method ...) (block (send nil? :define_method ...) ...)}
122
122
  PATTERN
123
123
 
124
- def_node_matcher :class_or_instance_eval?, <<-PATTERN
124
+ def_node_matcher :class_or_instance_eval?, <<~PATTERN
125
125
  (block (send _ {:class_eval :instance_eval}) ...)
126
126
  PATTERN
127
127
 
128
- def_node_matcher :class_or_module_or_struct_new_call?, <<-PATTERN
128
+ def_node_matcher :class_or_module_or_struct_new_call?, <<~PATTERN
129
129
  (block (send (const nil? {:Class :Module :Struct}) :new ...) ...)
130
130
  PATTERN
131
131
 
@@ -202,7 +202,7 @@ module RuboCop
202
202
  cop_config.fetch('MethodCreatingMethods', []).any? do |m|
203
203
  matcher_name = "#{m}_method?".to_sym
204
204
  unless respond_to?(matcher_name)
205
- self.class.def_node_matcher matcher_name, <<-PATTERN
205
+ self.class.def_node_matcher matcher_name, <<~PATTERN
206
206
  {def (send nil? :#{m} ...)}
207
207
  PATTERN
208
208
  end
@@ -226,7 +226,7 @@ module RuboCop
226
226
  cop_config.fetch('ContextCreatingMethods', []).any? do |m|
227
227
  matcher_name = "#{m}_block?".to_sym
228
228
  unless respond_to?(matcher_name)
229
- self.class.def_node_matcher matcher_name, <<-PATTERN
229
+ self.class.def_node_matcher matcher_name, <<~PATTERN
230
230
  (block (send {nil? const} {:#{m}} ...) ...)
231
231
  PATTERN
232
232
  end
@@ -49,7 +49,7 @@ module RuboCop
49
49
 
50
50
  private
51
51
 
52
- def_node_matcher :setter_call_to_local_variable?, <<-PATTERN
52
+ def_node_matcher :setter_call_to_local_variable?, <<~PATTERN
53
53
  [(send (lvar _) ...) setter_method?]
54
54
  PATTERN
55
55
 
@@ -21,7 +21,7 @@ module RuboCop
21
21
 
22
22
  private
23
23
 
24
- def_node_matcher :class_definition?, <<-PATTERN
24
+ def_node_matcher :class_definition?, <<~PATTERN
25
25
  (casgn nil? _ (block (send (const nil? :Class) :new) ...))
26
26
  PATTERN
27
27
 
@@ -21,7 +21,7 @@ module RuboCop
21
21
 
22
22
  private
23
23
 
24
- def_node_matcher :module_definition?, <<-PATTERN
24
+ def_node_matcher :module_definition?, <<~PATTERN
25
25
  (casgn nil? _ (block (send (const nil? :Module) :new) ...))
26
26
  PATTERN
27
27
 
@@ -25,7 +25,7 @@ module RuboCop
25
25
 
26
26
  private
27
27
 
28
- def_node_matcher :argument_to_lambda_or_proc?, <<-PATTERN
28
+ def_node_matcher :argument_to_lambda_or_proc?, <<~PATTERN
29
29
  ^lambda_or_proc?
30
30
  PATTERN
31
31
 
@@ -25,7 +25,7 @@ module RuboCop
25
25
  processed_source[0..index].map(&:strip)
26
26
  end
27
27
 
28
- def_node_matcher :non_public_modifier?, <<-PATTERN
28
+ def_node_matcher :non_public_modifier?, <<~PATTERN
29
29
  (send nil? {:private :protected} ({def defs} ...))
30
30
  PATTERN
31
31
  end
@@ -8,7 +8,7 @@ module RuboCop
8
8
 
9
9
  private
10
10
 
11
- def_node_matcher :empty_arguments?, <<-PATTERN
11
+ def_node_matcher :empty_arguments?, <<~PATTERN
12
12
  (block _ $(args) _)
13
13
  PATTERN
14
14
 
@@ -5,12 +5,12 @@ module RuboCop
5
5
  # Common functionality for enforcing a specific superclass
6
6
  module EnforceSuperclass
7
7
  def self.included(base)
8
- base.def_node_matcher :class_definition, <<-PATTERN
9
- (class (const _ !:#{base::SUPERCLASS}) #{base::BASE_PATTERN} ...)
8
+ base.def_node_matcher :class_definition, <<~PATTERN
9
+ (class (const _ !:#{base::SUPERCLASS}) #{base::BASE_PATTERN} ...)
10
10
  PATTERN
11
11
 
12
- base.def_node_matcher :class_new_definition, <<-PATTERN
13
- [!^(casgn nil? :#{base::SUPERCLASS} ...) (send (const nil? :Class) :new #{base::BASE_PATTERN})]
12
+ base.def_node_matcher :class_new_definition, <<~PATTERN
13
+ [!^(casgn nil? :#{base::SUPERCLASS} ...) (send (const nil? :Class) :new #{base::BASE_PATTERN})]
14
14
  PATTERN
15
15
  end
16
16
 
@@ -20,7 +20,7 @@ module RuboCop
20
20
 
21
21
  private
22
22
 
23
- def_node_matcher :define_method?, <<-PATTERN
23
+ def_node_matcher :define_method?, <<~PATTERN
24
24
  (block
25
25
  (send nil? :define_method ({sym str} $_))
26
26
  args
@@ -159,11 +159,11 @@ module RuboCop
159
159
  break false if a.block_type?
160
160
 
161
161
  next if a.setter_method?
162
+ next unless kind == :with_or_without_parentheses ||
163
+ kind == :with_parentheses && parentheses?(a)
162
164
 
163
165
  a.arguments.any? do |arg|
164
- within_node?(node, arg) && (kind == :with_or_without_parentheses ||
165
- kind == :with_parentheses &&
166
- parentheses?(node.parent))
166
+ within_node?(node, arg)
167
167
  end
168
168
  end
169
169
  end
@@ -20,7 +20,7 @@ module RuboCop
20
20
  OP_LIKE_METHODS = %i[eql? equal?].freeze
21
21
  BLACKLISTED = %i[+@ -@ [] []= << === `].freeze
22
22
 
23
- def_node_matcher :op_method_candidate?, <<-PATTERN
23
+ def_node_matcher :op_method_candidate?, <<~PATTERN
24
24
  (def [#op_method? $_] (args $(arg [!:other !:_other])) _)
25
25
  PATTERN
26
26
 
@@ -23,7 +23,7 @@ module RuboCop
23
23
  # than just standard ASCII characters
24
24
  SNAKE_CASE = /^[[:digit:][:upper:]_]+$/.freeze
25
25
 
26
- def_node_matcher :class_or_struct_return_method?, <<-PATTERN
26
+ def_node_matcher :class_or_struct_return_method?, <<~PATTERN
27
27
  (send
28
28
  (const _ {:Class :Struct}) :new
29
29
  ...)
@@ -63,7 +63,7 @@ module RuboCop
63
63
  (node.receiver.nil? || !literal_receiver?(node))
64
64
  end
65
65
 
66
- def_node_matcher :literal_receiver?, <<-PATTERN
66
+ def_node_matcher :literal_receiver?, <<~PATTERN
67
67
  {(send literal? ...)
68
68
  (send (begin literal?) ...)}
69
69
  PATTERN
@@ -28,7 +28,7 @@ module RuboCop
28
28
  # def value?
29
29
  # end
30
30
  class PredicateName < Cop
31
- def_node_matcher :dynamic_method_define, <<-PATTERN
31
+ def_node_matcher :dynamic_method_define, <<~PATTERN
32
32
  (send nil? #method_definition_macros
33
33
  (sym $_)
34
34
  ...)
@@ -14,7 +14,7 @@ module RuboCop
14
14
  class Eval < Cop
15
15
  MSG = 'The use of `eval` is a serious security risk.'
16
16
 
17
- def_node_matcher :eval?, <<-PATTERN
17
+ def_node_matcher :eval?, <<~PATTERN
18
18
  (send {nil? (send nil? :binding)} :eval $!str ...)
19
19
  PATTERN
20
20
 
@@ -25,7 +25,7 @@ module RuboCop
25
25
  class JSONLoad < Cop
26
26
  MSG = 'Prefer `JSON.parse` over `JSON.%<method>s`.'
27
27
 
28
- def_node_matcher :json_load, <<-PATTERN
28
+ def_node_matcher :json_load, <<~PATTERN
29
29
  (send (const {nil? cbase} :JSON) ${:load :restore} ...)
30
30
  PATTERN
31
31
 
@@ -21,7 +21,7 @@ module RuboCop
21
21
  class MarshalLoad < Cop
22
22
  MSG = 'Avoid using `Marshal.%<method>s`.'
23
23
 
24
- def_node_matcher :marshal_load, <<-PATTERN
24
+ def_node_matcher :marshal_load, <<~PATTERN
25
25
  (send (const {nil? cbase} :Marshal) ${:load :restore}
26
26
  !(send (const {nil? cbase} :Marshal) :dump ...))
27
27
  PATTERN