puppet-lint-manifest_whitespace-check 0.1.17 → 0.2.0
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_opening_brace.rb +1 -1
- 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 +3 -3
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_brace_spec.rb +4 -4
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_bracket_spec.rb +122 -3
- data/spec/puppet-lint/plugins/manifest_whitespace_double_newline_end_of_file_spec.rb +1 -1
- 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 +23 -4
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_bracket_spec.rb +26 -8
- metadata +6 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73d348cb4f0a000a02c631f97562527a401f7e61f2954e31e8841c9095b32a8f
|
4
|
+
data.tar.gz: 7fbdd7c452078510f2ae545a93f492f3effd982775cfce706ed7d41219eaa282
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e5df8707c5cbbe5a05bac3b1f16542e1df5c02cc41f4ca5a4d2e97eda2508bb5aa25601bbce7e04a3f06c6803a96dbd69752cd43be33d6f7dd69f23ff1c54dc
|
7
|
+
data.tar.gz: c0c670b007c1456d68a59635e3e29da5ffbc9bdc0e3ff3c0cc1623766180665ef2180b3fff0b584b7ae9bee29243e618b92a7b9030880c3d965b090ac802a790
|
@@ -7,7 +7,7 @@ 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
|
-
if %i[LBRACK LBRACE COLON COMMA COMMENT].include?(prev_code_token.type)
|
10
|
+
if %i[LPAREN LBRACK LBRACE COLON COMMA COMMENT].include?(prev_code_token.type)
|
11
11
|
next
|
12
12
|
end
|
13
13
|
next unless tokens.index(prev_code_token) != tokens.index(brace_token) - 2 ||
|
@@ -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
|
@@ -73,7 +73,7 @@ describe 'manifest_whitespace_class_name_single_space_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
|
end
|
@@ -91,7 +91,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
|
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'should detect no problems' do
|
94
|
-
expect(problems).to
|
94
|
+
expect(problems).to be_empty
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -430,7 +430,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
|
|
430
430
|
end
|
431
431
|
|
432
432
|
it 'should detect no problem' do
|
433
|
-
expect(problems).to
|
433
|
+
expect(problems).to be_empty
|
434
434
|
end
|
435
435
|
end
|
436
436
|
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
|
|
@@ -413,7 +413,7 @@ describe 'manifest_whitespace_closing_brace_after' do
|
|
413
413
|
end
|
414
414
|
|
415
415
|
it 'should detect no problems' do
|
416
|
-
expect(problems).to
|
416
|
+
expect(problems).to be_empty
|
417
417
|
end
|
418
418
|
end
|
419
419
|
|
@@ -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
|
@@ -163,7 +163,7 @@ describe 'manifest_whitespace_closing_bracket_after' do
|
|
163
163
|
end
|
164
164
|
|
165
165
|
it 'should detect no problems' do
|
166
|
-
expect(problems).to
|
166
|
+
expect(problems).to be_empty
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
@@ -179,7 +179,7 @@ describe 'manifest_whitespace_closing_bracket_after' do
|
|
179
179
|
end
|
180
180
|
|
181
181
|
it 'should detect no problems' do
|
182
|
-
expect(problems).to
|
182
|
+
expect(problems).to be_empty
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
@@ -302,4 +302,123 @@ describe 'manifest_whitespace_closing_bracket_after' do
|
|
302
302
|
end
|
303
303
|
end
|
304
304
|
end
|
305
|
+
|
306
|
+
context 'inside heredoc' do
|
307
|
+
describe 'issue10 example' do
|
308
|
+
let(:code) do
|
309
|
+
<<~CODE
|
310
|
+
file { '/tmp/test':
|
311
|
+
ensure => file,
|
312
|
+
owner => 'root',
|
313
|
+
group => 'root',
|
314
|
+
content => Sensitive(@("EOF")),
|
315
|
+
# hostname:port:database:username:password
|
316
|
+
127.0.0.1:5432:aos:${variable}:${hash['password']}
|
317
|
+
localhost:5432:aos:${variable}:${hash['password']}
|
318
|
+
| EOF
|
319
|
+
}
|
320
|
+
CODE
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'should detect no problems' do
|
324
|
+
expect(problems).to be_empty
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
describe 'interpolated hash key in middle of line' do
|
329
|
+
let(:code) do
|
330
|
+
<<~CODE
|
331
|
+
$content = @("EOF")
|
332
|
+
somestring:${foo['bar']}:more
|
333
|
+
more stuff
|
334
|
+
| EOF
|
335
|
+
# more puppet code follows
|
336
|
+
CODE
|
337
|
+
end
|
338
|
+
|
339
|
+
it 'should detect no problems' do
|
340
|
+
expect(problems).to be_empty
|
341
|
+
end
|
342
|
+
|
343
|
+
context 'with unwanted whitespace' do
|
344
|
+
let(:code) do
|
345
|
+
<<~CODE
|
346
|
+
$content = @("EOF")
|
347
|
+
somestring:${foo['bar'] }:more
|
348
|
+
more stuff
|
349
|
+
| EOF
|
350
|
+
# more puppet code follows
|
351
|
+
CODE
|
352
|
+
end
|
353
|
+
|
354
|
+
it 'should detect 1 problem' do
|
355
|
+
expect(problems).to have(1).problem
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
describe 'interpolated hash key at end of line' do
|
361
|
+
let(:code) do
|
362
|
+
<<~CODE
|
363
|
+
$content = @("EOF")
|
364
|
+
somestring:${foo['bar']}
|
365
|
+
more stuff
|
366
|
+
| EOF
|
367
|
+
# more puppet code follows
|
368
|
+
CODE
|
369
|
+
end
|
370
|
+
|
371
|
+
it 'should detect no problems' do
|
372
|
+
expect(problems).to be_empty
|
373
|
+
end
|
374
|
+
|
375
|
+
context 'with unwanted whitespace' do
|
376
|
+
let(:code) do
|
377
|
+
<<~CODE
|
378
|
+
$content = @("EOF")
|
379
|
+
somestring:${foo['bar'] }
|
380
|
+
more stuff
|
381
|
+
| EOF
|
382
|
+
# more puppet code follows
|
383
|
+
CODE
|
384
|
+
end
|
385
|
+
|
386
|
+
it 'should detect 1 problem' do
|
387
|
+
expect(problems).to have(1).problem
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
describe 'interpolated hash key at end of heredoc' do
|
393
|
+
let(:code) do
|
394
|
+
<<~CODE
|
395
|
+
$content = @("EOF")
|
396
|
+
# Some random heredoc preamble
|
397
|
+
somestring:${foo['bar']}
|
398
|
+
| EOF
|
399
|
+
# more puppet code follows
|
400
|
+
CODE
|
401
|
+
end
|
402
|
+
|
403
|
+
it 'should detect no problems' do
|
404
|
+
expect(problems).to be_empty
|
405
|
+
end
|
406
|
+
|
407
|
+
context 'with unwanted whitespace' do
|
408
|
+
let(:code) do
|
409
|
+
<<~CODE
|
410
|
+
$content = @("EOF")
|
411
|
+
# Some random heredoc preamble
|
412
|
+
somestring:${foo['bar'] }
|
413
|
+
| EOF
|
414
|
+
# more puppet code follows
|
415
|
+
CODE
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'should detect 1 problem' do
|
419
|
+
expect(problems).to have(1).problem
|
420
|
+
end
|
421
|
+
end
|
422
|
+
end
|
423
|
+
end
|
305
424
|
end
|
@@ -15,7 +15,26 @@ 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 a function' do
|
23
|
+
let(:code) do
|
24
|
+
<<~EOF
|
25
|
+
$my_var = lookup(
|
26
|
+
{
|
27
|
+
'name' => 'my_module::my_var',
|
28
|
+
'merge' => 'deep',
|
29
|
+
'value_type' => Array[Hash],
|
30
|
+
'default_value' => [],
|
31
|
+
}
|
32
|
+
)
|
33
|
+
EOF
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should detect no problems' do
|
37
|
+
expect(problems).to be_empty
|
19
38
|
end
|
20
39
|
end
|
21
40
|
|
@@ -30,7 +49,7 @@ describe 'manifest_whitespace_opening_brace_before' do
|
|
30
49
|
end
|
31
50
|
|
32
51
|
it 'should detect no problems' do
|
33
|
-
expect(problems).to
|
52
|
+
expect(problems).to be_empty
|
34
53
|
end
|
35
54
|
end
|
36
55
|
|
@@ -407,7 +426,7 @@ describe 'manifest_whitespace_opening_brace_before' do
|
|
407
426
|
|
408
427
|
context 'with fix disabled' do
|
409
428
|
it 'should detect a single problem' do
|
410
|
-
expect(problems).to
|
429
|
+
expect(problems).to be_empty
|
411
430
|
end
|
412
431
|
end
|
413
432
|
end
|
@@ -446,7 +465,7 @@ describe 'manifest_whitespace_opening_brace_before' do
|
|
446
465
|
|
447
466
|
context 'with fix disabled' do
|
448
467
|
it 'should detect no problem' do
|
449
|
-
expect(problems).to
|
468
|
+
expect(problems).to be_empty
|
450
469
|
end
|
451
470
|
end
|
452
471
|
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,25 @@ 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
|
+
pending 'Fix the linter'
|
55
|
+
expect(problems).to be_empty
|
38
56
|
end
|
39
57
|
end
|
40
58
|
|
@@ -75,7 +93,7 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
75
93
|
|
76
94
|
context 'with fix disabled' do
|
77
95
|
it 'should detect 0 problems' do
|
78
|
-
expect(problems).to
|
96
|
+
expect(problems).to be_empty
|
79
97
|
end
|
80
98
|
end
|
81
99
|
end
|
@@ -211,7 +229,7 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
211
229
|
|
212
230
|
context 'with fix disabled' do
|
213
231
|
it 'should detect a no problems' do
|
214
|
-
expect(problems).to
|
232
|
+
expect(problems).to be_empty
|
215
233
|
end
|
216
234
|
end
|
217
235
|
end
|
@@ -252,7 +270,7 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
252
270
|
|
253
271
|
context 'with fix disabled' do
|
254
272
|
it 'should detect a no problems' do
|
255
|
-
expect(problems).to
|
273
|
+
expect(problems).to be_empty
|
256
274
|
end
|
257
275
|
end
|
258
276
|
end
|
@@ -273,7 +291,7 @@ describe 'manifest_whitespace_opening_bracket_after' do
|
|
273
291
|
end
|
274
292
|
|
275
293
|
it 'should detect no problems' do
|
276
|
-
expect(problems).to
|
294
|
+
expect(problems).to be_empty
|
277
295
|
end
|
278
296
|
end
|
279
297
|
|
@@ -407,7 +425,7 @@ describe 'manifest_whitespace_opening_bracket_after' do
|
|
407
425
|
|
408
426
|
context 'with fix disabled' do
|
409
427
|
it 'should detect 0 problems' do
|
410
|
-
expect(problems).to
|
428
|
+
expect(problems).to be_empty
|
411
429
|
end
|
412
430
|
end
|
413
431
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jo Vandeginste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -149,7 +149,8 @@ files:
|
|
149
149
|
homepage: https://github.com/kuleuven/puppet-lint-manifest_whitespace-check
|
150
150
|
licenses:
|
151
151
|
- MIT
|
152
|
-
metadata:
|
152
|
+
metadata:
|
153
|
+
rubygems_mfa_required: 'true'
|
153
154
|
post_install_message:
|
154
155
|
rdoc_options: []
|
155
156
|
require_paths:
|
@@ -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
|
-
rubygems_version: 2.7.7
|
169
|
+
rubygems_version: 3.3.7
|
170
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: []
|