rubocop 0.48.0 → 0.48.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubocop might be problematic. Click here for more details.

Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +5 -0
  4. data/config/enabled.yml +2 -1
  5. data/lib/rubocop/ast/builder.rb +2 -2
  6. data/lib/rubocop/ast/node.rb +14 -14
  7. data/lib/rubocop/ast/node/send_node.rb +8 -3
  8. data/lib/rubocop/ast/traversal.rb +8 -8
  9. data/lib/rubocop/config.rb +3 -3
  10. data/lib/rubocop/config_loader.rb +2 -2
  11. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +26 -13
  12. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -1
  13. data/lib/rubocop/cop/lint/inherit_exception.rb +2 -2
  14. data/lib/rubocop/cop/lint/literal_in_condition.rb +1 -1
  15. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
  16. data/lib/rubocop/cop/lint/nested_method_definition.rb +26 -3
  17. data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +1 -1
  18. data/lib/rubocop/cop/lint/unreachable_code.rb +2 -2
  19. data/lib/rubocop/cop/lint/useless_comparison.rb +1 -1
  20. data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
  21. data/lib/rubocop/cop/lint/void.rb +1 -1
  22. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  23. data/lib/rubocop/cop/metrics/block_nesting.rb +2 -2
  24. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +2 -2
  25. data/lib/rubocop/cop/metrics/parameter_lists.rb +1 -1
  26. data/lib/rubocop/cop/metrics/perceived_complexity.rb +2 -2
  27. data/lib/rubocop/cop/mixin/access_modifier_node.rb +1 -1
  28. data/lib/rubocop/cop/mixin/def_node.rb +1 -1
  29. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
  30. data/lib/rubocop/cop/mixin/on_method_def.rb +1 -1
  31. data/lib/rubocop/cop/mixin/percent_literal.rb +45 -4
  32. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
  33. data/lib/rubocop/cop/mixin/unused_argument.rb +1 -1
  34. data/lib/rubocop/cop/offense.rb +2 -2
  35. data/lib/rubocop/cop/performance/casecmp.rb +1 -1
  36. data/lib/rubocop/cop/performance/end_with.rb +1 -2
  37. data/lib/rubocop/cop/performance/redundant_match.rb +1 -1
  38. data/lib/rubocop/cop/performance/regexp_match.rb +2 -2
  39. data/lib/rubocop/cop/performance/start_with.rb +1 -2
  40. data/lib/rubocop/cop/rails/action_filter.rb +4 -4
  41. data/lib/rubocop/cop/rails/blank.rb +1 -0
  42. data/lib/rubocop/cop/rails/date.rb +3 -3
  43. data/lib/rubocop/cop/rails/delegate.rb +1 -1
  44. data/lib/rubocop/cop/rails/exit.rb +2 -2
  45. data/lib/rubocop/cop/rails/file_path.rb +5 -1
  46. data/lib/rubocop/cop/rails/find_by.rb +1 -1
  47. data/lib/rubocop/cop/rails/find_each.rb +2 -2
  48. data/lib/rubocop/cop/rails/http_positional_arguments.rb +3 -3
  49. data/lib/rubocop/cop/rails/relative_date_constant.rb +7 -3
  50. data/lib/rubocop/cop/rails/request_referer.rb +17 -2
  51. data/lib/rubocop/cop/rails/save_bang.rb +4 -4
  52. data/lib/rubocop/cop/rails/skips_model_validations.rb +2 -2
  53. data/lib/rubocop/cop/rails/time_zone.rb +6 -6
  54. data/lib/rubocop/cop/rails/validation.rb +2 -2
  55. data/lib/rubocop/cop/severity.rb +1 -1
  56. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +34 -0
  57. data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
  58. data/lib/rubocop/cop/style/command_literal.rb +1 -1
  59. data/lib/rubocop/cop/style/conditional_assignment.rb +3 -3
  60. data/lib/rubocop/cop/style/constant_name.rb +1 -1
  61. data/lib/rubocop/cop/style/each_with_object.rb +1 -1
  62. data/lib/rubocop/cop/style/empty_line_after_magic_comment.rb +1 -1
  63. data/lib/rubocop/cop/style/file_name.rb +2 -2
  64. data/lib/rubocop/cop/style/global_vars.rb +2 -2
  65. data/lib/rubocop/cop/style/if_unless_modifier.rb +2 -2
  66. data/lib/rubocop/cop/style/indentation_width.rb +2 -2
  67. data/lib/rubocop/cop/style/inverse_methods.rb +1 -1
  68. data/lib/rubocop/cop/style/line_end_concatenation.rb +5 -5
  69. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +15 -7
  70. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +1 -1
  71. data/lib/rubocop/cop/style/mixin_grouping.rb +2 -2
  72. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +2 -2
  73. data/lib/rubocop/cop/style/next.rb +3 -3
  74. data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
  75. data/lib/rubocop/cop/style/one_line_conditional.rb +2 -2
  76. data/lib/rubocop/cop/style/op_method.rb +2 -2
  77. data/lib/rubocop/cop/style/parallel_assignment.rb +1 -1
  78. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +5 -36
  79. data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
  80. data/lib/rubocop/cop/style/preferred_hash_methods.rb +2 -2
  81. data/lib/rubocop/cop/style/redundant_parentheses.rb +1 -1
  82. data/lib/rubocop/cop/style/redundant_self.rb +4 -5
  83. data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
  84. data/lib/rubocop/cop/style/self_assignment.rb +3 -3
  85. data/lib/rubocop/cop/style/space_around_keyword.rb +9 -9
  86. data/lib/rubocop/cop/style/space_around_operators.rb +1 -1
  87. data/lib/rubocop/cop/style/space_inside_brackets.rb +1 -1
  88. data/lib/rubocop/cop/style/space_inside_parens.rb +1 -1
  89. data/lib/rubocop/cop/style/special_global_vars.rb +10 -10
  90. data/lib/rubocop/cop/style/symbol_proc.rb +2 -2
  91. data/lib/rubocop/cop/style/ternary_parentheses.rb +3 -2
  92. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  93. data/lib/rubocop/cop/util.rb +7 -7
  94. data/lib/rubocop/cop/variable_force.rb +7 -7
  95. data/lib/rubocop/cop/variable_force/variable.rb +2 -2
  96. data/lib/rubocop/formatter/colorizable.rb +2 -2
  97. data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
  98. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  99. data/lib/rubocop/options.rb +20 -11
  100. data/lib/rubocop/processed_source.rb +1 -1
  101. data/lib/rubocop/result_cache.rb +2 -2
  102. data/lib/rubocop/rspec/shared_examples.rb +1 -1
  103. data/lib/rubocop/runner.rb +1 -1
  104. data/lib/rubocop/target_finder.rb +6 -6
  105. data/lib/rubocop/version.rb +1 -1
  106. metadata +2 -2
@@ -12,22 +12,20 @@ module RuboCop
12
12
  # @example
13
13
  # # Style/PercentLiteralDelimiters:
14
14
  # # PreferredDelimiters:
15
- # # default: ()
16
- # # %i: []
15
+ # # default: []
16
+ # # %i: ()
17
17
  #
18
18
  # # good
19
- # %w(alpha beta) + %i[gamma delta]
19
+ # %w[alpha beta] + %i(gamma delta)
20
20
  #
21
21
  # # bad
22
- # %W[alpha #{beta}]
22
+ # %W(alpha #{beta})
23
23
  #
24
24
  # # bad
25
- # %I[alpha beta]
25
+ # %I(alpha beta)
26
26
  class PercentLiteralDelimiters < Cop
27
27
  include PercentLiteral
28
28
 
29
- PERCENT_LITERAL_TYPES = %w(% %i %I %q %Q %r %s %w %W %x).freeze
30
-
31
29
  def on_array(node)
32
30
  process(node, '%w', '%W', '%i', '%I')
33
31
  end
@@ -78,35 +76,6 @@ module RuboCop
78
76
  add_offense(node, :expression)
79
77
  end
80
78
 
81
- def preferred_delimiters
82
- @preferred_delimiters ||=
83
- begin
84
- ensure_valid_preferred_delimiters
85
-
86
- if cop_config['PreferredDelimiters'].key?('default')
87
- Hash[PERCENT_LITERAL_TYPES.map do |type|
88
- [type, cop_config['PreferredDelimiters'][type] ||
89
- cop_config['PreferredDelimiters']['default']]
90
- end]
91
- else
92
- cop_config['PreferredDelimiters']
93
- end
94
- end
95
- end
96
-
97
- def ensure_valid_preferred_delimiters
98
- invalid = cop_config['PreferredDelimiters'].keys -
99
- (PERCENT_LITERAL_TYPES + %w(default))
100
- return if invalid.empty?
101
-
102
- raise ArgumentError,
103
- "Invalid preferred delimiter config key: #{invalid.join(', ')}"
104
- end
105
-
106
- def preferred_delimiters_for(type)
107
- preferred_delimiters[type].split(//)
108
- end
109
-
110
79
  def uses_preferred_delimiter?(node, type)
111
80
  preferred_delimiters_for(type)[0] == begin_source(node)[-1]
112
81
  end
@@ -16,7 +16,7 @@ module RuboCop
16
16
  lambda do |corrector|
17
17
  backref, = *node
18
18
  parent_type = node.parent ? node.parent.type : nil
19
- if %i(dstr xstr regexp).include?(parent_type)
19
+ if %i[dstr xstr regexp].include?(parent_type)
20
20
  corrector.replace(node.source_range,
21
21
  "{Regexp.last_match(#{backref})}")
22
22
  else
@@ -37,8 +37,8 @@ module RuboCop
37
37
  MSG = 'Use `Hash#%s` instead of `Hash#%s`.'.freeze
38
38
 
39
39
  OFFENDING_SELECTORS = {
40
- short: %i(has_key? has_value?),
41
- verbose: %i(key? value?)
40
+ short: %i[has_key? has_value?],
41
+ verbose: %i[key? value?]
42
42
  }.freeze
43
43
 
44
44
  def on_send(node)
@@ -16,7 +16,7 @@ module RuboCop
16
16
  class RedundantParentheses < Cop
17
17
  include Parentheses
18
18
 
19
- ALLOWED_LITERALS = %i(irange erange).freeze
19
+ ALLOWED_LITERALS = %i[irange erange].freeze
20
20
 
21
21
  def_node_matcher :square_brackets?,
22
22
  '(send {(send _recv _msg) str array hash} :[] ...)'
@@ -71,9 +71,7 @@ module RuboCop
71
71
  add_scope(node)
72
72
  end
73
73
 
74
- def on_defs(node)
75
- add_scope(node)
76
- end
74
+ alias on_defs on_def
77
75
 
78
76
  def on_args(node)
79
77
  node.children.each { |arg| on_argument(arg) }
@@ -90,6 +88,7 @@ module RuboCop
90
88
 
91
89
  def on_send(node)
92
90
  return unless node.self_receiver? && regular_method_call?(node)
91
+ return if node.parent && node.parent.mlhs_type?
93
92
 
94
93
  return if @allowed_send_nodes.include?(node) ||
95
94
  @local_variables_scopes[node].include?(node.method_name)
@@ -127,11 +126,11 @@ module RuboCop
127
126
  end
128
127
 
129
128
  def keyword?(method_name)
130
- %i(alias and begin break case class def defined? do
129
+ %i[alias and begin break case class def defined? do
131
130
  else elsif end ensure false for if in module
132
131
  next nil not or redo rescue retry return self
133
132
  super then true undef unless until when while
134
- yield).include?(method_name)
133
+ yield].include?(method_name)
135
134
  end
136
135
 
137
136
  def allow_self(node)
@@ -100,7 +100,7 @@ module RuboCop
100
100
  replacement = if slash_literal?(node)
101
101
  ['%r', ''].zip(preferred_delimiters).map(&:join)
102
102
  else
103
- %w(/ /)
103
+ %w[/ /]
104
104
  end
105
105
 
106
106
  lambda do |corrector|
@@ -14,7 +14,7 @@ module RuboCop
14
14
  # x += 1
15
15
  class SelfAssignment < Cop
16
16
  MSG = 'Use self-assignment shorthand `%s=`.'.freeze
17
- OPS = %i(+ - * ** / | &).freeze
17
+ OPS = %i[+ - * ** / | &].freeze
18
18
 
19
19
  def on_lvasgn(node)
20
20
  check(node, :lvar)
@@ -36,7 +36,7 @@ module RuboCop
36
36
 
37
37
  if rhs.send_type?
38
38
  check_send_node(node, rhs, var_name, var_type)
39
- elsif %i(and or).include?(rhs.type)
39
+ elsif %i[and or].include?(rhs.type)
40
40
  check_boolean_node(node, rhs, var_name, var_type)
41
41
  end
42
42
  end
@@ -66,7 +66,7 @@ module RuboCop
66
66
 
67
67
  if rhs.send_type?
68
68
  autocorrect_send_node(node, rhs)
69
- elsif %i(and or).include?(rhs.type)
69
+ elsif %i[and or].include?(rhs.type)
70
70
  autocorrect_boolean_node(node, rhs)
71
71
  end
72
72
  end
@@ -31,16 +31,16 @@ module RuboCop
31
31
  DO = 'do'.freeze
32
32
  SAFE_NAVIGATION = '&.'.freeze
33
33
  ACCEPT_LEFT_PAREN =
34
- %w(break defined? next not rescue return super yield).freeze
34
+ %w[break defined? next not rescue return super yield].freeze
35
35
  ACCEPT_LEFT_SQUARE_BRACKET =
36
- %w(super yield).freeze
36
+ %w[super yield].freeze
37
37
 
38
38
  def on_and(node)
39
39
  check(node, [:operator].freeze) if node.keyword?
40
40
  end
41
41
 
42
42
  def on_block(node)
43
- check(node, %i(begin end).freeze)
43
+ check(node, %i[begin end].freeze)
44
44
  end
45
45
 
46
46
  def on_break(node)
@@ -48,7 +48,7 @@ module RuboCop
48
48
  end
49
49
 
50
50
  def on_case(node)
51
- check(node, %i(keyword else).freeze)
51
+ check(node, %i[keyword else].freeze)
52
52
  end
53
53
 
54
54
  def on_ensure(node)
@@ -56,15 +56,15 @@ module RuboCop
56
56
  end
57
57
 
58
58
  def on_for(node)
59
- check(node, %i(begin end).freeze)
59
+ check(node, %i[begin end].freeze)
60
60
  end
61
61
 
62
62
  def on_if(node)
63
- check(node, %i(keyword else begin end).freeze, 'then'.freeze)
63
+ check(node, %i[keyword else begin end].freeze, 'then'.freeze)
64
64
  end
65
65
 
66
66
  def on_kwbegin(node)
67
- check(node, %i(begin end).freeze, nil)
67
+ check(node, %i[begin end].freeze, nil)
68
68
  end
69
69
 
70
70
  def on_next(node)
@@ -108,7 +108,7 @@ module RuboCop
108
108
  end
109
109
 
110
110
  def on_until(node)
111
- check(node, %i(begin end keyword).freeze)
111
+ check(node, %i[begin end keyword].freeze)
112
112
  end
113
113
 
114
114
  def on_when(node)
@@ -116,7 +116,7 @@ module RuboCop
116
116
  end
117
117
 
118
118
  def on_while(node)
119
- check(node, %i(begin end keyword).freeze)
119
+ check(node, %i[begin end keyword].freeze)
120
120
  end
121
121
 
122
122
  def on_yield(node)
@@ -8,7 +8,7 @@ module RuboCop
8
8
  class SpaceAroundOperators < Cop
9
9
  include PrecedingFollowingAlignment
10
10
 
11
- IRREGULAR_METHODS = %i([] ! []=).freeze
11
+ IRREGULAR_METHODS = %i[[] ! []=].freeze
12
12
 
13
13
  def on_pair(node)
14
14
  return unless node.hash_rocket?
@@ -9,7 +9,7 @@ module RuboCop
9
9
 
10
10
  def specifics
11
11
  [
12
- %i(tLBRACK tLBRACK2),
12
+ %i[tLBRACK tLBRACK2],
13
13
  :tRBRACK,
14
14
  'square brackets'
15
15
  ]
@@ -8,7 +8,7 @@ module RuboCop
8
8
  include SpaceInside
9
9
 
10
10
  def specifics
11
- [%i(tLPAREN tLPAREN2), :tRPAREN, 'parentheses']
11
+ [%i[tLPAREN tLPAREN2], :tRPAREN, 'parentheses']
12
12
  end
13
13
  end
14
14
  end
@@ -19,19 +19,19 @@ module RuboCop
19
19
  :$0 => [:$PROGRAM_NAME],
20
20
  :$! => [:$ERROR_INFO],
21
21
  :$@ => [:$ERROR_POSITION],
22
- :$; => %i($FIELD_SEPARATOR $FS),
23
- :$, => %i($OUTPUT_FIELD_SEPARATOR $OFS),
24
- :$/ => %i($INPUT_RECORD_SEPARATOR $RS),
25
- :$\ => %i($OUTPUT_RECORD_SEPARATOR $ORS),
26
- :$. => %i($INPUT_LINE_NUMBER $NR),
22
+ :$; => %i[$FIELD_SEPARATOR $FS],
23
+ :$, => %i[$OUTPUT_FIELD_SEPARATOR $OFS],
24
+ :$/ => %i[$INPUT_RECORD_SEPARATOR $RS],
25
+ :$\ => %i[$OUTPUT_RECORD_SEPARATOR $ORS],
26
+ :$. => %i[$INPUT_LINE_NUMBER $NR],
27
27
  :$_ => [:$LAST_READ_LINE],
28
28
  :$> => [:$DEFAULT_OUTPUT],
29
29
  :$< => [:$DEFAULT_INPUT],
30
- :$$ => %i($PROCESS_ID $PID),
30
+ :$$ => %i[$PROCESS_ID $PID],
31
31
  :$? => [:$CHILD_STATUS],
32
32
  :$~ => [:$LAST_MATCH_INFO],
33
33
  :$= => [:$IGNORECASE],
34
- :$* => %i($ARGV ARGV),
34
+ :$* => %i[$ARGV ARGV],
35
35
  :$& => [:$MATCH],
36
36
  :$` => [:$PREMATCH],
37
37
  :$' => [:$POSTMATCH],
@@ -51,12 +51,12 @@ module RuboCop
51
51
  PERL_VARS.each { |_, v| v.freeze }.freeze
52
52
 
53
53
  # Anything *not* in this set is provided by the English library.
54
- NON_ENGLISH_VARS = Set.new(%i(
54
+ NON_ENGLISH_VARS = Set.new(%i[
55
55
  $LOAD_PATH
56
56
  $LOADED_FEATURES
57
57
  $PROGRAM_NAME
58
58
  ARGV
59
- )).freeze
59
+ ]).freeze
60
60
 
61
61
  def on_gvar(node)
62
62
  global_var, = *node
@@ -126,7 +126,7 @@ module RuboCop
126
126
  parent_type = node.parent && node.parent.type
127
127
  preferred_name = preferred_names(global_var).first
128
128
 
129
- unless %i(dstr xstr regexp).include?(parent_type)
129
+ unless %i[dstr xstr regexp].include?(parent_type)
130
130
  return preferred_name.to_s
131
131
  end
132
132
 
@@ -13,7 +13,7 @@ module RuboCop
13
13
  # something.map(&:upcase)
14
14
  class SymbolProc < Cop
15
15
  MSG = 'Pass `&:%s` as an argument to `%s` instead of a block.'.freeze
16
- SUPER_TYPES = %i(super zsuper).freeze
16
+ SUPER_TYPES = %i[super zsuper].freeze
17
17
 
18
18
  def_node_matcher :proc_node?, '(send (const nil :Proc) :new)'
19
19
  def_node_matcher :symbol_proc?, <<-PATTERN
@@ -31,7 +31,7 @@ module RuboCop
31
31
  # configurable - https://github.com/bbatsov/rubocop/issues/1485
32
32
  # we should ignore lambdas & procs
33
33
  return if proc_node?(send_or_super)
34
- return if %i(lambda proc).include?(block_method_name)
34
+ return if %i[lambda proc].include?(block_method_name)
35
35
  return if ignored_method?(block_method_name)
36
36
  return unless can_shorten?(block_args, block_body)
37
37
 
@@ -5,7 +5,8 @@ module RuboCop
5
5
  module Style
6
6
  # This cop checks for the presence of parentheses around ternary
7
7
  # conditions. It is configurable to enforce inclusion or omission of
8
- # parentheses using `EnforcedStyle`.
8
+ # parentheses using `EnforcedStyle`. Omission is only enforced when
9
+ # removing the parentheses won't cause a different behaviour.
9
10
  #
10
11
  # @example
11
12
  #
@@ -161,7 +162,7 @@ module RuboCop
161
162
 
162
163
  def_node_matcher :method_call_argument, <<-PATTERN
163
164
  {(:defined? $...)
164
- (send {(send ...) nil} _ $(send nil _)...)}
165
+ (send {_ nil} _ $(send nil _)...)}
165
166
  PATTERN
166
167
 
167
168
  def_node_matcher :square_brackets?,
@@ -95,7 +95,7 @@ module RuboCop
95
95
 
96
96
  def looks_like_trivial_writer?(args, body)
97
97
  args.children.one? &&
98
- !%i(restarg blockarg).include?(args.children[0].type) &&
98
+ !%i[restarg blockarg].include?(args.children[0].type) &&
99
99
  body && body.ivasgn_type? &&
100
100
  body.children[1] && body.children[1].lvar_type?
101
101
  end
@@ -10,14 +10,14 @@ module RuboCop
10
10
 
11
11
  BYTE_ORDER_MARK = 0xfeff # The Unicode codepoint
12
12
 
13
- EQUALS_ASGN_NODES = %i(lvasgn ivasgn cvasgn gvasgn
14
- casgn masgn).freeze
15
- SHORTHAND_ASGN_NODES = %i(op_asgn or_asgn and_asgn).freeze
13
+ EQUALS_ASGN_NODES = %i[lvasgn ivasgn cvasgn gvasgn
14
+ casgn masgn].freeze
15
+ SHORTHAND_ASGN_NODES = %i[op_asgn or_asgn and_asgn].freeze
16
16
  ASGN_NODES = (EQUALS_ASGN_NODES + SHORTHAND_ASGN_NODES).freeze
17
17
 
18
- MODIFIER_NODES = %i(if while until).freeze
18
+ MODIFIER_NODES = %i[if while until].freeze
19
19
  CONDITIONAL_NODES = (MODIFIER_NODES + [:case]).freeze
20
- LOGICAL_OPERATOR_NODES = %i(and or).freeze
20
+ LOGICAL_OPERATOR_NODES = %i[and or].freeze
21
21
 
22
22
  # http://phrogz.net/programmingruby/language.html#table_18.4
23
23
  # Backtick is added last just to help editors parse this code.
@@ -236,10 +236,10 @@ module RuboCop
236
236
  end
237
237
 
238
238
  def symbol_without_quote?(string)
239
- special_gvars = %w(
239
+ special_gvars = %w[
240
240
  $! $" $$ $& $' $* $+ $, $/ $; $: $. $< $= $> $? $@ $\\ $_ $` $~ $0
241
241
  $-0 $-F $-I $-K $-W $-a $-d $-i $-l $-p $-v $-w
242
- )
242
+ ]
243
243
  redefinable_operators = %w(
244
244
  | ^ & <=> == === =~ > >= < <= << >>
245
245
  + - * / % ** ~ +@ -@ [] []= ` ! != !~
@@ -35,7 +35,7 @@ module RuboCop
35
35
  :shadowarg # This means block local variable (obj.each { |arg; this| }).
36
36
  ].freeze
37
37
 
38
- LOGICAL_OPERATOR_ASSIGNMENT_TYPES = %i(or_asgn and_asgn).freeze
38
+ LOGICAL_OPERATOR_ASSIGNMENT_TYPES = %i[or_asgn and_asgn].freeze
39
39
  OPERATOR_ASSIGNMENT_TYPES =
40
40
  (LOGICAL_OPERATOR_ASSIGNMENT_TYPES + [:op_asgn]).freeze
41
41
 
@@ -43,15 +43,15 @@ module RuboCop
43
43
 
44
44
  VARIABLE_REFERENCE_TYPE = :lvar
45
45
 
46
- POST_CONDITION_LOOP_TYPES = %i(while_post until_post).freeze
47
- LOOP_TYPES = (POST_CONDITION_LOOP_TYPES + %i(while until for)).freeze
46
+ POST_CONDITION_LOOP_TYPES = %i[while_post until_post].freeze
47
+ LOOP_TYPES = (POST_CONDITION_LOOP_TYPES + %i[while until for]).freeze
48
48
 
49
49
  RESCUE_TYPE = :rescue
50
50
 
51
51
  ZERO_ARITY_SUPER_TYPE = :zsuper
52
52
 
53
- TWISTED_SCOPE_TYPES = %i(block class sclass defs).freeze
54
- SCOPE_TYPES = (TWISTED_SCOPE_TYPES + %i(module def)).freeze
53
+ TWISTED_SCOPE_TYPES = %i[block class sclass defs].freeze
54
+ SCOPE_TYPES = (TWISTED_SCOPE_TYPES + %i[module def]).freeze
55
55
 
56
56
  SEND_TYPE = :send
57
57
 
@@ -376,14 +376,14 @@ module RuboCop
376
376
  end
377
377
 
378
378
  # Hooks invoked by VariableTable.
379
- %i(
379
+ %i[
380
380
  before_entering_scope
381
381
  after_entering_scope
382
382
  before_leaving_scope
383
383
  after_leaving_scope
384
384
  before_declaring_variable
385
385
  after_declaring_variable
386
- ).each do |hook|
386
+ ].each do |hook|
387
387
  define_method(hook) do |arg|
388
388
  # Invoke hook in cops.
389
389
  run_hook(hook, arg, variable_table)
@@ -83,7 +83,7 @@ module RuboCop
83
83
  end
84
84
 
85
85
  def method_argument?
86
- argument? && %i(def defs).include?(@scope.node.type)
86
+ argument? && %i[def defs].include?(@scope.node.type)
87
87
  end
88
88
 
89
89
  def block_argument?
@@ -91,7 +91,7 @@ module RuboCop
91
91
  end
92
92
 
93
93
  def keyword_argument?
94
- %i(kwarg kwoptarg).include?(@declaration_node.type)
94
+ %i[kwarg kwoptarg].include?(@declaration_node.type)
95
95
  end
96
96
 
97
97
  def explicit_block_local_variable?