rubocop 0.17.0 → 0.18.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +65 -42
  3. data/CONTRIBUTING.md +20 -3
  4. data/config/enabled.yml +10 -0
  5. data/lib/rubocop.rb +7 -0
  6. data/lib/rubocop/cop/cop.rb +4 -13
  7. data/lib/rubocop/cop/lint/ambiguous_operator.rb +1 -1
  8. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +1 -1
  9. data/lib/rubocop/cop/lint/loop.rb +1 -1
  10. data/lib/rubocop/cop/lint/require_parentheses.rb +72 -0
  11. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +1 -1
  12. data/lib/rubocop/cop/style/access_modifier_indentation.rb +3 -1
  13. data/lib/rubocop/cop/style/align_array.rb +1 -1
  14. data/lib/rubocop/cop/style/align_hash.rb +1 -1
  15. data/lib/rubocop/cop/style/align_parameters.rb +1 -1
  16. data/lib/rubocop/cop/style/def_parentheses.rb +1 -1
  17. data/lib/rubocop/cop/style/line_end_concatenation.rb +53 -0
  18. data/lib/rubocop/cop/style/nested_ternary_operator.rb +1 -1
  19. data/lib/rubocop/cop/style/proc.rb +6 -0
  20. data/lib/rubocop/cop/style/regexp_literal.rb +1 -1
  21. data/lib/rubocop/cop/style/space_after_method_name.rb +1 -1
  22. data/lib/rubocop/cop/style/trailing_comma.rb +7 -0
  23. data/lib/rubocop/cop/style/word_array.rb +27 -0
  24. data/lib/rubocop/cop/util.rb +1 -0
  25. data/lib/rubocop/formatter/simple_text_formatter.rb +6 -2
  26. data/lib/rubocop/options.rb +1 -1
  27. data/lib/rubocop/path_util.rb +22 -0
  28. data/lib/rubocop/rake_task.rb +17 -3
  29. data/lib/rubocop/version.rb +1 -1
  30. data/rubocop.gemspec +2 -2
  31. data/spec/project_spec.rb +93 -0
  32. data/spec/rubocop/cli_spec.rb +27 -22
  33. data/spec/rubocop/cop/cop_spec.rb +1 -1
  34. data/spec/rubocop/cop/lint/ambiguous_operator_spec.rb +2 -2
  35. data/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb +1 -1
  36. data/spec/rubocop/cop/lint/block_alignment_spec.rb +5 -5
  37. data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +2 -2
  38. data/spec/rubocop/cop/lint/require_parentheses_spec.rb +82 -0
  39. data/spec/rubocop/cop/lint/rescue_exception_spec.rb +1 -1
  40. data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +9 -9
  41. data/spec/rubocop/cop/lint/useless_assignment_spec.rb +54 -54
  42. data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +6 -6
  43. data/spec/rubocop/cop/style/access_modifier_indentation_spec.rb +49 -8
  44. data/spec/rubocop/cop/style/align_array_spec.rb +1 -1
  45. data/spec/rubocop/cop/style/align_hash_spec.rb +1 -1
  46. data/spec/rubocop/cop/style/align_parameters_spec.rb +2 -2
  47. data/spec/rubocop/cop/style/blocks_spec.rb +1 -1
  48. data/spec/rubocop/cop/style/case_indentation_spec.rb +1 -1
  49. data/spec/rubocop/cop/style/dot_position_spec.rb +1 -1
  50. data/spec/rubocop/cop/style/favor_unless_over_negated_if_spec.rb +2 -2
  51. data/spec/rubocop/cop/style/if_unless_modifier_spec.rb +3 -3
  52. data/spec/rubocop/cop/style/indentation_consistency_spec.rb +4 -4
  53. data/spec/rubocop/cop/style/indentation_width_spec.rb +3 -3
  54. data/spec/rubocop/cop/style/line_end_concatenation_spec.rb +27 -0
  55. data/spec/rubocop/cop/style/multiline_block_chain_spec.rb +1 -1
  56. data/spec/rubocop/cop/style/proc_spec.rb +5 -0
  57. data/spec/rubocop/cop/style/regexp_literal_spec.rb +4 -4
  58. data/spec/rubocop/cop/style/string_literals_spec.rb +7 -7
  59. data/spec/rubocop/cop/style/trailing_comma_spec.rb +27 -6
  60. data/spec/rubocop/cop/style/unless_else_spec.rb +1 -1
  61. data/spec/rubocop/cop/style/variable_interpolation_spec.rb +2 -2
  62. data/spec/rubocop/cop/style/word_array_spec.rb +10 -0
  63. data/spec/rubocop/cop/variable_inspector/variable_table_spec.rb +4 -4
  64. data/spec/rubocop/formatter/disabled_config_formatter_spec.rb +1 -1
  65. data/spec/rubocop/formatter/formatter_set_spec.rb +1 -1
  66. data/spec/rubocop/path_util_spec.rb +42 -0
  67. data/spec/spec_helper.rb +3 -1
  68. metadata +29 -8
@@ -68,16 +68,16 @@ describe Rubocop::CLI, :isolated_environment do
68
68
  '',
69
69
  'Offences:',
70
70
  '',
71
- 'example.rb:2:1: C: [Corrected] Use `fail` instead of ' +
71
+ 'example.rb:2:1: C: [Corrected] Use `fail` instead of ' \
72
72
  '`raise` to signal exceptions.',
73
73
  'raise NotImplementedError,',
74
74
  '^^^^^',
75
- 'example.rb:3:7: C: [Corrected] Align the parameters of a ' +
75
+ 'example.rb:3:7: C: [Corrected] Align the parameters of a ' \
76
76
  'method call if they span more than one line.',
77
77
  " 'Method should be overridden in child classes'",
78
78
  ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^',
79
79
  '',
80
- '1 file inspected, 2 offences detected, 2 offences ' +
80
+ '1 file inspected, 2 offences detected, 2 offences ' \
81
81
  'corrected',
82
82
  ''].join("\n"))
83
83
  end
@@ -108,26 +108,26 @@ describe Rubocop::CLI, :isolated_environment do
108
108
  '',
109
109
  'Offences:',
110
110
  '',
111
- 'example.rb:4:1: C: [Corrected] Trailing whitespace ' +
111
+ 'example.rb:4:1: C: [Corrected] Trailing whitespace ' \
112
112
  'detected.',
113
- 'example.rb:4:1: C: [Corrected] Extra empty line detected ' +
113
+ 'example.rb:4:1: C: [Corrected] Extra empty line detected ' \
114
114
  'at body beginning.',
115
115
  '',
116
- '1 file inspected, 2 offences detected, 2 offences ' +
116
+ '1 file inspected, 2 offences detected, 2 offences ' \
117
117
  'corrected',
118
118
  ''].join("\n"))
119
119
  end
120
120
  end
121
121
 
122
122
  describe '--auto-gen-config' do
123
- it 'exits with error if asked to re-generate a todo list that is in ' +
123
+ it 'exits with error if asked to re-generate a todo list that is in ' \
124
124
  'use' do
125
125
  create_file('example1.rb', ['# encoding: utf-8',
126
126
  'x= 0 ',
127
127
  '#' * 85,
128
128
  'y ',
129
129
  'puts x'])
130
- todo_contents = ['# This configuration was generated with `rubocop' +
130
+ todo_contents = ['# This configuration was generated with `rubocop' \
131
131
  ' --auto-gen-config`',
132
132
  '',
133
133
  'LineLength:',
@@ -137,7 +137,7 @@ describe Rubocop::CLI, :isolated_environment do
137
137
  .to eq(todo_contents.join("\n") + "\n")
138
138
  create_file('.rubocop.yml', ['inherit_from: rubocop-todo.yml'])
139
139
  expect(cli.run(['--auto-gen-config'])).to eq(1)
140
- expect($stderr.string).to eq('Remove rubocop-todo.yml from the ' +
140
+ expect($stderr.string).to eq('Remove rubocop-todo.yml from the ' \
141
141
  'current configuration before ' +
142
142
  "generating it again.\n")
143
143
  end
@@ -150,7 +150,7 @@ describe Rubocop::CLI, :isolated_environment do
150
150
  'puts x'])
151
151
  expect(cli.run(['--auto-gen-config', 'example1.rb'])).to eq(1)
152
152
  expect($stderr.string)
153
- .to eq('--auto-gen-config can not be combined with any other ' +
153
+ .to eq('--auto-gen-config can not be combined with any other ' \
154
154
  "arguments.\n")
155
155
  expect($stdout.string).to eq('')
156
156
  end
@@ -171,7 +171,7 @@ describe Rubocop::CLI, :isolated_environment do
171
171
  .to include([
172
172
  'Created rubocop-todo.yml.',
173
173
  'Run rubocop with --config rubocop-todo.yml, or',
174
- 'add inherit_from: rubocop-todo.yml in a ' +
174
+ 'add inherit_from: rubocop-todo.yml in a ' \
175
175
  '.rubocop.yml file.',
176
176
  ''].join("\n"))
177
177
  expected =
@@ -180,7 +180,7 @@ describe Rubocop::CLI, :isolated_environment do
180
180
  '# The point is for the user to remove these configuration records',
181
181
  '# one by one as the offences are removed from the code base.',
182
182
  '# Note that changes in the inspected code, or installation of new',
183
- '# versions of RuboCop, may require this file to be generated ' +
183
+ '# versions of RuboCop, may require this file to be generated ' \
184
184
  'again.',
185
185
  '',
186
186
  '# Offence count: 1',
@@ -232,7 +232,7 @@ describe Rubocop::CLI, :isolated_environment do
232
232
  'example.rb'])).to eq(1)
233
233
  expect($stdout.string)
234
234
  .to eq(['== example.rb ==',
235
- 'C: 1: 1: Favor modifier if usage when you ' +
235
+ 'C: 1: 1: Favor modifier if usage when you ' \
236
236
  'have a single-line body. Another good alternative is ' +
237
237
  'the usage of control flow &&/||.',
238
238
  '',
@@ -455,7 +455,7 @@ describe Rubocop::CLI, :isolated_environment do
455
455
  'example2.rb', 'example3.rb']))
456
456
  .to eq(1)
457
457
  expect($stdout.string)
458
- .to eq(['example1.rb:2:2: C: Surrounding space missing for ' +
458
+ .to eq(['example1.rb:2:2: C: Surrounding space missing for ' \
459
459
  "operator '='.",
460
460
  'x= 0 ',
461
461
  ' ^',
@@ -463,9 +463,9 @@ describe Rubocop::CLI, :isolated_environment do
463
463
  'x= 0 ',
464
464
  ' ^',
465
465
  'example1.rb:3:80: C: Line is too long. [85/79]',
466
- '###################################################' +
466
+ '###################################################' \
467
467
  '##################################',
468
- ' ' +
468
+ ' ' \
469
469
  ' ^^^^^^',
470
470
  'example1.rb:4:2: C: Trailing whitespace detected.',
471
471
  'y ',
@@ -473,23 +473,23 @@ describe Rubocop::CLI, :isolated_environment do
473
473
  'example2.rb:2:1: C: Tab detected.',
474
474
  "\tx",
475
475
  '^',
476
- 'example2.rb:3:1: C: Inconsistent indentation ' +
476
+ 'example2.rb:3:1: C: Inconsistent indentation ' \
477
477
  'detected.',
478
478
  'def a',
479
479
  '',
480
- 'example2.rb:4:1: C: Use 2 (not 3) spaces for ' +
480
+ 'example2.rb:4:1: C: Use 2 (not 3) spaces for ' \
481
481
  'indentation.',
482
482
  ' puts',
483
483
  '^^^',
484
484
  'example3.rb:2:5: C: Use snake_case for methods.',
485
485
  'def badName',
486
486
  ' ^^^^^^^',
487
- 'example3.rb:3:3: C: Favor modifier if usage ' +
487
+ 'example3.rb:3:3: C: Favor modifier if usage ' \
488
488
  'when you have a single-line body. Another good ' +
489
489
  'alternative is the usage of control flow &&/||.',
490
490
  ' if something',
491
491
  ' ^^',
492
- 'example3.rb:5:5: W: end at 5, 4 is not aligned ' +
492
+ 'example3.rb:5:5: W: end at 5, 4 is not aligned ' \
493
493
  'with if at 3, 2',
494
494
  ' end',
495
495
  ' ^^^',
@@ -906,16 +906,21 @@ describe Rubocop::CLI, :isolated_environment do
906
906
  '# encoding: utf-8',
907
907
  'x = 0'
908
908
  ])
909
+ create_file('dir/thing.rb', [
910
+ '# encoding: utf-8',
911
+ 'x = 0'
912
+ ])
909
913
  create_file('.rubocop.yml', [
910
914
  'UselessAssignment:',
911
915
  ' Exclude:',
912
916
  ' - example.rb',
913
917
  ' - !ruby/regexp /regexp.rb\z/',
914
- ' - "exclude_*"'
918
+ ' - "exclude_*"',
919
+ ' - "dir/*"'
915
920
  ])
916
921
  expect(cli.run(%w(--format simple))).to eq(0)
917
922
  expect($stdout.string)
918
- .to eq(['', '3 files inspected, no offences detected',
923
+ .to eq(['', '4 files inspected, no offences detected',
919
924
  ''].join("\n"))
920
925
  end
921
926
 
@@ -81,7 +81,7 @@ describe Rubocop::Cop::Cop do
81
81
  it('has types') { expect(subject.length).not_to eq(0) }
82
82
  it { should include :lint }
83
83
  it do
84
- pending 'Rails cops are usually removed after CLI start, ' +
84
+ pending 'Rails cops are usually removed after CLI start, ' \
85
85
  'so CLI spec impacts this one'
86
86
  should include :rails
87
87
  end
@@ -22,7 +22,7 @@ describe Rubocop::Cop::Lint::AmbiguousOperator do
22
22
  it 'registers an offence' do
23
23
  expect(cop.offences.size).to eq(1)
24
24
  expect(cop.offences.first.message).to eq(
25
- 'Ambiguous splat operator. ' +
25
+ 'Ambiguous splat operator. ' \
26
26
  "Parenthesize the method arguments if it's surely a splat " +
27
27
  'operator, ' +
28
28
  'or add a whitespace to the right of the * if it should be a ' +
@@ -73,7 +73,7 @@ describe Rubocop::Cop::Lint::AmbiguousOperator do
73
73
  it 'registers an offence' do
74
74
  expect(cop.offences.size).to eq(1)
75
75
  expect(cop.offences.first.message).to eq(
76
- 'Ambiguous block operator. ' +
76
+ 'Ambiguous block operator. ' \
77
77
  "Parenthesize the method arguments if it's surely a block " +
78
78
  'operator, ' +
79
79
  'or add a whitespace to the right of the & if it should be a ' +
@@ -16,7 +16,7 @@ describe Rubocop::Cop::Lint::AmbiguousRegexpLiteral do
16
16
  it 'registers an offence' do
17
17
  expect(cop.offences.size).to eq(1)
18
18
  expect(cop.offences.first.message).to eq(
19
- 'Ambiguous regexp literal. Parenthesize the method arguments ' +
19
+ 'Ambiguous regexp literal. Parenthesize the method arguments ' \
20
20
  "if it's surely a regexp literal, or add a whitespace to the " +
21
21
  'right of the / if it should be a division.'
22
22
  )
@@ -94,7 +94,7 @@ describe Rubocop::Cop::Lint::BlockAlignment do
94
94
  'end'
95
95
  ])
96
96
  expect(cop.messages)
97
- .to eq(['end at 4, 0 is not aligned with a_long_method_that_dont_fit_on_the_line ' +
97
+ .to eq(['end at 4, 0 is not aligned with a_long_method_that_dont_fit_on_the_line ' \
98
98
  'do |v| at 2, 2'])
99
99
  end
100
100
  end
@@ -131,11 +131,11 @@ describe Rubocop::Cop::Lint::BlockAlignment do
131
131
  'end']
132
132
  inspect_source(cop, src)
133
133
  expect(cop.messages)
134
- .to eq(['end at 5, 8 is not aligned with bar.get_stuffs at 2, 2 or' +
134
+ .to eq(['end at 5, 8 is not aligned with bar.get_stuffs at 2, 2 or' \
135
135
  ' .reject do |stuff| at 3, 6',
136
- 'end at 7, 4 is not aligned with bar.get_stuffs at 2, 2 or' +
136
+ 'end at 7, 4 is not aligned with bar.get_stuffs at 2, 2 or' \
137
137
  ' end.select do |stuff| at 5, 8',
138
- 'end at 10, 8 is not aligned with bar.get_stuffs at 2, 2 or' +
138
+ 'end at 10, 8 is not aligned with bar.get_stuffs at 2, 2 or' \
139
139
  ' .select do |stuff| at 8, 6'])
140
140
  end
141
141
 
@@ -325,7 +325,7 @@ describe Rubocop::Cop::Lint::BlockAlignment do
325
325
  ' end)'
326
326
  ])
327
327
  expect(cop.messages)
328
- .to eq(['end at 3, 2 is not aligned with arr.all? do |o| at 1, 7 or ' +
328
+ .to eq(['end at 3, 2 is not aligned with arr.all? do |o| at 1, 7 or ' \
329
329
  'expect(arr.all? do |o| at 1, 0'])
330
330
  end
331
331
 
@@ -5,13 +5,13 @@ require 'spec_helper'
5
5
  describe Rubocop::Cop::Lint::ParenthesesAsGroupedExpression do
6
6
  subject(:cop) { described_class.new }
7
7
 
8
- it 'registers an offence for method call with space before the ' +
8
+ it 'registers an offence for method call with space before the ' \
9
9
  'parenthesis' do
10
10
  inspect_source(cop, ['a.func (x)'])
11
11
  expect(cop.offences.size).to eq(1)
12
12
  end
13
13
 
14
- it 'registers an offence for predicate method call with space ' +
14
+ it 'registers an offence for predicate method call with space ' \
15
15
  'before the parenthesis' do
16
16
  inspect_source(cop, ['is? (x)'])
17
17
  expect(cop.offences.size).to eq(1)
@@ -0,0 +1,82 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Rubocop::Cop::Lint::RequireParentheses do
6
+ subject(:cop) { described_class.new }
7
+
8
+ it 'registers an offence for missing parentheses around expression with ' \
9
+ '&& operator' do
10
+ inspect_source(cop, ["if day.is? 'monday' && month == :jan",
11
+ ' foo',
12
+ 'end'])
13
+ expect(cop.highlights).to eq(["day.is? 'monday' && month == :jan"])
14
+ expect(cop.messages)
15
+ .to eq(['Use parentheses in the method call to avoid confusion about ' \
16
+ 'precedence.'])
17
+ end
18
+
19
+ it 'registers an offence for missing parentheses around expression with ' \
20
+ '|| operator' do
21
+ inspect_source(cop, "day_is? 'tuesday' || true")
22
+ expect(cop.highlights).to eq(["day_is? 'tuesday' || true"])
23
+ end
24
+
25
+ it 'registers an offence for missing parentheses around expression in ' \
26
+ 'ternary' do
27
+ inspect_source(cop, "wd.include? 'tuesday' && true == true ? a : b")
28
+ expect(cop.highlights).to eq(["wd.include? 'tuesday' && true == true"])
29
+ end
30
+
31
+ it 'accepts missing parentheses around expression with + operator' do
32
+ inspect_source(cop, ["if day_is? 'tuesday' + rest",
33
+ 'end'])
34
+ expect(cop.offences).to be_empty
35
+ end
36
+
37
+ it 'accepts method calls without parentheses followed by keyword and/or' do
38
+ inspect_source(cop, ["if day.is? 'tuesday' and month == :jan",
39
+ 'end',
40
+ "if day.is? 'tuesday' or month == :jan",
41
+ 'end'])
42
+ expect(cop.offences).to be_empty
43
+ end
44
+
45
+ it 'accepts method calls that are all operations' do
46
+ inspect_source(cop, ['if current_level == max + 1',
47
+ 'end'])
48
+ expect(cop.offences).to be_empty
49
+ end
50
+
51
+ it 'accepts condition that is not a call' do
52
+ inspect_source(cop, ['if @debug',
53
+ 'end'])
54
+ expect(cop.offences).to be_empty
55
+ end
56
+
57
+ it 'accepts parentheses around expression with boolean operator' do
58
+ inspect_source(cop, ["if day.is?('tuesday' && true == true)",
59
+ 'end'])
60
+ expect(cop.offences).to be_empty
61
+ end
62
+
63
+ it 'accepts method call with parentheses in ternary' do
64
+ inspect_source(cop, "wd.include?('tuesday' && true == true) ? a : b")
65
+ expect(cop.offences).to be_empty
66
+ end
67
+
68
+ it 'accepts missing parentheses when method is not a predicate' do
69
+ inspect_source(cop, "weekdays.foo 'tuesday' && true == true")
70
+ expect(cop.offences).to be_empty
71
+ end
72
+
73
+ it 'accepts calls to methods that are setters' do
74
+ inspect_source(cop, 's.version = @version || ">= 1.8.5"')
75
+ expect(cop.offences).to be_empty
76
+ end
77
+
78
+ it 'accepts calls to methods that are operators' do
79
+ inspect_source(cop, 'a[b || c]')
80
+ expect(cop.offences).to be_empty
81
+ end
82
+ end
@@ -119,7 +119,7 @@ describe Rubocop::Cop::Lint::RescueException do
119
119
  expect(cop.offences).to be_empty
120
120
  end
121
121
 
122
- it 'does not crash when the namespace of a rescued class is in a local ' +
122
+ it 'does not crash when the namespace of a rescued class is in a local ' \
123
123
  'variable' do
124
124
  inspect_source(cop,
125
125
  ['adapter = current_adapter',
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
6
6
  subject(:cop) { described_class.new }
7
7
 
8
- context 'when a block argument has same name ' +
8
+ context 'when a block argument has same name ' \
9
9
  'as an outer scope variable' do
10
10
  let(:source) do
11
11
  [
@@ -29,7 +29,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
29
29
  include_examples 'mimics MRI 2.1'
30
30
  end
31
31
 
32
- context 'when a splat block argument has same name ' +
32
+ context 'when a splat block argument has same name ' \
33
33
  'as an outer scope variable' do
34
34
  let(:source) do
35
35
  [
@@ -53,7 +53,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
53
53
  include_examples 'mimics MRI 2.1'
54
54
  end
55
55
 
56
- context 'when a block block argument has same name ' +
56
+ context 'when a block block argument has same name ' \
57
57
  'as an outer scope variable' do
58
58
  let(:source) do
59
59
  [
@@ -79,7 +79,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
79
79
  include_examples 'mimics MRI 2.1'
80
80
  end
81
81
 
82
- context 'when a block local variable has same name ' +
82
+ context 'when a block local variable has same name ' \
83
83
  'as an outer scope variable' do
84
84
  let(:source) do
85
85
  [
@@ -104,7 +104,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
104
104
  include_examples 'mimics MRI 2.1', 'shadowing'
105
105
  end
106
106
 
107
- context 'when a block argument has different name ' +
107
+ context 'when a block argument has different name ' \
108
108
  'with outer scope variables' do
109
109
  let(:source) do
110
110
  [
@@ -169,7 +169,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
169
169
  include_examples 'mimics MRI 2.1'
170
170
  end
171
171
 
172
- context 'when multiple block arguments have ' +
172
+ context 'when multiple block arguments have ' \
173
173
  'a same name starts with "_"' do
174
174
  let(:source) do
175
175
  [
@@ -184,7 +184,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
184
184
  include_examples 'mimics MRI 2.1'
185
185
  end
186
186
 
187
- context 'when a block argument has same name "_" ' +
187
+ context 'when a block argument has same name "_" ' \
188
188
  'as outer scope variable "_"' do
189
189
  let(:source) do
190
190
  [
@@ -201,7 +201,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
201
201
  include_examples 'mimics MRI 2.1'
202
202
  end
203
203
 
204
- context 'when a block argument has a same name starts with "_" ' +
204
+ context 'when a block argument has a same name starts with "_" ' \
205
205
  'as an outer scope variable' do
206
206
  let(:source) do
207
207
  [
@@ -218,7 +218,7 @@ describe Rubocop::Cop::Lint::ShadowingOuterLocalVariable do
218
218
  include_examples 'mimics MRI 2.1'
219
219
  end
220
220
 
221
- context 'when a method argument has same name ' +
221
+ context 'when a method argument has same name ' \
222
222
  'as an outer scope variable' do
223
223
  let(:source) do
224
224
  [
@@ -32,7 +32,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
32
32
  include_examples 'mimics MRI 2.1'
33
33
  end
34
34
 
35
- context 'when a variable is assigned and unreferenced ' +
35
+ context 'when a variable is assigned and unreferenced ' \
36
36
  'in a singleton method defined with self keyword' do
37
37
  let(:source) do
38
38
  [
@@ -60,7 +60,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
60
60
  include_examples 'mimics MRI 2.1'
61
61
  end
62
62
 
63
- context 'when a variable is assigned and unreferenced ' +
63
+ context 'when a variable is assigned and unreferenced ' \
64
64
  'in a singleton method defined with variable name' do
65
65
  let(:source) do
66
66
  [
@@ -116,7 +116,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
116
116
  include_examples 'mimics MRI 2.1'
117
117
  end
118
118
 
119
- context 'when a variable is assigned and unreferenced in a class ' +
119
+ context 'when a variable is assigned and unreferenced in a class ' \
120
120
  'subclassing another class stored in local variable' do
121
121
  let(:source) do
122
122
  [
@@ -145,7 +145,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
145
145
  include_examples 'mimics MRI 2.1'
146
146
  end
147
147
 
148
- context 'when a variable is assigned and unreferenced ' +
148
+ context 'when a variable is assigned and unreferenced ' \
149
149
  'in a singleton class' do
150
150
  let(:source) do
151
151
  [
@@ -222,7 +222,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
222
222
  include_examples 'mimics MRI 2.1'
223
223
  end
224
224
 
225
- context 'when a variable is assigned with operator assignment ' +
225
+ context 'when a variable is assigned with operator assignment ' \
226
226
  'in top level' do
227
227
  let(:source) do
228
228
  [
@@ -240,7 +240,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
240
240
  end
241
241
  end
242
242
 
243
- context 'when a variable is assigned multiple times ' +
243
+ context 'when a variable is assigned multiple times ' \
244
244
  'but unreferenced' do
245
245
  let(:source) do
246
246
  [
@@ -269,7 +269,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
269
269
  end
270
270
  end
271
271
 
272
- context 'when a referenced variable is reassigned ' +
272
+ context 'when a referenced variable is reassigned ' \
273
273
  'but not re-referenced' do
274
274
  let(:source) do
275
275
  [
@@ -291,7 +291,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
291
291
  end
292
292
  end
293
293
 
294
- context 'when an unreferenced variable is reassigned ' +
294
+ context 'when an unreferenced variable is reassigned ' \
295
295
  'and re-referenced' do
296
296
  let(:source) do
297
297
  [
@@ -416,7 +416,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
416
416
  include_examples 'mimics MRI 2.1'
417
417
  end
418
418
 
419
- context 'when a variable is reassigned at the end of loop body ' +
419
+ context 'when a variable is reassigned at the end of loop body ' \
420
420
  'and would be referenced in next iteration' do
421
421
  let(:source) do
422
422
  [
@@ -438,7 +438,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
438
438
  include_examples 'mimics MRI 2.1'
439
439
  end
440
440
 
441
- context 'when a variable is reassigned at the end of loop body ' +
441
+ context 'when a variable is reassigned at the end of loop body ' \
442
442
  'and would be referenced in loop condition' do
443
443
  let(:source) do
444
444
  [
@@ -460,7 +460,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
460
460
  include_examples 'mimics MRI 2.1'
461
461
  end
462
462
 
463
- context "when a variable is reassigned in loop body but won't " +
463
+ context "when a variable is reassigned in loop body but won't " \
464
464
  'be referenced either next iteration or loop condition' do
465
465
  let(:source) do
466
466
  [
@@ -488,7 +488,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
488
488
  end
489
489
  end
490
490
 
491
- context 'when a referenced variable is reassigned ' +
491
+ context 'when a referenced variable is reassigned ' \
492
492
  'but not re-referenced in a method defined in loop' do
493
493
  let(:source) do
494
494
  [
@@ -512,7 +512,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
512
512
  end
513
513
  end
514
514
 
515
- context 'when a variable that has same name as outer scope variable ' +
515
+ context 'when a variable that has same name as outer scope variable ' \
516
516
  'is not referenced in a method defined in loop' do
517
517
  let(:source) do
518
518
  [
@@ -537,7 +537,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
537
537
  end
538
538
  end
539
539
 
540
- context 'when a variable is assigned in single branch if ' +
540
+ context 'when a variable is assigned in single branch if ' \
541
541
  'and unreferenced' do
542
542
  let(:source) do
543
543
  [
@@ -561,7 +561,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
561
561
  include_examples 'mimics MRI 2.1'
562
562
  end
563
563
 
564
- context 'when a unreferenced variable is reassigned in same branch ' +
564
+ context 'when a unreferenced variable is reassigned in same branch ' \
565
565
  'and referenced after the branching' do
566
566
  let(:source) do
567
567
  [
@@ -586,7 +586,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
586
586
  end
587
587
  end
588
588
 
589
- context 'when a variable is reassigned in single branch if ' +
589
+ context 'when a variable is reassigned in single branch if ' \
590
590
  'and referenced after the branching' do
591
591
  let(:source) do
592
592
  [
@@ -606,7 +606,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
606
606
  include_examples 'mimics MRI 2.1'
607
607
  end
608
608
 
609
- context 'when a variable is assigned in each branch of if ' +
609
+ context 'when a variable is assigned in each branch of if ' \
610
610
  'and referenced after the branching' do
611
611
  let(:source) do
612
612
  [
@@ -626,7 +626,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
626
626
  include_examples 'mimics MRI 2.1'
627
627
  end
628
628
 
629
- context 'when a variable is reassigned in single branch if ' +
629
+ context 'when a variable is reassigned in single branch if ' \
630
630
  'and referenced in the branch' do
631
631
  let(:source) do
632
632
  [
@@ -651,7 +651,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
651
651
  end
652
652
  end
653
653
 
654
- context 'when a variable is assigned in each branch of if ' +
654
+ context 'when a variable is assigned in each branch of if ' \
655
655
  'and referenced in the else branch' do
656
656
  let(:source) do
657
657
  [
@@ -676,7 +676,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
676
676
  end
677
677
  end
678
678
 
679
- context 'when a variable is assigned in branch of modifier if ' +
679
+ context 'when a variable is assigned in branch of modifier if ' \
680
680
  'that references the variable in its conditional clause' +
681
681
  'and referenced after the branching' do
682
682
  let(:source) do
@@ -692,7 +692,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
692
692
  include_examples 'mimics MRI 2.1'
693
693
  end
694
694
 
695
- context 'when a variable is assigned in branch of modifier if ' +
695
+ context 'when a variable is assigned in branch of modifier if ' \
696
696
  'that references the variable in its conditional clause' +
697
697
  'and unreferenced' do
698
698
  let(:source) do
@@ -713,7 +713,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
713
713
  end
714
714
  end
715
715
 
716
- context 'when a variable is assigned on each side of && ' +
716
+ context 'when a variable is assigned on each side of && ' \
717
717
  'and referenced after the &&' do
718
718
  let(:source) do
719
719
  [
@@ -728,7 +728,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
728
728
  include_examples 'mimics MRI 2.1'
729
729
  end
730
730
 
731
- context 'when a unreferenced variable is reassigned ' +
731
+ context 'when a unreferenced variable is reassigned ' \
732
732
  'on the left side of && and referenced after the &&' do
733
733
  let(:source) do
734
734
  [
@@ -750,7 +750,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
750
750
  end
751
751
  end
752
752
 
753
- context 'when a unreferenced variable is reassigned ' +
753
+ context 'when a unreferenced variable is reassigned ' \
754
754
  'on the right side of && and referenced after the &&' do
755
755
  let(:source) do
756
756
  [
@@ -766,7 +766,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
766
766
  include_examples 'mimics MRI 2.1'
767
767
  end
768
768
 
769
- context 'when a variable is reassigned ' +
769
+ context 'when a variable is reassigned ' \
770
770
  'while referencing itself in rhs and referenced' do
771
771
  let(:source) do
772
772
  [
@@ -782,7 +782,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
782
782
  include_examples 'mimics MRI 2.1'
783
783
  end
784
784
 
785
- context 'when a variable is reassigned ' +
785
+ context 'when a variable is reassigned ' \
786
786
  'with binary operator assignment and referenced' do
787
787
  let(:source) do
788
788
  [
@@ -798,7 +798,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
798
798
  include_examples 'mimics MRI 2.1'
799
799
  end
800
800
 
801
- context 'when a variable is reassigned ' +
801
+ context 'when a variable is reassigned ' \
802
802
  'with logical operator assignment and referenced' do
803
803
  let(:source) do
804
804
  [
@@ -814,7 +814,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
814
814
  include_examples 'mimics MRI 2.1'
815
815
  end
816
816
 
817
- context 'when a variable is reassigned with binary operator ' +
817
+ context 'when a variable is reassigned with binary operator ' \
818
818
  'assignment while assigning to itself in rhs ' +
819
819
  'then referenced' do
820
820
  let(:source) do
@@ -851,7 +851,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
851
851
  include_examples 'mimics MRI 2.1'
852
852
  end
853
853
 
854
- context 'when a variable is assigned with ||= ' +
854
+ context 'when a variable is assigned with ||= ' \
855
855
  'at the last expression of the scope' do
856
856
  let(:source) do
857
857
  [
@@ -873,7 +873,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
873
873
  end
874
874
  end
875
875
 
876
- context 'when a variable is assigned with ||= ' +
876
+ context 'when a variable is assigned with ||= ' \
877
877
  'before the last expression of the scope' do
878
878
  let(:source) do
879
879
  [
@@ -895,7 +895,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
895
895
  end
896
896
  end
897
897
 
898
- context 'when a variable is assigned with multiple assignment ' +
898
+ context 'when a variable is assigned with multiple assignment ' \
899
899
  'and unreferenced' do
900
900
  let(:source) do
901
901
  [
@@ -910,7 +910,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
910
910
  inspect_source(cop, source)
911
911
  expect(cop.offences.size).to eq(1)
912
912
  expect(cop.offences.first.message).to eq(
913
- 'Useless assignment to variable - bar. ' +
913
+ 'Useless assignment to variable - bar. ' \
914
914
  'Use _ or _bar as a variable name ' +
915
915
  "to indicate that it won't be used."
916
916
  )
@@ -921,7 +921,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
921
921
  include_examples 'mimics MRI 2.1'
922
922
  end
923
923
 
924
- context 'when a variable is reassigned with multiple assignment ' +
924
+ context 'when a variable is reassigned with multiple assignment ' \
925
925
  'while referencing itself in rhs and referenced' do
926
926
  let(:source) do
927
927
  [
@@ -937,7 +937,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
937
937
  include_examples 'mimics MRI 2.1'
938
938
  end
939
939
 
940
- context 'when a variable is assigned in loop body ' +
940
+ context 'when a variable is assigned in loop body ' \
941
941
  'and referenced in post while condition' do
942
942
  let(:source) do
943
943
  [
@@ -952,7 +952,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
952
952
  include_examples 'mimics MRI 2.1'
953
953
  end
954
954
 
955
- context 'when a variable is assigned in loop body ' +
955
+ context 'when a variable is assigned in loop body ' \
956
956
  'and referenced in post until condition' do
957
957
  let(:source) do
958
958
  [
@@ -967,7 +967,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
967
967
  include_examples 'mimics MRI 2.1'
968
968
  end
969
969
 
970
- context 'when a variable is assigned ' +
970
+ context 'when a variable is assigned ' \
971
971
  'in main body of begin with rescue but unreferenced' do
972
972
  let(:source) do
973
973
  [
@@ -992,7 +992,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
992
992
  include_examples 'mimics MRI 2.1'
993
993
  end
994
994
 
995
- context 'when a variable is assigned in main body of begin, rescue ' +
995
+ context 'when a variable is assigned in main body of begin, rescue ' \
996
996
  'and else then referenced after the begin' do
997
997
  let(:source) do
998
998
  [
@@ -1015,7 +1015,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1015
1015
  include_examples 'mimics MRI 2.1'
1016
1016
  end
1017
1017
 
1018
- context 'when a variable is reassigned multiple times ' +
1018
+ context 'when a variable is reassigned multiple times ' \
1019
1019
  'in main body of begin then referenced after the begin' do
1020
1020
  let(:source) do
1021
1021
  [
@@ -1037,7 +1037,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1037
1037
  include_examples 'mimics MRI 2.1'
1038
1038
  end
1039
1039
 
1040
- context 'when a variable is reassigned multiple times ' +
1040
+ context 'when a variable is reassigned multiple times ' \
1041
1041
  'in main body of begin then referenced in rescue' do
1042
1042
  let(:source) do
1043
1043
  [
@@ -1057,7 +1057,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1057
1057
  include_examples 'mimics MRI 2.1'
1058
1058
  end
1059
1059
 
1060
- context 'when a variable is reassigned multiple times ' +
1060
+ context 'when a variable is reassigned multiple times ' \
1061
1061
  'in main body of begin then referenced in ensure' do
1062
1062
  let(:source) do
1063
1063
  [
@@ -1077,7 +1077,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1077
1077
  include_examples 'mimics MRI 2.1'
1078
1078
  end
1079
1079
 
1080
- context 'when a variable is reassigned multiple times in rescue ' +
1080
+ context 'when a variable is reassigned multiple times in rescue ' \
1081
1081
  'and referenced after the begin' do
1082
1082
  let(:source) do
1083
1083
  [
@@ -1104,7 +1104,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1104
1104
  end
1105
1105
  end
1106
1106
 
1107
- context 'when a variable is reassigned multiple times ' +
1107
+ context 'when a variable is reassigned multiple times ' \
1108
1108
  'in rescue with ensure then referenced after the begin' do
1109
1109
  let(:source) do
1110
1110
  [
@@ -1133,7 +1133,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1133
1133
  end
1134
1134
  end
1135
1135
 
1136
- context 'when a variable is reassigned multiple times ' +
1136
+ context 'when a variable is reassigned multiple times ' \
1137
1137
  'in ensure with rescue then referenced after the begin' do
1138
1138
  let(:source) do
1139
1139
  [
@@ -1160,7 +1160,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1160
1160
  end
1161
1161
  end
1162
1162
 
1163
- context 'when a variable is assigned at the end of rescue ' +
1163
+ context 'when a variable is assigned at the end of rescue ' \
1164
1164
  'and would be referenced with retry' do
1165
1165
  let(:source) do
1166
1166
  [
@@ -1180,7 +1180,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1180
1180
  include_examples 'mimics MRI 2.1'
1181
1181
  end
1182
1182
 
1183
- context 'when a variable is assigned ' +
1183
+ context 'when a variable is assigned ' \
1184
1184
  'in main body of begin, rescue and else ' +
1185
1185
  'and reassigned in ensure then referenced after the begin' do
1186
1186
  let(:source) do
@@ -1213,7 +1213,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1213
1213
  end
1214
1214
  end
1215
1215
 
1216
- context 'when a method argument is reassigned ' +
1216
+ context 'when a method argument is reassigned ' \
1217
1217
  'and zero arity super is called' do
1218
1218
  let(:source) do
1219
1219
  [
@@ -1228,7 +1228,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1228
1228
  include_examples 'mimics MRI 2.1'
1229
1229
  end
1230
1230
 
1231
- context 'when a local variable is unreferenced ' +
1231
+ context 'when a local variable is unreferenced ' \
1232
1232
  'and zero arity super is called' do
1233
1233
  let(:source) do
1234
1234
  [
@@ -1251,7 +1251,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1251
1251
  include_examples 'mimics MRI 2.1'
1252
1252
  end
1253
1253
 
1254
- context 'when a method argument is reassigned ' +
1254
+ context 'when a method argument is reassigned ' \
1255
1255
  'but not passed to super' do
1256
1256
  let(:source) do
1257
1257
  [
@@ -1290,7 +1290,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1290
1290
  include_examples 'mimics MRI 2.1'
1291
1291
  end
1292
1292
 
1293
- context 'when a named capture is unreferenced ' +
1293
+ context 'when a named capture is unreferenced ' \
1294
1294
  'in other than top level' do
1295
1295
  let(:source) do
1296
1296
  [
@@ -1329,7 +1329,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1329
1329
  include_examples 'mimics MRI 2.1'
1330
1330
  end
1331
1331
 
1332
- context 'when a variable is referenced ' +
1332
+ context 'when a variable is referenced ' \
1333
1333
  'in rhs of named capture expression' do
1334
1334
  let(:source) do
1335
1335
  [
@@ -1344,7 +1344,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1344
1344
  include_examples 'accepts'
1345
1345
  end
1346
1346
 
1347
- context 'when a variable is assigned in begin ' +
1347
+ context 'when a variable is assigned in begin ' \
1348
1348
  'and referenced outside' do
1349
1349
  let(:source) do
1350
1350
  [
@@ -1361,7 +1361,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1361
1361
  include_examples 'mimics MRI 2.1'
1362
1362
  end
1363
1363
 
1364
- context 'when a variable is shadowed by a block argument ' +
1364
+ context 'when a variable is shadowed by a block argument ' \
1365
1365
  'and unreferenced' do
1366
1366
  let(:source) do
1367
1367
  [
@@ -1517,7 +1517,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1517
1517
  include_examples 'mimics MRI 2.1'
1518
1518
  end
1519
1519
 
1520
- context 'when a variable is assigned ' +
1520
+ context 'when a variable is assigned ' \
1521
1521
  'while being passed to a method taking block' do
1522
1522
 
1523
1523
  context 'and the variable is used' do
@@ -1554,7 +1554,7 @@ describe Rubocop::Cop::Lint::UselessAssignment do
1554
1554
  end
1555
1555
  end
1556
1556
 
1557
- context 'when a variabled is assigned ' +
1557
+ context 'when a variabled is assigned ' \
1558
1558
  'and passed to a method followed by method taking block' do
1559
1559
  let(:source) do
1560
1560
  [