puppet-lint-manifest_whitespace-check 0.1.17 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/puppet-lint/plugins/check_manifest_whitespace_closing_brace.rb +6 -16
- data/lib/puppet-lint/plugins/check_manifest_whitespace_closing_bracket.rb +3 -9
- data/lib/puppet-lint/plugins/check_manifest_whitespace_opening_brace.rb +11 -7
- data/lib/puppet-lint/plugins/check_manifest_whitespace_opening_bracket.rb +3 -9
- data/lib/puppet-lint/plugins/tools.rb +1 -1
- data/spec/puppet-lint/plugins/manifest_whitespace_arrow_spaces_spec.rb +3 -3
- data/spec/puppet-lint/plugins/manifest_whitespace_class_header_spec.rb +6 -4
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_brace_spec.rb +19 -5
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_bracket_spec.rb +125 -4
- data/spec/puppet-lint/plugins/manifest_whitespace_double_newline_end_of_file_spec.rb +13 -13
- data/spec/puppet-lint/plugins/manifest_whitespace_newline_begin_of_file_spec.rb +1 -1
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_brace_spec.rb +59 -4
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_bracket_spec.rb +25 -8
- metadata +9 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b3bc8cb98f4459ad929e160c0759c73e76fc6253c54061b4edea16370f8b38d
|
4
|
+
data.tar.gz: ddc62ccbc2c3537f6057c73d498a035dc4007f416a8b435140a207aa8c0380f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59189f5b0b1922bfd04ef96b64f53662b5740ef3a20d8a34f44045fa90d194a4c94e41ca6440ada5b0ecb8b8ec3bb27631b85c02e61f59b4844a708665e417a2
|
7
|
+
data.tar.gz: 3547dfb1ab41289ef4ad92168bbc02a12b0ae717b9e97146c0fc2cb13314a972cc1d1c191c0d4feaf73ac7604deb7b272ac90616693f980d1be224a2d498ec26
|
@@ -9,19 +9,13 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_before) do
|
|
9
9
|
next unless prev_token && prev_code_token
|
10
10
|
next if %i[LBRACE].include?(prev_token.type)
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
next
|
15
|
-
end
|
12
|
+
if !%i[LBRACE].include?(prev_code_token.type) && (is_single_space(prev_token) && tokens.index(prev_code_token) == tokens.index(brace_token) - 2)
|
13
|
+
next
|
16
14
|
end
|
17
15
|
|
18
|
-
if prev_token.type == :INDENT
|
19
|
-
next if tokens.index(prev_code_token) == tokens.index(brace_token) - 3
|
20
|
-
end
|
16
|
+
next if prev_token.type == :INDENT && (tokens.index(prev_code_token) == tokens.index(brace_token) - 3)
|
21
17
|
|
22
|
-
if prev_token.type == :NEWLINE
|
23
|
-
next if tokens.index(prev_code_token) == tokens.index(brace_token) - 2
|
24
|
-
end
|
18
|
+
next if prev_token.type == :NEWLINE && (tokens.index(prev_code_token) == tokens.index(brace_token) - 2)
|
25
19
|
|
26
20
|
notify(
|
27
21
|
:error,
|
@@ -39,13 +33,9 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_before) do
|
|
39
33
|
next_token = token
|
40
34
|
|
41
35
|
until next_token.type == :RBRACE
|
42
|
-
if tokens[tokens.index(next_token)..-1].first(2).collect(&:type) == %i[NEWLINE RBRACE]
|
43
|
-
break
|
44
|
-
end
|
36
|
+
break if tokens[tokens.index(next_token)..-1].first(2).collect(&:type) == %i[NEWLINE RBRACE]
|
45
37
|
|
46
|
-
if tokens[tokens.index(next_token)..-1].first(3).collect(&:type) == %i[NEWLINE INDENT RBRACE]
|
47
|
-
break
|
48
|
-
end
|
38
|
+
break if tokens[tokens.index(next_token)..-1].first(3).collect(&:type) == %i[NEWLINE INDENT RBRACE]
|
49
39
|
|
50
40
|
remove_token(next_token)
|
51
41
|
next_token = next_token.next_token
|
@@ -11,12 +11,8 @@ PuppetLint.new_check(:manifest_whitespace_closing_bracket_before) do
|
|
11
11
|
|
12
12
|
next unless %i[NEWLINE INDENT WHITESPACE].include?(prev_token.type)
|
13
13
|
|
14
|
-
if prev_token.type == :INDENT
|
15
|
-
|
16
|
-
end
|
17
|
-
if prev_token.type == :NEWLINE
|
18
|
-
next if tokens.index(prev_code_token) == tokens.index(bracket_token) - 2
|
19
|
-
end
|
14
|
+
next if prev_token.type == :INDENT && (tokens.index(prev_code_token) == tokens.index(bracket_token) - 3)
|
15
|
+
next if prev_token.type == :NEWLINE && (tokens.index(prev_code_token) == tokens.index(bracket_token) - 2)
|
20
16
|
|
21
17
|
notify(
|
22
18
|
:error,
|
@@ -37,9 +33,7 @@ PuppetLint.new_check(:manifest_whitespace_closing_bracket_before) do
|
|
37
33
|
|
38
34
|
next_token = token.next_token
|
39
35
|
until next_token.type == :RBRACK
|
40
|
-
if next_token.type == :INDENT && next_token.next_token.type == :RBRACK
|
41
|
-
break
|
42
|
-
end
|
36
|
+
break if next_token.type == :INDENT && next_token.next_token.type == :RBRACK
|
43
37
|
|
44
38
|
remove_token(next_token)
|
45
39
|
next_token = next_token.next_token
|
@@ -7,11 +7,17 @@ PuppetLint.new_check(:manifest_whitespace_opening_brace_before) do
|
|
7
7
|
prev_code_token = prev_non_space_token(brace_token)
|
8
8
|
|
9
9
|
next unless prev_token && prev_code_token
|
10
|
-
|
11
|
-
|
10
|
+
|
11
|
+
next if %i[COLON].include?(prev_code_token.type)
|
12
|
+
|
13
|
+
if %i[COMMENT COMMA LPAREN LBRACK LBRACE].include?(prev_code_token.type)
|
14
|
+
next if tokens.index(prev_code_token) == tokens.index(brace_token) - 1
|
15
|
+
next if tokens[tokens.index(prev_code_token)..tokens.index(brace_token)].collect(&:type).include?(:NEWLINE)
|
16
|
+
|
17
|
+
else
|
18
|
+
next unless tokens.index(prev_code_token) != tokens.index(brace_token) - 2 ||
|
19
|
+
!is_single_space(prev_token)
|
12
20
|
end
|
13
|
-
next unless tokens.index(prev_code_token) != tokens.index(brace_token) - 2 ||
|
14
|
-
!is_single_space(prev_token)
|
15
21
|
|
16
22
|
notify(
|
17
23
|
:error,
|
@@ -29,9 +35,7 @@ PuppetLint.new_check(:manifest_whitespace_opening_brace_before) do
|
|
29
35
|
prev_code_token = prev_non_space_token(token)
|
30
36
|
|
31
37
|
while prev_code_token != prev_token
|
32
|
-
unless %i[WHITESPACE INDENT NEWLINE].include?(prev_token.type)
|
33
|
-
raise PuppetLint::NoFix
|
34
|
-
end
|
38
|
+
raise PuppetLint::NoFix unless %i[WHITESPACE INDENT NEWLINE].include?(prev_token.type)
|
35
39
|
|
36
40
|
remove_token(prev_token)
|
37
41
|
prev_token = prev_token.prev_token
|
@@ -7,14 +7,10 @@ PuppetLint.new_check(:manifest_whitespace_opening_bracket_before) do
|
|
7
7
|
prev_code_token = prev_non_space_token(bracket_token)
|
8
8
|
|
9
9
|
next unless prev_token && prev_code_token
|
10
|
-
if %i[LBRACK LBRACE COMMA SEMIC COMMENT].include?(prev_code_token.type)
|
11
|
-
next
|
12
|
-
end
|
10
|
+
next if %i[LBRACK LBRACE COMMA SEMIC COMMENT NAME].include?(prev_code_token.type)
|
13
11
|
next unless %i[WHITESPACE NEWLINE INDENT].include?(prev_token.type)
|
14
12
|
|
15
|
-
if %i[INDENT NEWLINE].include?(prev_token.type) && %i[RBRACK RBRACE].include?(prev_code_token.type)
|
16
|
-
next
|
17
|
-
end
|
13
|
+
next if %i[INDENT NEWLINE].include?(prev_token.type) && %i[RBRACK RBRACE].include?(prev_code_token.type)
|
18
14
|
next unless tokens.index(prev_code_token) != tokens.index(bracket_token) - 2 ||
|
19
15
|
!is_single_space(prev_token)
|
20
16
|
|
@@ -34,9 +30,7 @@ PuppetLint.new_check(:manifest_whitespace_opening_bracket_before) do
|
|
34
30
|
prev_code_token = prev_non_space_token(token)
|
35
31
|
|
36
32
|
while prev_code_token != prev_token
|
37
|
-
unless %i[WHITESPACE INDENT NEWLINE].include?(prev_token.type)
|
38
|
-
raise PuppetLint::NoFix
|
39
|
-
end
|
33
|
+
raise PuppetLint::NoFix unless %i[WHITESPACE INDENT NEWLINE].include?(prev_token.type)
|
40
34
|
|
41
35
|
remove_token(prev_token)
|
42
36
|
prev_token = prev_token.prev_token
|
@@ -9,7 +9,7 @@ def new_single_space
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def after_bracket_tokens
|
12
|
-
%i[RBRACK RPAREN SEMIC COMMA COLON DOT NEWLINE DQMID DQPOST LBRACK]
|
12
|
+
%i[RBRACK RPAREN SEMIC COMMA COLON DOT NEWLINE DQMID DQPOST LBRACK HEREDOC_MID HEREDOC_POST]
|
13
13
|
end
|
14
14
|
|
15
15
|
def prev_non_space_token(token)
|
@@ -216,7 +216,7 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
216
216
|
end
|
217
217
|
|
218
218
|
it 'should detect a no problem' do
|
219
|
-
expect(problems).to
|
219
|
+
expect(problems).to be_empty
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
@@ -228,7 +228,7 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
228
228
|
end
|
229
229
|
|
230
230
|
it 'should detect a no problem' do
|
231
|
-
expect(problems).to
|
231
|
+
expect(problems).to be_empty
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
@@ -242,7 +242,7 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
242
242
|
end
|
243
243
|
|
244
244
|
it 'should detect a no problem' do
|
245
|
-
expect(problems).to
|
245
|
+
expect(problems).to be_empty
|
246
246
|
end
|
247
247
|
end
|
248
248
|
end
|
@@ -3,7 +3,9 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe 'manifest_whitespace_class_name_single_space_before' do
|
6
|
-
let(:single_space_msg) {
|
6
|
+
let(:single_space_msg) {
|
7
|
+
'there should be a single space between the class or defined resource statement and the name'
|
8
|
+
}
|
7
9
|
|
8
10
|
context 'with two spaces' do
|
9
11
|
let(:code) do
|
@@ -73,7 +75,7 @@ describe 'manifest_whitespace_class_name_single_space_before' do
|
|
73
75
|
end
|
74
76
|
|
75
77
|
it 'should detect no problems' do
|
76
|
-
expect(problems).to
|
78
|
+
expect(problems).to be_empty
|
77
79
|
end
|
78
80
|
end
|
79
81
|
end
|
@@ -91,7 +93,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
|
|
91
93
|
end
|
92
94
|
|
93
95
|
it 'should detect no problems' do
|
94
|
-
expect(problems).to
|
96
|
+
expect(problems).to be_empty
|
95
97
|
end
|
96
98
|
end
|
97
99
|
|
@@ -430,7 +432,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
|
|
430
432
|
end
|
431
433
|
|
432
434
|
it 'should detect no problem' do
|
433
|
-
expect(problems).to
|
435
|
+
expect(problems).to be_empty
|
434
436
|
end
|
435
437
|
end
|
436
438
|
end
|
@@ -43,7 +43,7 @@ describe 'manifest_whitespace_closing_brace_before' do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should detect no problems' do
|
46
|
-
expect(problems).to
|
46
|
+
expect(problems).to be_empty
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -59,7 +59,7 @@ describe 'manifest_whitespace_closing_brace_before' do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'should detect no problems' do
|
62
|
-
expect(problems).to
|
62
|
+
expect(problems).to be_empty
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -73,7 +73,7 @@ describe 'manifest_whitespace_closing_brace_before' do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'should detect no problems' do
|
76
|
-
expect(problems).to
|
76
|
+
expect(problems).to be_empty
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -402,7 +402,9 @@ describe 'manifest_whitespace_closing_brace_before' do
|
|
402
402
|
end
|
403
403
|
|
404
404
|
describe 'manifest_whitespace_closing_brace_after' do
|
405
|
-
let(:closing_brace_msg)
|
405
|
+
let(:closing_brace_msg) do
|
406
|
+
'there should be either a bracket, punctuation mark, closing quote or a newline after a closing brace, or whitespace and none of the aforementioned'
|
407
|
+
end
|
406
408
|
|
407
409
|
context 'with iterator' do
|
408
410
|
let(:code) do
|
@@ -413,7 +415,19 @@ describe 'manifest_whitespace_closing_brace_after' do
|
|
413
415
|
end
|
414
416
|
|
415
417
|
it 'should detect no problems' do
|
416
|
-
expect(problems).to
|
418
|
+
expect(problems).to be_empty
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
422
|
+
context 'inline with a function after' do
|
423
|
+
let(:code) do
|
424
|
+
<<~EOF
|
425
|
+
Hash({ $key => $return_value } )
|
426
|
+
EOF
|
427
|
+
end
|
428
|
+
|
429
|
+
it 'should detect 1 problem' do
|
430
|
+
expect(problems).to have(1).problem
|
417
431
|
end
|
418
432
|
end
|
419
433
|
|
@@ -43,7 +43,7 @@ describe 'manifest_whitespace_closing_bracket_before' do
|
|
43
43
|
|
44
44
|
context 'with fix disabled' do
|
45
45
|
it 'should detect 0 problems' do
|
46
|
-
expect(problems).to
|
46
|
+
expect(problems).to be_empty
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -153,7 +153,9 @@ describe 'manifest_whitespace_closing_bracket_before' do
|
|
153
153
|
end
|
154
154
|
|
155
155
|
describe 'manifest_whitespace_closing_bracket_after' do
|
156
|
-
let(:closing_bracket_msg) {
|
156
|
+
let(:closing_bracket_msg) {
|
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
|
+
}
|
157
159
|
|
158
160
|
context 'with many brackets' do
|
159
161
|
let(:code) do
|
@@ -163,7 +165,7 @@ describe 'manifest_whitespace_closing_bracket_after' do
|
|
163
165
|
end
|
164
166
|
|
165
167
|
it 'should detect no problems' do
|
166
|
-
expect(problems).to
|
168
|
+
expect(problems).to be_empty
|
167
169
|
end
|
168
170
|
end
|
169
171
|
|
@@ -179,7 +181,7 @@ describe 'manifest_whitespace_closing_bracket_after' do
|
|
179
181
|
end
|
180
182
|
|
181
183
|
it 'should detect no problems' do
|
182
|
-
expect(problems).to
|
184
|
+
expect(problems).to be_empty
|
183
185
|
end
|
184
186
|
end
|
185
187
|
|
@@ -302,4 +304,123 @@ describe 'manifest_whitespace_closing_bracket_after' do
|
|
302
304
|
end
|
303
305
|
end
|
304
306
|
end
|
307
|
+
|
308
|
+
context 'inside heredoc' do
|
309
|
+
describe 'issue10 example' do
|
310
|
+
let(:code) do
|
311
|
+
<<~CODE
|
312
|
+
file { '/tmp/test':
|
313
|
+
ensure => file,
|
314
|
+
owner => 'root',
|
315
|
+
group => 'root',
|
316
|
+
content => Sensitive(@("EOF")),
|
317
|
+
# hostname:port:database:username:password
|
318
|
+
127.0.0.1:5432:aos:${variable}:${hash['password']}
|
319
|
+
localhost:5432:aos:${variable}:${hash['password']}
|
320
|
+
| EOF
|
321
|
+
}
|
322
|
+
CODE
|
323
|
+
end
|
324
|
+
|
325
|
+
it 'should detect no problems' do
|
326
|
+
expect(problems).to be_empty
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
describe 'interpolated hash key in middle of line' do
|
331
|
+
let(:code) do
|
332
|
+
<<~CODE
|
333
|
+
$content = @("EOF")
|
334
|
+
somestring:${foo['bar']}:more
|
335
|
+
more stuff
|
336
|
+
| EOF
|
337
|
+
# more puppet code follows
|
338
|
+
CODE
|
339
|
+
end
|
340
|
+
|
341
|
+
it 'should detect no problems' do
|
342
|
+
expect(problems).to be_empty
|
343
|
+
end
|
344
|
+
|
345
|
+
context 'with unwanted whitespace' do
|
346
|
+
let(:code) do
|
347
|
+
<<~CODE
|
348
|
+
$content = @("EOF")
|
349
|
+
somestring:${foo['bar'] }:more
|
350
|
+
more stuff
|
351
|
+
| EOF
|
352
|
+
# more puppet code follows
|
353
|
+
CODE
|
354
|
+
end
|
355
|
+
|
356
|
+
it 'should detect 1 problem' do
|
357
|
+
expect(problems).to have(1).problem
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
describe 'interpolated hash key at end of line' do
|
363
|
+
let(:code) do
|
364
|
+
<<~CODE
|
365
|
+
$content = @("EOF")
|
366
|
+
somestring:${foo['bar']}
|
367
|
+
more stuff
|
368
|
+
| EOF
|
369
|
+
# more puppet code follows
|
370
|
+
CODE
|
371
|
+
end
|
372
|
+
|
373
|
+
it 'should detect no problems' do
|
374
|
+
expect(problems).to be_empty
|
375
|
+
end
|
376
|
+
|
377
|
+
context 'with unwanted whitespace' do
|
378
|
+
let(:code) do
|
379
|
+
<<~CODE
|
380
|
+
$content = @("EOF")
|
381
|
+
somestring:${foo['bar'] }
|
382
|
+
more stuff
|
383
|
+
| EOF
|
384
|
+
# more puppet code follows
|
385
|
+
CODE
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'should detect 1 problem' do
|
389
|
+
expect(problems).to have(1).problem
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
describe 'interpolated hash key at end of heredoc' do
|
395
|
+
let(:code) do
|
396
|
+
<<~CODE
|
397
|
+
$content = @("EOF")
|
398
|
+
# Some random heredoc preamble
|
399
|
+
somestring:${foo['bar']}
|
400
|
+
| EOF
|
401
|
+
# more puppet code follows
|
402
|
+
CODE
|
403
|
+
end
|
404
|
+
|
405
|
+
it 'should detect no problems' do
|
406
|
+
expect(problems).to be_empty
|
407
|
+
end
|
408
|
+
|
409
|
+
context 'with unwanted whitespace' do
|
410
|
+
let(:code) do
|
411
|
+
<<~CODE
|
412
|
+
$content = @("EOF")
|
413
|
+
# Some random heredoc preamble
|
414
|
+
somestring:${foo['bar'] }
|
415
|
+
| EOF
|
416
|
+
# more puppet code follows
|
417
|
+
CODE
|
418
|
+
end
|
419
|
+
|
420
|
+
it 'should detect 1 problem' do
|
421
|
+
expect(problems).to have(1).problem
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
305
426
|
end
|
@@ -18,7 +18,7 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should not detect any problems' do
|
21
|
-
expect(problems).to
|
21
|
+
expect(problems).to be_empty
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -28,8 +28,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
28
28
|
context 'with 1 empty line at the end of a manifest' do
|
29
29
|
let(:code) do
|
30
30
|
<<~EOF
|
31
|
-
|
32
|
-
|
31
|
+
class example {
|
32
|
+
}
|
33
33
|
|
34
34
|
EOF
|
35
35
|
end
|
@@ -46,8 +46,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
46
46
|
context 'with 3 empty lines at the end of a manifest' do
|
47
47
|
let(:code) do
|
48
48
|
<<~EOF
|
49
|
-
|
50
|
-
|
49
|
+
class example {
|
50
|
+
}
|
51
51
|
|
52
52
|
|
53
53
|
|
@@ -78,8 +78,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
78
78
|
context 'with 1 empty line at the end of a manifest' do
|
79
79
|
let(:code) do
|
80
80
|
<<~EOF
|
81
|
-
|
82
|
-
|
81
|
+
class example {
|
82
|
+
}
|
83
83
|
|
84
84
|
EOF
|
85
85
|
end
|
@@ -95,8 +95,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
95
95
|
it 'should add the final newline' do
|
96
96
|
expect(manifest).to eq(
|
97
97
|
<<~EOF
|
98
|
-
|
99
|
-
|
98
|
+
class example {
|
99
|
+
}
|
100
100
|
EOF
|
101
101
|
)
|
102
102
|
end
|
@@ -105,8 +105,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
105
105
|
context 'with 3 empty lines at the end of a manifest' do
|
106
106
|
let(:code) do
|
107
107
|
<<~EOF
|
108
|
-
|
109
|
-
|
108
|
+
class example {
|
109
|
+
}
|
110
110
|
|
111
111
|
|
112
112
|
|
@@ -126,8 +126,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
126
126
|
it 'should add the final newline' do
|
127
127
|
expect(manifest).to eq(
|
128
128
|
<<~EOF
|
129
|
-
|
130
|
-
|
129
|
+
class example {
|
130
|
+
}
|
131
131
|
EOF
|
132
132
|
)
|
133
133
|
end
|
@@ -15,7 +15,62 @@ describe 'manifest_whitespace_opening_brace_before' do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should detect no problems' do
|
18
|
-
expect(problems).to
|
18
|
+
expect(problems).to be_empty
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'inside interpolation' do
|
23
|
+
let(:code) do
|
24
|
+
<<~EOF
|
25
|
+
my_define { "foo-${myvar}": }
|
26
|
+
EOF
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should detect no problems' do
|
30
|
+
expect(problems).to be_empty
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'inline with a function before' do
|
35
|
+
let(:code) do
|
36
|
+
<<~EOF
|
37
|
+
Hash( { $key => $return_value })
|
38
|
+
EOF
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should detect 1 problem' do
|
42
|
+
expect(problems).to have(1).problem
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'inline with a function' do
|
47
|
+
let(:code) do
|
48
|
+
<<~EOF
|
49
|
+
Hash({ $key => $return_value })
|
50
|
+
EOF
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should detect no problems' do
|
54
|
+
expect(problems).to be_empty
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'inside a function' do
|
59
|
+
let(:code) do
|
60
|
+
<<~EOF
|
61
|
+
$my_var = lookup(
|
62
|
+
{
|
63
|
+
'name' => 'my_module::my_var',
|
64
|
+
'merge' => 'deep',
|
65
|
+
'value_type' => Array[Hash],
|
66
|
+
'default_value' => [],
|
67
|
+
}
|
68
|
+
)
|
69
|
+
EOF
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should detect no problems' do
|
73
|
+
expect(problems).to be_empty
|
19
74
|
end
|
20
75
|
end
|
21
76
|
|
@@ -30,7 +85,7 @@ describe 'manifest_whitespace_opening_brace_before' do
|
|
30
85
|
end
|
31
86
|
|
32
87
|
it 'should detect no problems' do
|
33
|
-
expect(problems).to
|
88
|
+
expect(problems).to be_empty
|
34
89
|
end
|
35
90
|
end
|
36
91
|
|
@@ -407,7 +462,7 @@ describe 'manifest_whitespace_opening_brace_before' do
|
|
407
462
|
|
408
463
|
context 'with fix disabled' do
|
409
464
|
it 'should detect a single problem' do
|
410
|
-
expect(problems).to
|
465
|
+
expect(problems).to be_empty
|
411
466
|
end
|
412
467
|
end
|
413
468
|
end
|
@@ -446,7 +501,7 @@ describe 'manifest_whitespace_opening_brace_before' do
|
|
446
501
|
|
447
502
|
context 'with fix disabled' do
|
448
503
|
it 'should detect no problem' do
|
449
|
-
expect(problems).to
|
504
|
+
expect(problems).to be_empty
|
450
505
|
end
|
451
506
|
end
|
452
507
|
end
|
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
describe 'manifest_whitespace_opening_bracket_before' do
|
6
6
|
let(:opening_bracket_msg) { 'there should be a single space before an opening bracket' }
|
7
7
|
|
8
|
-
context 'with
|
8
|
+
context 'with comment' do
|
9
9
|
let(:code) do
|
10
10
|
<<~EOF
|
11
11
|
{
|
@@ -16,7 +16,7 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should detect no problems' do
|
19
|
-
expect(problems).to
|
19
|
+
expect(problems).to be_empty
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -34,7 +34,24 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'should detect no problems' do
|
37
|
-
expect(problems).to
|
37
|
+
expect(problems).to be_empty
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with multiline iterator' do
|
42
|
+
let(:code) do
|
43
|
+
<<~EOF
|
44
|
+
include my::class
|
45
|
+
|
46
|
+
[
|
47
|
+
'a',
|
48
|
+
'b',
|
49
|
+
].each |$i| { }
|
50
|
+
EOF
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should detect no problems' do
|
54
|
+
expect(problems).to be_empty
|
38
55
|
end
|
39
56
|
end
|
40
57
|
|
@@ -75,7 +92,7 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
75
92
|
|
76
93
|
context 'with fix disabled' do
|
77
94
|
it 'should detect 0 problems' do
|
78
|
-
expect(problems).to
|
95
|
+
expect(problems).to be_empty
|
79
96
|
end
|
80
97
|
end
|
81
98
|
end
|
@@ -211,7 +228,7 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
211
228
|
|
212
229
|
context 'with fix disabled' do
|
213
230
|
it 'should detect a no problems' do
|
214
|
-
expect(problems).to
|
231
|
+
expect(problems).to be_empty
|
215
232
|
end
|
216
233
|
end
|
217
234
|
end
|
@@ -252,7 +269,7 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
252
269
|
|
253
270
|
context 'with fix disabled' do
|
254
271
|
it 'should detect a no problems' do
|
255
|
-
expect(problems).to
|
272
|
+
expect(problems).to be_empty
|
256
273
|
end
|
257
274
|
end
|
258
275
|
end
|
@@ -273,7 +290,7 @@ describe 'manifest_whitespace_opening_bracket_after' do
|
|
273
290
|
end
|
274
291
|
|
275
292
|
it 'should detect no problems' do
|
276
|
-
expect(problems).to
|
293
|
+
expect(problems).to be_empty
|
277
294
|
end
|
278
295
|
end
|
279
296
|
|
@@ -407,7 +424,7 @@ describe 'manifest_whitespace_opening_bracket_after' do
|
|
407
424
|
|
408
425
|
context 'with fix disabled' do
|
409
426
|
it 'should detect 0 problems' do
|
410
|
-
expect(problems).to
|
427
|
+
expect(problems).to be_empty
|
411
428
|
end
|
412
429
|
end
|
413
430
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-manifest_whitespace-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jo Vandeginste
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -149,8 +149,9 @@ files:
|
|
149
149
|
homepage: https://github.com/kuleuven/puppet-lint-manifest_whitespace-check
|
150
150
|
licenses:
|
151
151
|
- MIT
|
152
|
-
metadata:
|
153
|
-
|
152
|
+
metadata:
|
153
|
+
rubygems_mfa_required: 'true'
|
154
|
+
post_install_message:
|
154
155
|
rdoc_options: []
|
155
156
|
require_paths:
|
156
157
|
- lib
|
@@ -165,21 +166,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
166
|
- !ruby/object:Gem::Version
|
166
167
|
version: '0'
|
167
168
|
requirements: []
|
168
|
-
|
169
|
-
|
170
|
-
signing_key:
|
169
|
+
rubygems_version: 3.3.7
|
170
|
+
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: A puppet-lint check to validate whitespace in manifests
|
173
|
-
test_files:
|
174
|
-
- spec/spec_helper.rb
|
175
|
-
- spec/puppet-lint/plugins/manifest_whitespace_opening_bracket_spec.rb
|
176
|
-
- spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb
|
177
|
-
- spec/puppet-lint/plugins/manifest_whitespace_closing_bracket_spec.rb
|
178
|
-
- spec/puppet-lint/plugins/manifest_whitespace_missing_newline_end_of_file_spec.rb
|
179
|
-
- spec/puppet-lint/plugins/manifest_whitespace_newline_begin_of_file_spec.rb
|
180
|
-
- spec/puppet-lint/plugins/manifest_whitespace_closing_brace_spec.rb
|
181
|
-
- spec/puppet-lint/plugins/manifest_whitespace_class_header_spec.rb
|
182
|
-
- spec/puppet-lint/plugins/manifest_whitespace_double_newline_end_of_file_spec.rb
|
183
|
-
- spec/puppet-lint/plugins/manifest_whitespace_double_newline_spec.rb
|
184
|
-
- spec/puppet-lint/plugins/manifest_whitespace_arrow_spaces_spec.rb
|
185
|
-
- spec/puppet-lint/plugins/manifest_whitespace_opening_brace_spec.rb
|
173
|
+
test_files: []
|