puppet-lint-manifest_whitespace-check 0.2.8 → 0.3.0

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.
@@ -7,9 +7,9 @@ describe 'manifest_whitespace_closing_brace_before' do
7
7
 
8
8
  context 'with plus' do
9
9
  let(:code) do
10
- <<~EOF
10
+ <<~CODE
11
11
  $my_images = { 'default' => {}}
12
- EOF
12
+ CODE
13
13
  end
14
14
 
15
15
  context 'with fix enabled' do
@@ -21,15 +21,15 @@ describe 'manifest_whitespace_closing_brace_before' do
21
21
  PuppetLint.configuration.fix = false
22
22
  end
23
23
 
24
- it 'should fix a error' do
24
+ it 'fixes a error' do
25
25
  expect(problems).to contain_fixed(closing_brace_msg)
26
26
  end
27
27
 
28
- it 'should add spaces' do
28
+ it 'adds spaces' do
29
29
  expect(manifest).to eq(
30
- <<~EOF,
30
+ <<~CODE,
31
31
  $my_images = { 'default' => {} }
32
- EOF
32
+ CODE
33
33
  )
34
34
  end
35
35
  end
@@ -37,49 +37,49 @@ describe 'manifest_whitespace_closing_brace_before' do
37
37
 
38
38
  context 'with nested hash' do
39
39
  let(:code) do
40
- <<~EOF
40
+ <<~CODE
41
41
  Hash $instances = { 'localhost' => { 'url' => 'http://localhost/mod_status?auto' } },
42
- EOF
42
+ CODE
43
43
  end
44
44
 
45
- it 'should detect no problems' do
45
+ it 'detects no problems' do
46
46
  expect(problems).to be_empty
47
47
  end
48
48
  end
49
49
 
50
50
  context 'with iterator' do
51
51
  let(:code) do
52
- <<~EOF
52
+ <<~CODE
53
53
  ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
54
54
  }
55
55
 
56
56
  ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
57
57
  }
58
- EOF
58
+ CODE
59
59
  end
60
60
 
61
- it 'should detect no problems' do
61
+ it 'detects no problems' do
62
62
  expect(problems).to be_empty
63
63
  end
64
64
  end
65
65
 
66
66
  context 'with comment only' do
67
67
  let(:code) do
68
- <<~EOF
68
+ <<~CODE
69
69
  $value7 = {
70
70
  # nothing
71
71
  }
72
- EOF
72
+ CODE
73
73
  end
74
74
 
75
- it 'should detect no problems' do
75
+ it 'detects no problems' do
76
76
  expect(problems).to be_empty
77
77
  end
78
78
  end
79
79
 
80
80
  context 'with no spaces' do
81
81
  let(:code) do
82
- <<~EOF
82
+ <<~CODE
83
83
  # example
84
84
  #
85
85
  # Main class, includes all other classes.
@@ -115,15 +115,15 @@ describe 'manifest_whitespace_closing_brace_before' do
115
115
  class { 'example3':}
116
116
  }
117
117
  }
118
- EOF
118
+ CODE
119
119
  end
120
120
 
121
121
  context 'with fix disabled' do
122
- it 'should detect 3 problems' do
122
+ it 'detects 3 problems' do
123
123
  expect(problems).to have(3).problem
124
124
  end
125
125
 
126
- it 'should create a error' do
126
+ it 'creates a error' do
127
127
  expect(problems).to contain_error(closing_brace_msg).on_line(9).in_column(31)
128
128
  end
129
129
  end
@@ -137,13 +137,13 @@ describe 'manifest_whitespace_closing_brace_before' do
137
137
  PuppetLint.configuration.fix = false
138
138
  end
139
139
 
140
- it 'should fix a error' do
140
+ it 'fixes a error' do
141
141
  expect(problems).to contain_fixed(closing_brace_msg)
142
142
  end
143
143
 
144
- it 'should add spaces' do
144
+ it 'adds spaces' do
145
145
  expect(manifest).to eq(
146
- <<~EOF,
146
+ <<~CODE,
147
147
  # example
148
148
  #
149
149
  # Main class, includes all other classes.
@@ -179,7 +179,7 @@ describe 'manifest_whitespace_closing_brace_before' do
179
179
  class { 'example3': }
180
180
  }
181
181
  }
182
- EOF
182
+ CODE
183
183
  )
184
184
  end
185
185
  end
@@ -187,7 +187,7 @@ describe 'manifest_whitespace_closing_brace_before' do
187
187
 
188
188
  context 'with too many spaces' do
189
189
  let(:code) do
190
- <<~EOF
190
+ <<~CODE
191
191
  # example
192
192
  #
193
193
  # Main class, includes all other classes.
@@ -221,15 +221,15 @@ describe 'manifest_whitespace_closing_brace_before' do
221
221
  class { 'example3': }
222
222
  }
223
223
  }
224
- EOF
224
+ CODE
225
225
  end
226
226
 
227
227
  context 'with fix disabled' do
228
- it 'should detect 4 problems' do
228
+ it 'detects 4 problems' do
229
229
  expect(problems).to have(4).problems
230
230
  end
231
231
 
232
- it 'should create a error' do
232
+ it 'creates a error' do
233
233
  expect(problems).to contain_error(closing_brace_msg).on_line(9).in_column(31)
234
234
  end
235
235
  end
@@ -243,13 +243,13 @@ describe 'manifest_whitespace_closing_brace_before' do
243
243
  PuppetLint.configuration.fix = false
244
244
  end
245
245
 
246
- it 'should fix a error' do
246
+ it 'fixes a error' do
247
247
  expect(problems).to contain_fixed(closing_brace_msg)
248
248
  end
249
249
 
250
- it 'should add spaces' do
250
+ it 'adds spaces' do
251
251
  expect(manifest).to eq(
252
- <<~EOF,
252
+ <<~CODE,
253
253
  # example
254
254
  #
255
255
  # Main class, includes all other classes.
@@ -283,7 +283,7 @@ describe 'manifest_whitespace_closing_brace_before' do
283
283
  class { 'example3': }
284
284
  }
285
285
  }
286
- EOF
286
+ CODE
287
287
  )
288
288
  end
289
289
  end
@@ -291,7 +291,7 @@ describe 'manifest_whitespace_closing_brace_before' do
291
291
 
292
292
  context 'with too many newlines' do
293
293
  let(:code) do
294
- <<~EOF
294
+ <<~CODE
295
295
  # example
296
296
  #
297
297
  # Main class, includes all other classes.
@@ -331,15 +331,15 @@ describe 'manifest_whitespace_closing_brace_before' do
331
331
  }
332
332
 
333
333
  }
334
- EOF
334
+ CODE
335
335
  end
336
336
 
337
337
  context 'with fix disabled' do
338
- it 'should detect 5 problems' do
338
+ it 'detects 5 problems' do
339
339
  expect(problems).to have(5).problems
340
340
  end
341
341
 
342
- it 'should create a error' do
342
+ it 'creates a error' do
343
343
  expect(problems).to contain_error(closing_brace_msg).on_line(15).in_column(25)
344
344
  end
345
345
  end
@@ -353,13 +353,13 @@ describe 'manifest_whitespace_closing_brace_before' do
353
353
  PuppetLint.configuration.fix = false
354
354
  end
355
355
 
356
- it 'should fix a error' do
356
+ it 'fixes a error' do
357
357
  expect(problems).to contain_fixed(closing_brace_msg)
358
358
  end
359
359
 
360
- it 'should remove newlines' do
360
+ it 'removes newlines' do
361
361
  expect(manifest).to eq(
362
- <<~EOF,
362
+ <<~CODE,
363
363
  # example
364
364
  #
365
365
  # Main class, includes all other classes.
@@ -394,7 +394,7 @@ describe 'manifest_whitespace_closing_brace_before' do
394
394
  class { 'example3': }
395
395
  }
396
396
  }
397
- EOF
397
+ CODE
398
398
  )
399
399
  end
400
400
  end
@@ -408,32 +408,32 @@ describe 'manifest_whitespace_closing_brace_after' do
408
408
 
409
409
  context 'with iterator' do
410
410
  let(:code) do
411
- <<~EOF
411
+ <<~CODE
412
412
  ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
413
413
  }
414
- EOF
414
+ CODE
415
415
  end
416
416
 
417
- it 'should detect no problems' do
417
+ it 'detects no problems' do
418
418
  expect(problems).to be_empty
419
419
  end
420
420
  end
421
421
 
422
422
  context 'inline with a function after' do
423
423
  let(:code) do
424
- <<~EOF
424
+ <<~CODE
425
425
  Hash({ $key => $return_value } )
426
- EOF
426
+ CODE
427
427
  end
428
428
 
429
- it 'should detect 1 problem' do
429
+ it 'detects 1 problem' do
430
430
  expect(problems).to have(1).problem
431
431
  end
432
432
  end
433
433
 
434
434
  context 'with spaces' do
435
435
  let(:code) do
436
- <<~EOF
436
+ <<~CODE
437
437
  # example
438
438
  #
439
439
  # Main class, includes all other classes.
@@ -471,15 +471,15 @@ describe 'manifest_whitespace_closing_brace_after' do
471
471
  class { 'example3': }
472
472
  }
473
473
  }
474
- EOF
474
+ CODE
475
475
  end
476
476
 
477
477
  context 'with fix disabled' do
478
- it 'should detect 3 problems' do
478
+ it 'detects 3 problems' do
479
479
  expect(problems).to have(3).problem
480
480
  end
481
481
 
482
- it 'should create a error' do
482
+ it 'creates a error' do
483
483
  expect(problems).to contain_error(closing_brace_msg).on_line(9).in_column(33)
484
484
  end
485
485
  end
@@ -493,13 +493,13 @@ describe 'manifest_whitespace_closing_brace_after' do
493
493
  PuppetLint.configuration.fix = false
494
494
  end
495
495
 
496
- it 'should fix a error' do
496
+ it 'fixes a error' do
497
497
  expect(problems).to contain_fixed(closing_brace_msg)
498
498
  end
499
499
 
500
- it 'should add spaces' do
500
+ it 'adds spaces' do
501
501
  expect(manifest).to eq(
502
- <<~EOF,
502
+ <<~CODE,
503
503
  # example
504
504
  #
505
505
  # Main class, includes all other classes.
@@ -537,7 +537,7 @@ describe 'manifest_whitespace_closing_brace_after' do
537
537
  class { 'example3': }
538
538
  }
539
539
  }
540
- EOF
540
+ CODE
541
541
  )
542
542
  end
543
543
  end
@@ -7,7 +7,7 @@ describe 'manifest_whitespace_closing_bracket_before' do
7
7
 
8
8
  context 'with no spaces' do
9
9
  let(:code) do
10
- <<~EOF
10
+ <<~CODE
11
11
  # example
12
12
  #
13
13
  # Main class, includes all other classes.
@@ -38,11 +38,11 @@ describe 'manifest_whitespace_closing_bracket_before' do
38
38
  }
39
39
  }
40
40
  }
41
- EOF
41
+ CODE
42
42
  end
43
43
 
44
44
  context 'with fix disabled' do
45
- it 'should detect 0 problems' do
45
+ it 'detects 0 problems' do
46
46
  expect(problems).to be_empty
47
47
  end
48
48
  end
@@ -50,7 +50,7 @@ describe 'manifest_whitespace_closing_bracket_before' do
50
50
 
51
51
  context 'with too many spaces' do
52
52
  let(:code) do
53
- <<~EOF
53
+ <<~CODE
54
54
  # example
55
55
  #
56
56
  # Main class, includes all other classes.
@@ -82,15 +82,15 @@ describe 'manifest_whitespace_closing_bracket_before' do
82
82
  }
83
83
  }
84
84
  }
85
- EOF
85
+ CODE
86
86
  end
87
87
 
88
88
  context 'with fix disabled' do
89
- it 'should detect 5 problems' do
89
+ it 'detects 5 problems' do
90
90
  expect(problems).to have(5).problems
91
91
  end
92
92
 
93
- it 'should create a error' do
93
+ it 'creates a error' do
94
94
  expect(problems).to contain_error(closing_bracket_msg).on_line(9).in_column(33)
95
95
  end
96
96
  end
@@ -104,17 +104,17 @@ describe 'manifest_whitespace_closing_bracket_before' do
104
104
  PuppetLint.configuration.fix = false
105
105
  end
106
106
 
107
- it 'should detect 5 problems' do
107
+ it 'detects 5 problems' do
108
108
  expect(problems).to have(5).problems
109
109
  end
110
110
 
111
- it 'should fix a error' do
111
+ it 'fixes a error' do
112
112
  expect(problems).to contain_fixed(closing_bracket_msg)
113
113
  end
114
114
 
115
- it 'should add spaces' do
115
+ it 'adds spaces' do
116
116
  expect(manifest).to eq(
117
- <<~EOF,
117
+ <<~CODE,
118
118
  # example
119
119
  #
120
120
  # Main class, includes all other classes.
@@ -145,7 +145,7 @@ describe 'manifest_whitespace_closing_bracket_before' do
145
145
  }
146
146
  }
147
147
  }
148
- EOF
148
+ CODE
149
149
  )
150
150
  end
151
151
  end
@@ -157,56 +157,37 @@ describe 'manifest_whitespace_closing_bracket_after' do
157
157
  'there should be either a bracket, punctuation mark, closing quote or a newline after a closing bracket, or whitespace and none of the aforementioned'
158
158
  end
159
159
 
160
- context 'inside heredoc' do
161
- let(:code) do
162
- <<~EOF
163
- class test::heredoc {
164
- $unsupported = @("MESSAGE"/L)
165
- This does not support ${facts['os']['name']} ${$facts['os']['release']['major']}; \
166
- see ${support_urls['supported_platforms']} for more information\
167
- | MESSAGE
168
-
169
- fail($unsupported)
170
- }
171
- EOF
172
- end
173
-
174
- it 'should detect no problems' do
175
- expect(problems).to be_empty
176
- end
177
- end
178
-
179
160
  context 'with many brackets' do
180
161
  let(:code) do
181
- <<~EOF
162
+ <<~CODE
182
163
  ensure_packages($spaceweather::packages, { require => Class['Mongodb::Globals'] })
183
- EOF
164
+ CODE
184
165
  end
185
166
 
186
- it 'should detect no problems' do
167
+ it 'detects no problems' do
187
168
  expect(problems).to be_empty
188
169
  end
189
170
  end
190
171
 
191
172
  context 'with iterator' do
192
173
  let(:code) do
193
- <<~EOF
174
+ <<~CODE
194
175
  ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
195
176
  }
196
177
 
197
178
  ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
198
179
  }
199
- EOF
180
+ CODE
200
181
  end
201
182
 
202
- it 'should detect no problems' do
183
+ it 'detects no problems' do
203
184
  expect(problems).to be_empty
204
185
  end
205
186
  end
206
187
 
207
188
  context 'with spaces' do
208
189
  let(:code) do
209
- <<~EOF
190
+ <<~CODE
210
191
  # example
211
192
  #
212
193
  # Main class, includes all other classes.
@@ -248,15 +229,15 @@ describe 'manifest_whitespace_closing_bracket_after' do
248
229
  ensure => installed,
249
230
  }
250
231
  }
251
- EOF
232
+ CODE
252
233
  end
253
234
 
254
235
  context 'with fix disabled' do
255
- it 'should detect 2 problems' do
236
+ it 'detects 2 problems' do
256
237
  expect(problems).to have(2).problem
257
238
  end
258
239
 
259
- it 'should create a error' do
240
+ it 'creates a error' do
260
241
  expect(problems).to contain_error(closing_bracket_msg).on_line(23).in_column(22)
261
242
  end
262
243
  end
@@ -270,13 +251,13 @@ describe 'manifest_whitespace_closing_bracket_after' do
270
251
  PuppetLint.configuration.fix = false
271
252
  end
272
253
 
273
- it 'should fix a error' do
254
+ it 'fixes a error' do
274
255
  expect(problems).to contain_fixed(closing_bracket_msg)
275
256
  end
276
257
 
277
- it 'should add spaces' do
258
+ it 'adds spaces' do
278
259
  expect(manifest).to eq(
279
- <<~EOF,
260
+ <<~CODE,
280
261
  # example
281
262
  #
282
263
  # Main class, includes all other classes.
@@ -318,13 +299,32 @@ describe 'manifest_whitespace_closing_bracket_after' do
318
299
  ensure => installed,
319
300
  }
320
301
  }
321
- EOF
302
+ CODE
322
303
  )
323
304
  end
324
305
  end
325
306
  end
326
307
 
327
- context 'inside heredoc' do
308
+ context 'inside heredoc 1' do
309
+ let(:code) do
310
+ <<~CODE
311
+ class test::heredoc {
312
+ $unsupported = @("MESSAGE"/L)
313
+ This does not support ${facts['os']['name']} ${$facts['os']['release']['major']}; \
314
+ see ${support_urls['supported_platforms']} for more information\
315
+ | MESSAGE
316
+
317
+ fail($unsupported)
318
+ }
319
+ CODE
320
+ end
321
+
322
+ it 'detects no problems' do
323
+ expect(problems).to be_empty
324
+ end
325
+ end
326
+
327
+ context 'inside heredoc 2' do
328
328
  describe 'issue10 example' do
329
329
  let(:code) do
330
330
  <<~CODE
@@ -332,16 +332,16 @@ describe 'manifest_whitespace_closing_bracket_after' do
332
332
  ensure => file,
333
333
  owner => 'root',
334
334
  group => 'root',
335
- content => Sensitive(@("EOF")),
335
+ content => Sensitive(@("CODE")),
336
336
  # hostname:port:database:username:password
337
337
  127.0.0.1:5432:aos:${variable}:${hash['password']}
338
338
  localhost:5432:aos:${variable}:${hash['password']}
339
- | EOF
339
+ | CODE
340
340
  }
341
341
  CODE
342
342
  end
343
343
 
344
- it 'should detect no problems' do
344
+ it 'detects no problems' do
345
345
  expect(problems).to be_empty
346
346
  end
347
347
  end
@@ -349,30 +349,30 @@ describe 'manifest_whitespace_closing_bracket_after' do
349
349
  describe 'interpolated hash key in middle of line' do
350
350
  let(:code) do
351
351
  <<~CODE
352
- $content = @("EOF")
352
+ $content = @("CODE")
353
353
  somestring:${foo['bar']}:more
354
354
  more stuff
355
- | EOF
355
+ | CODE
356
356
  # more puppet code follows
357
357
  CODE
358
358
  end
359
359
 
360
- it 'should detect no problems' do
360
+ it 'detects no problems' do
361
361
  expect(problems).to be_empty
362
362
  end
363
363
 
364
364
  context 'with unwanted whitespace' do
365
365
  let(:code) do
366
366
  <<~CODE
367
- $content = @("EOF")
367
+ $content = @("CODE")
368
368
  somestring:${foo['bar'] }:more
369
369
  more stuff
370
- | EOF
370
+ | CODE
371
371
  # more puppet code follows
372
372
  CODE
373
373
  end
374
374
 
375
- it 'should detect 1 problem' do
375
+ it 'detects 1 problem' do
376
376
  expect(problems).to have(1).problem
377
377
  end
378
378
  end
@@ -381,30 +381,30 @@ describe 'manifest_whitespace_closing_bracket_after' do
381
381
  describe 'interpolated hash key at end of line' do
382
382
  let(:code) do
383
383
  <<~CODE
384
- $content = @("EOF")
384
+ $content = @("CODE")
385
385
  somestring:${foo['bar']}
386
386
  more stuff
387
- | EOF
387
+ | CODE
388
388
  # more puppet code follows
389
389
  CODE
390
390
  end
391
391
 
392
- it 'should detect no problems' do
392
+ it 'detects no problems' do
393
393
  expect(problems).to be_empty
394
394
  end
395
395
 
396
396
  context 'with unwanted whitespace' do
397
397
  let(:code) do
398
398
  <<~CODE
399
- $content = @("EOF")
399
+ $content = @("CODE")
400
400
  somestring:${foo['bar'] }
401
401
  more stuff
402
- | EOF
402
+ | CODE
403
403
  # more puppet code follows
404
404
  CODE
405
405
  end
406
406
 
407
- it 'should detect 1 problem' do
407
+ it 'detects 1 problem' do
408
408
  expect(problems).to have(1).problem
409
409
  end
410
410
  end
@@ -413,30 +413,30 @@ describe 'manifest_whitespace_closing_bracket_after' do
413
413
  describe 'interpolated hash key at end of heredoc' do
414
414
  let(:code) do
415
415
  <<~CODE
416
- $content = @("EOF")
416
+ $content = @("CODE")
417
417
  # Some random heredoc preamble
418
418
  somestring:${foo['bar']}
419
- | EOF
419
+ | CODE
420
420
  # more puppet code follows
421
421
  CODE
422
422
  end
423
423
 
424
- it 'should detect no problems' do
424
+ it 'detects no problems' do
425
425
  expect(problems).to be_empty
426
426
  end
427
427
 
428
428
  context 'with unwanted whitespace' do
429
429
  let(:code) do
430
430
  <<~CODE
431
- $content = @("EOF")
431
+ $content = @("CODE")
432
432
  # Some random heredoc preamble
433
433
  somestring:${foo['bar'] }
434
- | EOF
434
+ | CODE
435
435
  # more puppet code follows
436
436
  CODE
437
437
  end
438
438
 
439
- it 'should detect 1 problem' do
439
+ it 'detects 1 problem' do
440
440
  expect(problems).to have(1).problem
441
441
  end
442
442
  end