rubocop 0.91.0 → 0.91.1

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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +9 -1
  4. data/lib/rubocop.rb +1 -1
  5. data/lib/rubocop/comment_config.rb +9 -5
  6. data/lib/rubocop/cop/correctors/line_break_corrector.rb +1 -1
  7. data/lib/rubocop/cop/layout/case_indentation.rb +4 -7
  8. data/lib/rubocop/cop/layout/class_structure.rb +1 -1
  9. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +2 -2
  10. data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +4 -13
  11. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +14 -8
  12. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +1 -1
  13. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +1 -2
  14. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +10 -1
  15. data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +2 -2
  16. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +7 -7
  17. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +4 -18
  18. data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +2 -2
  19. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +2 -2
  20. data/lib/rubocop/cop/lint/constant_definition_in_block.rb +23 -3
  21. data/lib/rubocop/cop/lint/duplicate_rescue_exception.rb +2 -4
  22. data/lib/rubocop/cop/lint/identity_comparison.rb +5 -3
  23. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +2 -5
  24. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +22 -12
  25. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +14 -4
  26. data/lib/rubocop/cop/lint/rescue_type.rb +0 -1
  27. data/lib/rubocop/cop/lint/shadowed_exception.rb +6 -6
  28. data/lib/rubocop/cop/lint/unreachable_loop.rb +1 -5
  29. data/lib/rubocop/cop/lint/useless_access_modifier.rb +3 -9
  30. data/lib/rubocop/cop/lint/useless_times.rb +11 -2
  31. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +25 -16
  32. data/lib/rubocop/cop/mixin/configurable_numbering.rb +3 -3
  33. data/lib/rubocop/cop/mixin/rescue_node.rb +1 -0
  34. data/lib/rubocop/cop/mixin/statement_modifier.rb +9 -3
  35. data/lib/rubocop/cop/mixin/visibility_help.rb +4 -16
  36. data/lib/rubocop/cop/style/combinable_loops.rb +5 -10
  37. data/lib/rubocop/cop/style/commented_keyword.rb +7 -8
  38. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +15 -6
  39. data/lib/rubocop/cop/style/if_unless_modifier.rb +0 -4
  40. data/lib/rubocop/cop/style/keyword_parameters_order.rb +1 -6
  41. data/lib/rubocop/cop/style/multiline_block_chain.rb +2 -2
  42. data/lib/rubocop/cop/style/multiline_when_then.rb +1 -0
  43. data/lib/rubocop/cop/style/one_line_conditional.rb +3 -1
  44. data/lib/rubocop/cop/style/optional_boolean_parameter.rb +3 -0
  45. data/lib/rubocop/cop/style/random_with_offset.rb +3 -3
  46. data/lib/rubocop/cop/style/redundant_assignment.rb +1 -9
  47. data/lib/rubocop/cop/style/redundant_conditional.rb +4 -5
  48. data/lib/rubocop/cop/style/redundant_parentheses.rb +2 -3
  49. data/lib/rubocop/cop/style/redundant_percent_q.rb +9 -11
  50. data/lib/rubocop/cop/style/redundant_return.rb +17 -17
  51. data/lib/rubocop/cop/style/redundant_self.rb +7 -9
  52. data/lib/rubocop/cop/style/redundant_sort.rb +13 -24
  53. data/lib/rubocop/cop/style/redundant_sort_by.rb +5 -9
  54. data/lib/rubocop/cop/style/rescue_standard_error.rb +20 -16
  55. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -2
  56. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +4 -3
  57. data/lib/rubocop/cop/util.rb +0 -1
  58. data/lib/rubocop/directive_comment.rb +32 -0
  59. data/lib/rubocop/version.rb +1 -1
  60. metadata +3 -3
  61. data/lib/rubocop/cop/tokens_util.rb +0 -84
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e27cb6b7c6fcded0825904076fe0d1f5bdc7f3dd6d7391e1b3b09900f276eda
4
- data.tar.gz: df22bf3745be7f53ec2c96a0c00f9d467bed247123d929a19938bb15b62b4a1c
3
+ metadata.gz: a3c2093a4cd4b9f214ecef0ecf755abf1fcdcef137aaf5cd2c088537cfa3a7e6
4
+ data.tar.gz: e470d985cba7af81cfae61f82b5cc52fde7b8e1bceb1993af84db21bb370b592
5
5
  SHA512:
6
- metadata.gz: 29e908f8706eedf177e93d909e744f310a57cfdbfb75d1071b4cddfeb3bd4e480ca7d654ec442ceac848b917cc75eebc500321740f8e68c59356e3b99a349b00
7
- data.tar.gz: 4857c9ba3dec5f0c163e63101d630a543ba8a3d3b6a2d2b6237dca2e0072fbc6885222130957617ade1ae98f9a0e2ca624164f10d3fd146aa96270c777dbfc03
6
+ metadata.gz: bb916e735bfbdc7063f730d0a0407a3bb3037b2ccb1c0166b73fdc08e887f47f45aa95ab02bd2540404868c3afa48e77b3a2efaa0c93333fc61a6ae12c4ba275
7
+ data.tar.gz: b70b264424f19e87a194bbfe370c368806b398be3b6efba1f420ae980d3c0ac1c50d3fd736571bd1933aaa38d81b083a47abb7c10167d972667b2234ec3dba84
data/README.md CHANGED
@@ -49,7 +49,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
49
49
  might want to use a conservative version lock in your `Gemfile`:
50
50
 
51
51
  ```rb
52
- gem 'rubocop', '~> 0.91.0', require: false
52
+ gem 'rubocop', '~> 0.91.1', require: false
53
53
  ```
54
54
 
55
55
  ## Quickstart
@@ -3283,11 +3283,16 @@ Style/IpAddresses:
3283
3283
  Description: "Don't include literal IP addresses in code."
3284
3284
  Enabled: false
3285
3285
  VersionAdded: '0.58'
3286
- VersionChanged: '0.77'
3286
+ VersionChanged: '0.91'
3287
3287
  # Allow addresses to be permitted
3288
3288
  AllowedAddresses:
3289
3289
  - "::"
3290
3290
  # :: is a valid IPv6 address, but could potentially be legitimately in code
3291
+ Exclude:
3292
+ - '**/*.gemfile'
3293
+ - '**/Gemfile'
3294
+ - '**/gems.rb'
3295
+ - '**/*.gemspec'
3291
3296
 
3292
3297
  Style/KeywordParametersOrder:
3293
3298
  Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
@@ -3988,6 +3993,8 @@ Style/SafeNavigation:
3988
3993
  This cop transforms usages of a method call safeguarded by
3989
3994
  a check for the existence of the object to
3990
3995
  safe navigation (`&.`).
3996
+ Auto-correction is unsafe as it assumes the object will
3997
+ be `nil` or truthy, but never `false`.
3991
3998
  Enabled: true
3992
3999
  VersionAdded: '0.43'
3993
4000
  VersionChanged: '0.77'
@@ -4000,6 +4007,7 @@ Style/SafeNavigation:
4000
4007
  - presence
4001
4008
  - try
4002
4009
  - try!
4010
+ SafeAutoCorrect: false
4003
4011
 
4004
4012
  Style/Sample:
4005
4013
  Description: >-
@@ -25,7 +25,6 @@ require_relative 'rubocop/string_interpreter'
25
25
  require_relative 'rubocop/error'
26
26
  require_relative 'rubocop/warning'
27
27
 
28
- require_relative 'rubocop/cop/tokens_util'
29
28
  require_relative 'rubocop/cop/util'
30
29
  require_relative 'rubocop/cop/offense'
31
30
  require_relative 'rubocop/cop/message_annotator'
@@ -615,6 +614,7 @@ require_relative 'rubocop/config_obsoletion'
615
614
  require_relative 'rubocop/config_store'
616
615
  require_relative 'rubocop/config_validator'
617
616
  require_relative 'rubocop/target_finder'
617
+ require_relative 'rubocop/directive_comment'
618
618
  require_relative 'rubocop/comment_config'
619
619
  require_relative 'rubocop/magic_comment'
620
620
  require_relative 'rubocop/result_cache'
@@ -41,12 +41,15 @@ module RuboCop
41
41
  end
42
42
 
43
43
  def extra_enabled_comments
44
- extra_enabled_comments_with_names([], {})
44
+ extra_enabled_comments_with_names(
45
+ extras: Hash.new { |h, k| h[k] = [] },
46
+ names: Hash.new(0)
47
+ )
45
48
  end
46
49
 
47
50
  private
48
51
 
49
- def extra_enabled_comments_with_names(extras, names)
52
+ def extra_enabled_comments_with_names(extras:, names:)
50
53
  each_directive do |comment, cop_names, disabled|
51
54
  next unless comment_only_line?(comment.loc.expression.line)
52
55
 
@@ -190,18 +193,19 @@ module RuboCop
190
193
  enabled_cops += 1
191
194
  end
192
195
 
193
- extras << [comment, 'all'] if enabled_cops.zero?
196
+ extras[comment] << 'all' if enabled_cops.zero?
194
197
  end
195
198
 
199
+ # Collect cops that have been disabled or enabled by name in a directive comment
200
+ # so that `Lint/RedundantCopEnableDirective` can register offenses correctly.
196
201
  def handle_switch(cop_names, names, disabled, extras, comment)
197
202
  cop_names.each do |name|
198
- names[name] ||= 0
199
203
  if disabled
200
204
  names[name] += 1
201
205
  elsif (names[name]).positive?
202
206
  names[name] -= 1
203
207
  else
204
- extras << [comment, name]
208
+ extras[comment] << name
205
209
  end
206
210
  end
207
211
  end
@@ -53,7 +53,7 @@ module RuboCop
53
53
 
54
54
  def semicolon(node)
55
55
  @semicolon ||= {}
56
- @semicolon[node.object_id] ||= tokens(node).find(&:semicolon?)
56
+ @semicolon[node.object_id] ||= processed_source.tokens_within(node).find(&:semicolon?)
57
57
  end
58
58
  end
59
59
  end
@@ -105,7 +105,10 @@ module RuboCop
105
105
  end
106
106
 
107
107
  def incorrect_style(when_node)
108
- add_offense(when_node.loc.keyword) do |corrector|
108
+ depth = indent_one_step? ? 'one step more than' : 'as deep as'
109
+ message = format(MSG, depth: depth, base: style)
110
+
111
+ add_offense(when_node.loc.keyword, message: message) do |corrector|
109
112
  detect_incorrect_style(when_node)
110
113
 
111
114
  whitespace = whitespace_range(when_node)
@@ -125,12 +128,6 @@ module RuboCop
125
128
  end
126
129
  end
127
130
 
128
- def find_message(*)
129
- depth = indent_one_step? ? 'one step more than' : 'as deep as'
130
-
131
- format(MSG, depth: depth, base: style)
132
- end
133
-
134
131
  def base_column(case_node, base)
135
132
  case base
136
133
  when :case then case_node.location.keyword.column
@@ -169,7 +169,7 @@ module RuboCop
169
169
  # Autocorrect by swapping between two nodes autocorrecting them
170
170
  def autocorrect(corrector, node)
171
171
  node_classification = classify(node)
172
- previous = left_siblings_of(node).find do |sibling|
172
+ previous = node.left_siblings.find do |sibling|
173
173
  classification = classify(sibling)
174
174
  !ignore?(classification) && node_classification != classification
175
175
  end
@@ -95,7 +95,7 @@ module RuboCop
95
95
  end
96
96
 
97
97
  def next_sibling_parent_empty_or_else?(node)
98
- next_sibling = node.parent.children[node.sibling_index + 1]
98
+ next_sibling = node.right_sibling
99
99
  return true if next_sibling.nil?
100
100
 
101
101
  parent = next_sibling.parent
@@ -104,7 +104,7 @@ module RuboCop
104
104
  end
105
105
 
106
106
  def next_sibling_empty_or_guard_clause?(node)
107
- next_sibling = node.parent.children[node.sibling_index + 1]
107
+ next_sibling = node.right_sibling
108
108
  return true if next_sibling.nil?
109
109
 
110
110
  next_sibling.if_type? && contains_guard_clause?(next_sibling)
@@ -53,7 +53,6 @@ module RuboCop
53
53
  #
54
54
  class EmptyLineAfterMultilineCondition < Base
55
55
  include RangeHelp
56
- include RescueNode
57
56
  extend AutoCorrector
58
57
 
59
58
  MSG = 'Use empty line after multiline condition.'
@@ -62,7 +61,7 @@ module RuboCop
62
61
  return if node.ternary?
63
62
 
64
63
  if node.modifier_form?
65
- check_condition(node.condition) if right_sibling(node)
64
+ check_condition(node.condition) if node.right_sibling
66
65
  else
67
66
  check_condition(node.condition)
68
67
  end
@@ -74,7 +73,7 @@ module RuboCop
74
73
  alias on_until on_while
75
74
 
76
75
  def on_while_post(node)
77
- return unless right_sibling(node)
76
+ return unless node.right_sibling
78
77
 
79
78
  check_condition(node.condition)
80
79
  end
@@ -92,10 +91,8 @@ module RuboCop
92
91
  end
93
92
 
94
93
  def on_rescue(node)
95
- _body, *resbodies, _else = *node
96
-
97
- resbodies.each do |resbody|
98
- rescued_exceptions = rescued_exceptions(resbody)
94
+ node.resbody_branches.each do |resbody|
95
+ rescued_exceptions = resbody.exceptions
99
96
  next if !multiline_rescue_exceptions?(rescued_exceptions) ||
100
97
  next_line_empty?(rescued_exceptions.last.last_line)
101
98
 
@@ -116,12 +113,6 @@ module RuboCop
116
113
  processed_source[line].blank?
117
114
  end
118
115
 
119
- def right_sibling(node)
120
- return unless node.parent
121
-
122
- node.parent.children[node.sibling_index + 1]
123
- end
124
-
125
116
  def multiline_when_condition?(when_node)
126
117
  when_node.conditions.first.first_line != when_node.conditions.last.last_line
127
118
  end
@@ -84,14 +84,7 @@ module RuboCop
84
84
  end
85
85
 
86
86
  def on_send(node)
87
- return unless node.bare_access_modifier?
88
-
89
- case style
90
- when :around
91
- return if empty_lines_around?(node)
92
- when :only_before
93
- return if allowed_only_before_style?(node)
94
- end
87
+ return unless register_offense?(node)
95
88
 
96
89
  message = message(node)
97
90
  add_offense(node, message: message) do |corrector|
@@ -105,6 +98,19 @@ module RuboCop
105
98
 
106
99
  private
107
100
 
101
+ def register_offense?(node)
102
+ return false unless node.bare_access_modifier? && !node.parent.block_type?
103
+
104
+ case style
105
+ when :around
106
+ return false if empty_lines_around?(node)
107
+ when :only_before
108
+ return false if allowed_only_before_style?(node)
109
+ end
110
+
111
+ true
112
+ end
113
+
108
114
  def allowed_only_before_style?(node)
109
115
  if node.special_modifier?
110
116
  return true if processed_source[node.last_line] == 'end'
@@ -96,7 +96,7 @@ module RuboCop
96
96
  def next_line_node(node)
97
97
  return if node.parent.if_type?
98
98
 
99
- node.parent.children[node.sibling_index + 1]
99
+ node.right_sibling
100
100
  end
101
101
 
102
102
  def allow_alias?(node)
@@ -113,10 +113,9 @@ module RuboCop
113
113
  end
114
114
 
115
115
  def keyword_locations_in_rescue(node)
116
- _begin_body, *resbodies, _else_body = *node
117
116
  [
118
117
  node.loc.else,
119
- *resbodies.map { |body| body.loc.keyword }
118
+ *node.resbody_branches.map { |body| body.loc.keyword }
120
119
  ].compact
121
120
  end
122
121
 
@@ -191,7 +191,16 @@ module RuboCop
191
191
  end
192
192
 
193
193
  def begin_end_alignment_style
194
- config.for_cop('Layout/BeginEndAlignment')['EnforcedStyleAlignWith']
194
+ # FIXME: Workaround for pending status for `Layout/BeginEndAlignment` cop
195
+ # When RuboCop 1.0 is released, please replace it with the following condition.
196
+ #
197
+ # config.for_cop('Layout/BeginEndAlignment')['Enabled'] &&
198
+ # config.for_cop('Layout/BeginEndAlignment')['EnforcedStyleAlignWith']
199
+ if config.for_all_cops['NewCops'] == 'enable' ||
200
+ config.for_cop('Layout/BeginEndAlignment')['Enabled'] &&
201
+ config.for_cop('Layout/BeginEndAlignment')['Enabled'] != 'pending'
202
+ config.for_cop('Layout/BeginEndAlignment')['EnforcedStyleAlignWith']
203
+ end
195
204
  end
196
205
  end
197
206
  end
@@ -36,8 +36,8 @@ module RuboCop
36
36
  MSG = 'Surrounding space %<type>s in default value assignment.'
37
37
 
38
38
  def on_optarg(node)
39
- index = index_of_first_token(node)
40
- arg, equals, value = processed_source.tokens[index, 3]
39
+ tokens = processed_source.tokens_within(node)
40
+ arg, equals, value = tokens.take(3)
41
41
  check_optarg(arg, equals, value)
42
42
  end
43
43
 
@@ -108,11 +108,11 @@ module RuboCop
108
108
  end
109
109
 
110
110
  def left_array_bracket(node)
111
- tokens(node).find(&:left_array_bracket?)
111
+ processed_source.tokens_within(node).find(&:left_array_bracket?)
112
112
  end
113
113
 
114
114
  def right_array_bracket(node)
115
- tokens(node).reverse.find(&:right_bracket?)
115
+ processed_source.tokens_within(node).reverse.find(&:right_bracket?)
116
116
  end
117
117
 
118
118
  def empty_config
@@ -120,7 +120,7 @@ module RuboCop
120
120
  end
121
121
 
122
122
  def next_to_newline?(node, token)
123
- tokens(node)[index_for(node, token) + 1].line != token.line
123
+ processed_source.tokens_within(node)[index_for(node, token) + 1].line != token.line
124
124
  end
125
125
 
126
126
  def end_has_own_line?(token)
@@ -131,7 +131,7 @@ module RuboCop
131
131
  end
132
132
 
133
133
  def index_for(node, token)
134
- tokens(node).index(token)
134
+ processed_source.tokens_within(node).index(token)
135
135
  end
136
136
 
137
137
  def line_and_column_for(token)
@@ -153,7 +153,7 @@ module RuboCop
153
153
  end
154
154
 
155
155
  def next_to_comment?(node, token)
156
- tokens(node)[index_for(node, token) + 1].comment?
156
+ processed_source.tokens_within(node)[index_for(node, token) + 1].comment?
157
157
  end
158
158
 
159
159
  def compact_offenses(node, left, right, start_ok, end_ok)
@@ -184,9 +184,9 @@ module RuboCop
184
184
  def multi_dimensional_array?(node, token, side: :right)
185
185
  i = index_for(node, token)
186
186
  if side == :right
187
- tokens(node)[i - 1].right_bracket?
187
+ processed_source.tokens_within(node)[i - 1].right_bracket?
188
188
  else
189
- tokens(node)[i + 1].left_array_bracket?
189
+ processed_source.tokens_within(node)[i + 1].left_array_bracket?
190
190
  end
191
191
  end
192
192
 
@@ -72,29 +72,15 @@ module RuboCop
72
72
  MSG = 'Space inside %<problem>s.'
73
73
 
74
74
  def on_hash(node)
75
- tokens = processed_source.tokens
75
+ tokens = processed_source.tokens_within(node)
76
+ return unless tokens.first.left_brace? && tokens.last.right_curly_brace?
76
77
 
77
- hash_literal_with_braces(node) do |begin_index, end_index|
78
- check(tokens[begin_index], tokens[begin_index + 1])
79
- return if begin_index == end_index - 1
80
-
81
- check(tokens[end_index - 1], tokens[end_index])
82
- end
78
+ check(tokens[0], tokens[1])
79
+ check(tokens[-2], tokens[-1]) if tokens.size > 2
83
80
  end
84
81
 
85
82
  private
86
83
 
87
- def hash_literal_with_braces(node)
88
- tokens = processed_source.tokens
89
- begin_index = index_of_first_token(node)
90
- return unless tokens[begin_index].left_brace?
91
-
92
- end_index = index_of_last_token(node)
93
- return unless tokens[end_index].right_curly_brace?
94
-
95
- yield begin_index, end_index
96
- end
97
-
98
84
  def check(token1, token2)
99
85
  # No offense if line break inside.
100
86
  return if token1.line < token2.line
@@ -66,7 +66,7 @@ module RuboCop
66
66
  def on_send(node)
67
67
  return if node.multiline?
68
68
 
69
- tokens = tokens(node)
69
+ tokens = processed_source.tokens_within(node)
70
70
  left_token = left_ref_bracket(node, tokens)
71
71
  return unless left_token
72
72
 
@@ -98,7 +98,7 @@ module RuboCop
98
98
  end
99
99
 
100
100
  def reference_brackets(node)
101
- tokens = tokens(node)
101
+ tokens = processed_source.tokens_within(node)
102
102
  left = left_ref_bracket(node, tokens)
103
103
  [left, closing_bracket(tokens, left)]
104
104
  end
@@ -54,8 +54,8 @@ module RuboCop
54
54
  end
55
55
 
56
56
  def delimiters(begin_node)
57
- left = processed_source.tokens[index_of_first_token(begin_node)]
58
- right = processed_source.tokens[index_of_last_token(begin_node)]
57
+ left = processed_source.first_token_of(begin_node)
58
+ right = processed_source.last_token_of(begin_node)
59
59
  [left, right]
60
60
  end
61
61
  end
@@ -6,8 +6,11 @@ module RuboCop
6
6
  # Do not define constants within a block, since the block's scope does not
7
7
  # isolate or namespace the constant in any way.
8
8
  #
9
- # Define the constant outside of the block instead, or use a variable or
10
- # method if defining the constant in the outer scope would be problematic.
9
+ # If you are trying to define that constant once, define it outside of
10
+ # the block instead, or use a variable or method if defining the constant
11
+ # in the outer scope would be problematic.
12
+ #
13
+ # For meta-programming, use `const_set`.
11
14
  #
12
15
  # @example
13
16
  # # bad
@@ -20,6 +23,14 @@ module RuboCop
20
23
  # class TestRequest; end
21
24
  # end
22
25
  #
26
+ # # bad
27
+ # module M
28
+ # extend ActiveSupport::Concern
29
+ # included do
30
+ # LIST = []
31
+ # end
32
+ # end
33
+ #
23
34
  # # good
24
35
  # task :lint do
25
36
  # files_to_lint = Dir['lib/*.rb']
@@ -28,9 +39,18 @@ module RuboCop
28
39
  # # good
29
40
  # describe 'making a request' do
30
41
  # let(:test_request) { Class.new }
42
+ # # see also `stub_const` for RSpec
43
+ # end
44
+ #
45
+ # # good
46
+ # module M
47
+ # extend ActiveSupport::Concern
48
+ # included do
49
+ # const_set(:LIST, [])
50
+ # end
31
51
  # end
32
52
  class ConstantDefinitionInBlock < Base
33
- MSG = 'Do not define constants within a block.'
53
+ MSG = 'Do not define constants this way within a block.'
34
54
 
35
55
  def_node_matcher :constant_assigned_in_block?, <<~PATTERN
36
56
  ({^block_type? [^begin_type? ^^block_type?]} nil? ...)