rubocop 0.20.1 → 0.21.0

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 (128) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -0
  3. data/README.md +16 -4
  4. data/config/default.yml +37 -10
  5. data/config/enabled.yml +25 -7
  6. data/lib/rubocop.rb +15 -19
  7. data/lib/rubocop/cli.rb +2 -2
  8. data/lib/rubocop/config.rb +40 -3
  9. data/lib/rubocop/config_loader.rb +6 -37
  10. data/lib/rubocop/config_store.rb +0 -1
  11. data/lib/rubocop/cop/commissioner.rb +12 -9
  12. data/lib/rubocop/cop/cop.rb +17 -5
  13. data/lib/rubocop/cop/force.rb +41 -0
  14. data/lib/rubocop/cop/ignored_node.rb +10 -10
  15. data/lib/rubocop/cop/lint/ambiguous_operator.rb +1 -1
  16. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +2 -2
  17. data/lib/rubocop/cop/lint/block_alignment.rb +2 -2
  18. data/lib/rubocop/cop/lint/condition_position.rb +2 -0
  19. data/lib/rubocop/cop/lint/debugger.rb +17 -3
  20. data/lib/rubocop/cop/lint/end_alignment.rb +3 -11
  21. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
  22. data/lib/rubocop/cop/lint/rescue_exception.rb +11 -0
  23. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +4 -6
  24. data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +39 -0
  25. data/lib/rubocop/cop/lint/unused_block_argument.rb +81 -0
  26. data/lib/rubocop/cop/lint/unused_method_argument.rb +52 -0
  27. data/lib/rubocop/cop/lint/useless_assignment.rb +6 -8
  28. data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +6 -0
  29. data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
  30. data/lib/rubocop/cop/lint/void.rb +1 -1
  31. data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +2 -2
  32. data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +7 -3
  33. data/lib/rubocop/cop/mixin/check_assignment.rb +11 -0
  34. data/lib/rubocop/cop/mixin/check_methods.rb +12 -0
  35. data/lib/rubocop/cop/mixin/percent_literal.rb +26 -0
  36. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +2 -2
  37. data/lib/rubocop/cop/mixin/string_help.rb +0 -4
  38. data/lib/rubocop/cop/rails/delegate.rb +109 -0
  39. data/lib/rubocop/cop/style/align_hash.rb +3 -3
  40. data/lib/rubocop/cop/style/class_and_module_children.rb +2 -2
  41. data/lib/rubocop/cop/style/colon_method_call.rb +2 -2
  42. data/lib/rubocop/cop/style/dot_position.rb +1 -1
  43. data/lib/rubocop/cop/style/encoding.rb +44 -16
  44. data/lib/rubocop/cop/style/indentation_width.rb +29 -19
  45. data/lib/rubocop/cop/style/lambda_call.rb +1 -1
  46. data/lib/rubocop/cop/style/line_end_concatenation.rb +1 -1
  47. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +3 -21
  48. data/lib/rubocop/cop/style/predicate_name.rb +1 -1
  49. data/lib/rubocop/cop/style/raise_args.rb +1 -1
  50. data/lib/rubocop/cop/style/redundant_begin.rb +18 -2
  51. data/lib/rubocop/cop/style/redundant_self.rb +2 -2
  52. data/lib/rubocop/cop/style/regexp_literal.rb +29 -37
  53. data/lib/rubocop/cop/style/space_after_method_name.rb +1 -1
  54. data/lib/rubocop/cop/style/string_literals.rb +1 -1
  55. data/lib/rubocop/cop/style/trailing_blank_lines.rb +37 -23
  56. data/lib/rubocop/cop/style/trailing_comma.rb +2 -3
  57. data/lib/rubocop/cop/style/trivial_accessors.rb +40 -4
  58. data/lib/rubocop/cop/style/unneeded_capital_w.rb +29 -0
  59. data/lib/rubocop/cop/team.rb +10 -2
  60. data/lib/rubocop/cop/util.rb +2 -2
  61. data/lib/rubocop/cop/{variable_inspector.rb → variable_force.rb} +45 -37
  62. data/lib/rubocop/cop/{variable_inspector → variable_force}/assignment.rb +1 -1
  63. data/lib/rubocop/cop/{variable_inspector → variable_force}/locatable.rb +1 -1
  64. data/lib/rubocop/cop/{variable_inspector → variable_force}/reference.rb +13 -1
  65. data/lib/rubocop/cop/{variable_inspector → variable_force}/scope.rb +9 -1
  66. data/lib/rubocop/cop/{variable_inspector → variable_force}/variable.rb +14 -4
  67. data/lib/rubocop/cop/{variable_inspector → variable_force}/variable_table.rb +1 -1
  68. data/lib/rubocop/file_inspector.rb +3 -1
  69. data/lib/rubocop/formatter/base_formatter.rb +1 -1
  70. data/lib/rubocop/formatter/disabled_config_formatter.rb +2 -2
  71. data/lib/rubocop/formatter/disabled_lines_formatter.rb +2 -2
  72. data/lib/rubocop/formatter/offense_count_formatter.rb +11 -10
  73. data/lib/rubocop/formatter/progress_formatter.rb +2 -2
  74. data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
  75. data/lib/rubocop/options.rb +74 -58
  76. data/lib/rubocop/path_util.rb +17 -2
  77. data/lib/rubocop/rake_task.rb +23 -5
  78. data/lib/rubocop/version.rb +1 -1
  79. data/relnotes/v0.21.0.md +45 -0
  80. data/rubocop-todo.yml +6 -6
  81. data/rubocop.gemspec +1 -1
  82. data/spec/rubocop/cli_spec.rb +170 -59
  83. data/spec/rubocop/config_spec.rb +48 -3
  84. data/spec/rubocop/config_store_spec.rb +3 -3
  85. data/spec/rubocop/cop/commissioner_spec.rb +9 -7
  86. data/spec/rubocop/cop/cop_spec.rb +0 -2
  87. data/spec/rubocop/cop/force_spec.rb +29 -0
  88. data/spec/rubocop/cop/lint/ambiguous_operator_spec.rb +2 -2
  89. data/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb +1 -1
  90. data/spec/rubocop/cop/lint/block_alignment_spec.rb +24 -24
  91. data/spec/rubocop/cop/lint/condition_position_spec.rb +7 -5
  92. data/spec/rubocop/cop/lint/debugger_spec.rb +26 -9
  93. data/spec/rubocop/cop/lint/end_alignment_spec.rb +6 -3
  94. data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +7 -6
  95. data/spec/rubocop/cop/lint/rescue_exception_spec.rb +36 -0
  96. data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +4 -4
  97. data/spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb +179 -0
  98. data/spec/rubocop/cop/lint/unused_block_argument_spec.rb +147 -0
  99. data/spec/rubocop/cop/lint/unused_method_argument_spec.rb +140 -0
  100. data/spec/rubocop/cop/lint/useless_assignment_spec.rb +50 -48
  101. data/spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb +1 -1
  102. data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +2 -0
  103. data/spec/rubocop/cop/rails/delegate_spec.rb +152 -0
  104. data/spec/rubocop/cop/style/encoding_spec.rb +131 -36
  105. data/spec/rubocop/cop/style/indentation_width_spec.rb +79 -0
  106. data/spec/rubocop/cop/style/redundant_begin_spec.rb +32 -0
  107. data/spec/rubocop/cop/style/regexp_literal_spec.rb +83 -13
  108. data/spec/rubocop/cop/style/string_literals_spec.rb +9 -3
  109. data/spec/rubocop/cop/style/trailing_blank_lines_spec.rb +65 -25
  110. data/spec/rubocop/cop/style/trivial_accessors_spec.rb +76 -0
  111. data/spec/rubocop/cop/style/unneeded_capital_w_spec.rb +85 -0
  112. data/spec/rubocop/cop/team_spec.rb +43 -0
  113. data/spec/rubocop/cop/{variable_inspector → variable_force}/assignment_spec.rb +3 -3
  114. data/spec/rubocop/cop/{variable_inspector → variable_force}/locatable_spec.rb +3 -3
  115. data/spec/rubocop/cop/{variable_inspector → variable_force}/scope_spec.rb +30 -2
  116. data/spec/rubocop/cop/{variable_inspector → variable_force}/variable_spec.rb +12 -27
  117. data/spec/rubocop/cop/{variable_inspector → variable_force}/variable_table_spec.rb +1 -1
  118. data/spec/rubocop/cop/{variable_inspector_spec.rb → variable_force_spec.rb} +4 -8
  119. data/spec/rubocop/formatter/base_formatter_spec.rb +2 -2
  120. data/spec/rubocop/formatter/offense_count_formatter_spec.rb +1 -1
  121. data/spec/rubocop/formatter/progress_formatter_spec.rb +1 -1
  122. data/spec/rubocop/options_spec.rb +2 -2
  123. data/spec/rubocop/path_util_spec.rb +47 -14
  124. data/spec/spec_helper.rb +9 -3
  125. data/spec/support/file_helper.rb +2 -0
  126. metadata +43 -26
  127. data/lib/rubocop/cop/style/final_newline.rb +0 -29
  128. data/spec/rubocop/cop/style/final_newline_spec.rb +0 -30
@@ -0,0 +1,140 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Rubocop::Cop::Lint::UnusedMethodArgument do
6
+ subject(:cop) { described_class.new }
7
+
8
+ before do
9
+ inspect_source(cop, source)
10
+ end
11
+
12
+ context 'when a method takes multiple arguments' do
13
+ context 'and an argument is unused' do
14
+ let(:source) { <<-END }
15
+ def some_method(foo, bar)
16
+ puts bar
17
+ end
18
+ END
19
+
20
+ it 'registers an offense' do
21
+ expect(cop.offenses.size).to eq(1)
22
+ expect(cop.offenses.first.message).to eq(
23
+ 'Unused method argument - `foo`. ' \
24
+ "If it's necessary, use `_` or `_foo` " \
25
+ "as an argument name to indicate that it won't be used."
26
+ )
27
+ expect(cop.offenses.first.severity.name).to eq(:warning)
28
+ expect(cop.offenses.first.line).to eq(1)
29
+ expect(cop.highlights).to eq(['foo'])
30
+ end
31
+ end
32
+
33
+ context 'and all the arguments are unused' do
34
+ let(:source) { <<-END }
35
+ def some_method(foo, bar)
36
+ end
37
+ END
38
+
39
+ it 'registers offenses and suggests the use of `*`' do
40
+ expect(cop.offenses.size).to eq(2)
41
+ expect(cop.offenses.first.message).to eq(
42
+ 'Unused method argument - `foo`. ' \
43
+ "If it's necessary, use `_` or `_foo` " \
44
+ "as an argument name to indicate that it won't be used. " \
45
+ 'You can also write as `some_method(*)` if you want the method ' \
46
+ "to accept any arguments but don't care about them.")
47
+ end
48
+ end
49
+ end
50
+
51
+ context 'when a singleton method argument is unused' do
52
+ let(:source) { <<-END }
53
+ def self.some_method(foo)
54
+ end
55
+ END
56
+
57
+ it 'registers an offense' do
58
+ expect(cop.offenses.size).to eq(1)
59
+ expect(cop.offenses.first.line).to eq(1)
60
+ expect(cop.highlights).to eq(['foo'])
61
+ end
62
+ end
63
+
64
+ context 'when an underscore-prefixed method argument is unused' do
65
+ let(:source) { <<-END }
66
+ def some_method(_foo)
67
+ end
68
+ END
69
+
70
+ it 'accepts' do
71
+ expect(cop.offenses).to be_empty
72
+ end
73
+ end
74
+
75
+ context 'when a method argument is used' do
76
+ let(:source) { <<-END }
77
+ def some_method(foo)
78
+ puts foo
79
+ end
80
+ END
81
+
82
+ it 'accepts' do
83
+ expect(cop.offenses).to be_empty
84
+ end
85
+ end
86
+
87
+ context 'when a variable is unused' do
88
+ let(:source) { <<-END }
89
+ def some_method
90
+ foo = 1
91
+ end
92
+ END
93
+
94
+ it 'does not care' do
95
+ expect(cop.offenses).to be_empty
96
+ end
97
+ end
98
+
99
+ context 'when a block argument is unused' do
100
+ let(:source) { <<-END }
101
+ 1.times do |foo|
102
+ end
103
+ END
104
+
105
+ it 'does not care' do
106
+ expect(cop.offenses).to be_empty
107
+ end
108
+ end
109
+
110
+ context 'in a method calling `super` without arguments' do
111
+ context 'when a method argument is not used explicitly' do
112
+ let(:source) { <<-END }
113
+ def some_method(foo)
114
+ super
115
+ end
116
+ END
117
+
118
+ it 'accepts since the arguments are guaranteed to be the same as ' \
119
+ "superclass' ones and the user has no control on them" do
120
+ expect(cop.offenses).to be_empty
121
+ end
122
+ end
123
+ end
124
+
125
+ context 'in a method calling `super` with arguments' do
126
+ context 'when a method argument is unused' do
127
+ let(:source) { <<-END }
128
+ def some_method(foo)
129
+ super(:something)
130
+ end
131
+ END
132
+
133
+ it 'registers an offense' do
134
+ expect(cop.offenses.size).to eq(1)
135
+ expect(cop.offenses.first.line).to eq(1)
136
+ expect(cop.highlights).to eq(['foo'])
137
+ end
138
+ end
139
+ end
140
+ end
@@ -24,7 +24,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
24
24
  inspect_source(cop, source)
25
25
  expect(cop.offenses.size).to eq(1)
26
26
  expect(cop.offenses.first.message)
27
- .to eq('Useless assignment to variable - foo')
27
+ .to eq('Useless assignment to variable - `foo`.')
28
28
  expect(cop.offenses.first.line).to eq(5)
29
29
  expect(cop.highlights).to eq(['foo'])
30
30
  end
@@ -52,7 +52,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
52
52
  inspect_source(cop, source)
53
53
  expect(cop.offenses.size).to eq(1)
54
54
  expect(cop.offenses.first.message)
55
- .to eq('Useless assignment to variable - foo')
55
+ .to eq('Useless assignment to variable - `foo`.')
56
56
  expect(cop.offenses.first.line).to eq(5)
57
57
  expect(cop.highlights).to eq(['foo'])
58
58
  end
@@ -81,7 +81,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
81
81
  inspect_source(cop, source)
82
82
  expect(cop.offenses.size).to eq(1)
83
83
  expect(cop.offenses.first.message)
84
- .to eq('Useless assignment to variable - foo')
84
+ .to eq('Useless assignment to variable - `foo`.')
85
85
  expect(cop.offenses.first.line).to eq(6)
86
86
  expect(cop.highlights).to eq(['foo'])
87
87
  end
@@ -108,7 +108,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
108
108
  inspect_source(cop, source)
109
109
  expect(cop.offenses.size).to eq(1)
110
110
  expect(cop.offenses.first.message)
111
- .to eq('Useless assignment to variable - foo')
111
+ .to eq('Useless assignment to variable - `foo`.')
112
112
  expect(cop.offenses.first.line).to eq(5)
113
113
  expect(cop.highlights).to eq(['foo'])
114
114
  end
@@ -137,7 +137,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
137
137
  inspect_source(cop, source)
138
138
  expect(cop.offenses.size).to eq(1)
139
139
  expect(cop.offenses.first.message)
140
- .to eq('Useless assignment to variable - foo')
140
+ .to eq('Useless assignment to variable - `foo`.')
141
141
  expect(cop.offenses.first.line).to eq(6)
142
142
  expect(cop.highlights).to eq(['foo'])
143
143
  end
@@ -166,7 +166,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
166
166
  inspect_source(cop, source)
167
167
  expect(cop.offenses.size).to eq(1)
168
168
  expect(cop.offenses.first.message)
169
- .to eq('Useless assignment to variable - foo')
169
+ .to eq('Useless assignment to variable - `foo`.')
170
170
  expect(cop.offenses.first.line).to eq(6)
171
171
  expect(cop.highlights).to eq(['foo'])
172
172
  end
@@ -193,7 +193,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
193
193
  inspect_source(cop, source)
194
194
  expect(cop.offenses.size).to eq(1)
195
195
  expect(cop.offenses.first.message)
196
- .to eq('Useless assignment to variable - foo')
196
+ .to eq('Useless assignment to variable - `foo`.')
197
197
  expect(cop.offenses.first.line).to eq(5)
198
198
  expect(cop.highlights).to eq(['foo'])
199
199
  end
@@ -214,7 +214,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
214
214
  inspect_source(cop, source)
215
215
  expect(cop.offenses.size).to eq(1)
216
216
  expect(cop.offenses.first.message)
217
- .to eq('Useless assignment to variable - foo')
217
+ .to eq('Useless assignment to variable - `foo`.')
218
218
  expect(cop.offenses.first.line).to eq(1)
219
219
  expect(cop.highlights).to eq(['foo'])
220
220
  end
@@ -233,8 +233,9 @@ describe Rubocop::Cop::Lint::UselessAssignment do
233
233
  it 'registers an offense' do
234
234
  inspect_source(cop, source)
235
235
  expect(cop.offenses.size).to eq(1)
236
- expect(cop.offenses.first.message)
237
- .to eq('Useless assignment to variable - foo. Use just operator ||.')
236
+ expect(cop.offenses.first.message).to eq(
237
+ 'Useless assignment to variable - `foo`. Use just operator `||`.'
238
+ )
238
239
  expect(cop.offenses.first.line).to eq(1)
239
240
  expect(cop.highlights).to eq(['foo'])
240
241
  end
@@ -258,11 +259,11 @@ describe Rubocop::Cop::Lint::UselessAssignment do
258
259
  expect(cop.offenses.size).to eq(2)
259
260
 
260
261
  expect(cop.offenses[0].message)
261
- .to eq('Useless assignment to variable - foo')
262
+ .to eq('Useless assignment to variable - `foo`.')
262
263
  expect(cop.offenses[0].line).to eq(2)
263
264
 
264
265
  expect(cop.offenses[1].message)
265
- .to eq('Useless assignment to variable - foo')
266
+ .to eq('Useless assignment to variable - `foo`.')
266
267
  expect(cop.offenses[1].line).to eq(4)
267
268
 
268
269
  expect(cop.highlights).to eq(%w(foo foo))
@@ -285,7 +286,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
285
286
  inspect_source(cop, source)
286
287
  expect(cop.offenses.size).to eq(1)
287
288
  expect(cop.offenses.first.message)
288
- .to eq('Useless assignment to variable - foo')
289
+ .to eq('Useless assignment to variable - `foo`.')
289
290
  expect(cop.offenses.first.line).to eq(4)
290
291
  expect(cop.highlights).to eq(['foo'])
291
292
  end
@@ -307,7 +308,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
307
308
  inspect_source(cop, source)
308
309
  expect(cop.offenses.size).to eq(1)
309
310
  expect(cop.offenses.first.message)
310
- .to eq('Useless assignment to variable - foo')
311
+ .to eq('Useless assignment to variable - `foo`.')
311
312
  expect(cop.offenses.first.line).to eq(2)
312
313
  expect(cop.highlights).to eq(['foo'])
313
314
  end
@@ -366,7 +367,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
366
367
  inspect_source(cop, source)
367
368
  expect(cop.offenses.size).to eq(1)
368
369
  expect(cop.offenses.first.message)
369
- .to eq('Useless assignment to variable - foo')
370
+ .to eq('Useless assignment to variable - `foo`.')
370
371
  expect(cop.offenses.first.line).to eq(1)
371
372
  expect(cop.highlights).to eq(['foo'])
372
373
  end
@@ -387,7 +388,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
387
388
  inspect_source(cop, source)
388
389
  expect(cop.offenses.size).to eq(1)
389
390
  expect(cop.offenses.first.message)
390
- .to eq('Useless assignment to variable - foo')
391
+ .to eq('Useless assignment to variable - `foo`.')
391
392
  expect(cop.offenses.first.line).to eq(2)
392
393
  expect(cop.highlights).to eq(['foo'])
393
394
  end
@@ -408,7 +409,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
408
409
  inspect_source(cop, source)
409
410
  expect(cop.offenses.size).to eq(1)
410
411
  expect(cop.offenses.first.message)
411
- .to eq('Useless assignment to variable - foo')
412
+ .to eq('Useless assignment to variable - `foo`.')
412
413
  expect(cop.offenses.first.line).to eq(3)
413
414
  expect(cop.highlights).to eq(['foo'])
414
415
  end
@@ -497,13 +498,14 @@ describe Rubocop::Cop::Lint::UselessAssignment do
497
498
 
498
499
  it 'registers an offense' do
499
500
  pending 'Requires an advanced logic that checks whether the return ' \
500
- 'value of an operator assignment is used or not.'
501
- inspect_source(cop, source)
502
- expect(cop.offenses.size).to eq(1)
503
- expect(cop.offenses.first.message)
504
- .to eq('Useless assignment to variable - foo')
505
- expect(cop.offenses.first.line).to eq(7)
506
- expect(cop.highlights).to eq(['foo'])
501
+ 'value of an operator assignment is used or not.' do
502
+ inspect_source(cop, source)
503
+ expect(cop.offenses.size).to eq(1)
504
+ expect(cop.offenses.first.message)
505
+ .to eq('Useless assignment to variable - `foo`.')
506
+ expect(cop.offenses.first.line).to eq(7)
507
+ expect(cop.highlights).to eq(['foo'])
508
+ end
507
509
  end
508
510
  end
509
511
 
@@ -525,7 +527,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
525
527
  inspect_source(cop, source)
526
528
  expect(cop.offenses.size).to eq(1)
527
529
  expect(cop.offenses.first.message)
528
- .to eq('Useless assignment to variable - foo')
530
+ .to eq('Useless assignment to variable - `foo`.')
529
531
  expect(cop.offenses.first.line).to eq(5)
530
532
  expect(cop.highlights).to eq(['foo'])
531
533
  end
@@ -550,7 +552,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
550
552
  inspect_source(cop, source)
551
553
  expect(cop.offenses.size).to eq(1)
552
554
  expect(cop.offenses.first.message)
553
- .to eq('Useless assignment to variable - foo')
555
+ .to eq('Useless assignment to variable - `foo`.')
554
556
  expect(cop.offenses.first.line).to eq(6)
555
557
  expect(cop.highlights).to eq(['foo'])
556
558
  end
@@ -572,7 +574,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
572
574
  inspect_source(cop, source)
573
575
  expect(cop.offenses.size).to eq(1)
574
576
  expect(cop.offenses.first.message)
575
- .to eq('Useless assignment to variable - foo')
577
+ .to eq('Useless assignment to variable - `foo`.')
576
578
  expect(cop.offenses.first.line).to eq(3)
577
579
  expect(cop.highlights).to eq(['foo'])
578
580
  end
@@ -599,7 +601,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
599
601
  inspect_source(cop, source)
600
602
  expect(cop.offenses.size).to eq(1)
601
603
  expect(cop.offenses.first.message)
602
- .to eq('Useless assignment to variable - foo')
604
+ .to eq('Useless assignment to variable - `foo`.')
603
605
  expect(cop.offenses.first.line).to eq(3)
604
606
  expect(cop.highlights).to eq(['foo'])
605
607
  end
@@ -664,7 +666,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
664
666
  inspect_source(cop, source)
665
667
  expect(cop.offenses.size).to eq(1)
666
668
  expect(cop.offenses.first.message)
667
- .to eq('Useless assignment to variable - foo')
669
+ .to eq('Useless assignment to variable - `foo`.')
668
670
  expect(cop.offenses.first.line).to eq(2)
669
671
  expect(cop.highlights).to eq(['foo'])
670
672
  end
@@ -689,7 +691,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
689
691
  inspect_source(cop, source)
690
692
  expect(cop.offenses.size).to eq(1)
691
693
  expect(cop.offenses.first.message)
692
- .to eq('Useless assignment to variable - foo')
694
+ .to eq('Useless assignment to variable - `foo`.')
693
695
  expect(cop.offenses.first.line).to eq(3)
694
696
  expect(cop.highlights).to eq(['foo'])
695
697
  end
@@ -726,7 +728,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
726
728
  inspect_source(cop, source)
727
729
  expect(cop.offenses.size).to eq(1)
728
730
  expect(cop.offenses.first.message)
729
- .to eq('Useless assignment to variable - foo')
731
+ .to eq('Useless assignment to variable - `foo`.')
730
732
  expect(cop.offenses.first.line).to eq(2)
731
733
  expect(cop.highlights).to eq(['foo'])
732
734
  end
@@ -763,7 +765,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
763
765
  inspect_source(cop, source)
764
766
  expect(cop.offenses.size).to eq(1)
765
767
  expect(cop.offenses.first.message)
766
- .to eq('Useless assignment to variable - foo')
768
+ .to eq('Useless assignment to variable - `foo`.')
767
769
  expect(cop.offenses.first.line).to eq(2)
768
770
  expect(cop.highlights).to eq(['foo'])
769
771
  end
@@ -850,7 +852,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
850
852
  inspect_source(cop, source)
851
853
  expect(cop.offenses.size).to eq(1)
852
854
  expect(cop.offenses.first.message)
853
- .to eq('Useless assignment to variable - foo')
855
+ .to eq('Useless assignment to variable - `foo`.')
854
856
  expect(cop.offenses.first.line).to eq(3)
855
857
  expect(cop.highlights).to eq(['foo'])
856
858
  end
@@ -885,7 +887,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
885
887
  inspect_source(cop, source)
886
888
  expect(cop.offenses.size).to eq(1)
887
889
  expect(cop.offenses.first.message).to eq(
888
- 'Useless assignment to variable - foo. Use just operator ||.'
890
+ 'Useless assignment to variable - `foo`. Use just operator `||`.'
889
891
  )
890
892
  expect(cop.offenses.first.line).to eq(3)
891
893
  expect(cop.highlights).to eq(['foo'])
@@ -908,7 +910,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
908
910
  inspect_source(cop, source)
909
911
  expect(cop.offenses.size).to eq(1)
910
912
  expect(cop.offenses.first.message)
911
- .to eq('Useless assignment to variable - foo')
913
+ .to eq('Useless assignment to variable - `foo`.')
912
914
  expect(cop.offenses.first.line).to eq(3)
913
915
  expect(cop.highlights).to eq(['foo'])
914
916
  end
@@ -929,8 +931,8 @@ describe Rubocop::Cop::Lint::UselessAssignment do
929
931
  inspect_source(cop, source)
930
932
  expect(cop.offenses.size).to eq(1)
931
933
  expect(cop.offenses.first.message).to eq(
932
- 'Useless assignment to variable - bar. ' \
933
- 'Use _ or _bar as a variable name ' \
934
+ 'Useless assignment to variable - `bar`. ' \
935
+ 'Use `_` or `_bar` as a variable name ' \
934
936
  "to indicate that it won't be used."
935
937
  )
936
938
  expect(cop.offenses.first.line).to eq(2)
@@ -1003,7 +1005,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1003
1005
  inspect_source(cop, source)
1004
1006
  expect(cop.offenses.size).to eq(1)
1005
1007
  expect(cop.offenses.first.message)
1006
- .to eq('Useless assignment to variable - foo')
1008
+ .to eq('Useless assignment to variable - `foo`.')
1007
1009
  expect(cop.offenses.first.line).to eq(3)
1008
1010
  expect(cop.highlights).to eq(['foo'])
1009
1011
  end
@@ -1117,7 +1119,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1117
1119
  inspect_source(cop, source)
1118
1120
  expect(cop.offenses.size).to eq(1)
1119
1121
  expect(cop.offenses.first.message)
1120
- .to eq('Useless assignment to variable - foo')
1122
+ .to eq('Useless assignment to variable - `foo`.')
1121
1123
  expect(cop.offenses.first.line).to eq(6)
1122
1124
  expect(cop.highlights).to eq(['foo'])
1123
1125
  end
@@ -1146,7 +1148,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1146
1148
  inspect_source(cop, source)
1147
1149
  expect(cop.offenses.size).to eq(1)
1148
1150
  expect(cop.offenses.first.message)
1149
- .to eq('Useless assignment to variable - foo')
1151
+ .to eq('Useless assignment to variable - `foo`.')
1150
1152
  expect(cop.offenses.first.line).to eq(6)
1151
1153
  expect(cop.highlights).to eq(['foo'])
1152
1154
  end
@@ -1173,7 +1175,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1173
1175
  inspect_source(cop, source)
1174
1176
  expect(cop.offenses.size).to eq(1)
1175
1177
  expect(cop.offenses.first.message)
1176
- .to eq('Useless assignment to variable - foo')
1178
+ .to eq('Useless assignment to variable - `foo`.')
1177
1179
  expect(cop.offenses.first.line).to eq(6)
1178
1180
  expect(cop.highlights).to eq(['foo'])
1179
1181
  end
@@ -1281,7 +1283,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1281
1283
  inspect_source(cop, source)
1282
1284
  expect(cop.offenses.size).to eq(1)
1283
1285
  expect(cop.offenses.first.message)
1284
- .to eq('Useless assignment to variable - foo')
1286
+ .to eq('Useless assignment to variable - `foo`.')
1285
1287
  expect(cop.offenses.first.line).to eq(2)
1286
1288
  expect(cop.highlights).to eq(['foo'])
1287
1289
  end
@@ -1304,7 +1306,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1304
1306
  inspect_source(cop, source)
1305
1307
  expect(cop.offenses.size).to eq(1)
1306
1308
  expect(cop.offenses.first.message)
1307
- .to eq('Useless assignment to variable - foo')
1309
+ .to eq('Useless assignment to variable - `foo`.')
1308
1310
  expect(cop.offenses.first.line).to eq(2)
1309
1311
  expect(cop.highlights).to eq(['foo'])
1310
1312
  end
@@ -1321,7 +1323,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1321
1323
  inspect_source(cop, source)
1322
1324
  expect(cop.offenses.size).to eq(1)
1323
1325
  expect(cop.offenses.first.message)
1324
- .to eq('Useless assignment to variable - foo')
1326
+ .to eq('Useless assignment to variable - `foo`.')
1325
1327
  expect(cop.offenses.first.line).to eq(1)
1326
1328
  end
1327
1329
 
@@ -1342,7 +1344,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1342
1344
  inspect_source(cop, source)
1343
1345
  expect(cop.offenses.size).to eq(1)
1344
1346
  expect(cop.offenses.first.message)
1345
- .to eq('Useless assignment to variable - foo')
1347
+ .to eq('Useless assignment to variable - `foo`.')
1346
1348
  expect(cop.offenses.first.line).to eq(2)
1347
1349
  expect(cop.highlights).to eq(["/(?<foo>\w+)/"])
1348
1350
  end
@@ -1416,7 +1418,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1416
1418
  inspect_source(cop, source)
1417
1419
  expect(cop.offenses.size).to eq(1)
1418
1420
  expect(cop.offenses.first.message)
1419
- .to eq('Useless assignment to variable - foo')
1421
+ .to eq('Useless assignment to variable - `foo`.')
1420
1422
  expect(cop.offenses.first.line).to eq(2)
1421
1423
  expect(cop.highlights).to eq(['foo'])
1422
1424
  end
@@ -1547,7 +1549,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1547
1549
  inspect_source(cop, source)
1548
1550
  expect(cop.offenses.size).to eq(1)
1549
1551
  expect(cop.offenses.first.message)
1550
- .to eq('Useless assignment to variable - foo')
1552
+ .to eq('Useless assignment to variable - `foo`.')
1551
1553
  expect(cop.offenses.first.line).to eq(1)
1552
1554
  expect(cop.highlights).to eq(['foo'])
1553
1555
  end
@@ -1583,7 +1585,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1583
1585
  inspect_source(cop, source)
1584
1586
  expect(cop.offenses.size).to eq(1)
1585
1587
  expect(cop.offenses.first.message)
1586
- .to eq('Useless assignment to variable - foo')
1588
+ .to eq('Useless assignment to variable - `foo`.')
1587
1589
  expect(cop.offenses.first.line).to eq(1)
1588
1590
  expect(cop.highlights).to eq(['foo'])
1589
1591
  end