puppet-lint-manifest_whitespace-check 0.1.16 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af72a48c82a227107871c1e7b83a3bec2a101aab3cef89bbd3d6ce426122334d
4
- data.tar.gz: c7bc25b60155836000ec44971dd88832fafd413cac0e89107c49be5e86e804c1
3
+ metadata.gz: 73d348cb4f0a000a02c631f97562527a401f7e61f2954e31e8841c9095b32a8f
4
+ data.tar.gz: 7fbdd7c452078510f2ae545a93f492f3effd982775cfce706ed7d41219eaa282
5
5
  SHA512:
6
- metadata.gz: 24961bb90cab1231db45ad634bf31444a276645d371401168956a436dd977e23166b19d5b1880e96d8ebfc64c3c53da68c4a65e92643a421094fae5a693ec2f0
7
- data.tar.gz: c57d69810e67d335b597cb8257d627a07ac6c31fde14e37f64b8c05e4bb83fc750ca9e87699689211f299268ca287e89d76835259667d6b0876c3ed94f40b04e
6
+ metadata.gz: 1e5df8707c5cbbe5a05bac3b1f16542e1df5c02cc41f4ca5a4d2e97eda2508bb5aa25601bbce7e04a3f06c6803a96dbd69752cd43be33d6f7dd69f23ff1c54dc
7
+ data.tar.gz: c0c670b007c1456d68a59635e3e29da5ffbc9bdc0e3ff3c0cc1623766180665ef2180b3fff0b584b7ae9bee29243e618b92a7b9030880c3d965b090ac802a790
@@ -43,20 +43,22 @@ PuppetLint.new_check(:manifest_whitespace_class_name_single_space_after) do
43
43
  notify(
44
44
  :error,
45
45
  message: 'there should be a single space between the class or resource name and the next item',
46
- line: next_token.line,
47
- column: next_token.column,
48
- token: next_token,
46
+ line: name_token.line,
47
+ column: name_token.column,
48
+ token: name_token,
49
49
  )
50
50
  end
51
51
  end
52
52
 
53
53
  def fix(problem)
54
54
  token = problem[:token]
55
- next_code_token = next_non_space_token(token.prev_token)
56
55
 
57
- while token != next_code_token
58
- remove_token(token)
59
- token = token.next_token
56
+ next_token = token.next_token
57
+ next_code_token = next_non_space_token(token)
58
+
59
+ while next_token != next_code_token
60
+ remove_token(next_token)
61
+ next_token = next_token.next_token
60
62
  end
61
63
 
62
64
  add_token(tokens.index(next_code_token), new_single_space)
@@ -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 have(0).problems
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 have(0).problems
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 have(0).problems
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 have(0).problem
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 have(0).problem
94
+ expect(problems).to be_empty
95
95
  end
96
96
  end
97
97
 
@@ -119,7 +119,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
119
119
  end
120
120
 
121
121
  it 'should create a error' do
122
- expect(problems).to contain_error(single_space_msg).on_line(6).in_column(14)
122
+ expect(problems).to contain_error(single_space_msg).on_line(6).in_column(7)
123
123
  end
124
124
  end
125
125
 
@@ -183,7 +183,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
183
183
  end
184
184
 
185
185
  it 'should create a error' do
186
- expect(problems).to contain_error(single_space_msg).on_line(6).in_column(24)
186
+ expect(problems).to contain_error(single_space_msg).on_line(6).in_column(7)
187
187
  end
188
188
  end
189
189
 
@@ -245,7 +245,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
245
245
  end
246
246
 
247
247
  it 'should create a error' do
248
- expect(problems).to contain_error(single_space_msg).on_line(6).in_column(14)
248
+ expect(problems).to contain_error(single_space_msg).on_line(6).in_column(7)
249
249
  end
250
250
  end
251
251
 
@@ -307,7 +307,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
307
307
  end
308
308
 
309
309
  it 'should create a error' do
310
- expect(problems).to contain_error(single_space_msg).on_line(6).in_column(14)
310
+ expect(problems).to contain_error(single_space_msg).on_line(6).in_column(7)
311
311
  end
312
312
  end
313
313
 
@@ -372,7 +372,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
372
372
  end
373
373
 
374
374
  it 'should create a error' do
375
- expect(problems).to contain_error(single_space_msg).on_line(6).in_column(14)
375
+ expect(problems).to contain_error(single_space_msg).on_line(6).in_column(7)
376
376
  end
377
377
  end
378
378
 
@@ -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 have(0).problems
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 have(0).problem
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 have(0).problem
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 have(0).problem
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 have(0).problem
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 have(0).problem
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 have(0).problem
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 have(0).problem
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
@@ -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 have(0).problems
21
+ expect(problems).to be_empty
22
22
  end
23
23
  end
24
24
 
@@ -20,7 +20,7 @@ describe 'manifest_whitespace_newline_beginning_of_file' do
20
20
  end
21
21
 
22
22
  it 'should not detect any problems' do
23
- expect(problems).to have(0).problems
23
+ expect(problems).to be_empty
24
24
  end
25
25
  end
26
26
 
@@ -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 have(0).problem
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,47 @@ describe 'manifest_whitespace_opening_brace_before' do
30
49
  end
31
50
 
32
51
  it 'should detect no problems' do
33
- expect(problems).to have(0).problem
52
+ expect(problems).to be_empty
53
+ end
54
+ end
55
+
56
+ context 'with class no spaces' do
57
+ let(:code) do
58
+ <<~EOF
59
+ class example{
60
+ # some generic comment
61
+ }
62
+ EOF
63
+ end
64
+
65
+ context 'with fix disabled' do
66
+ it 'should detect a problem' do
67
+ expect(problems).to have(1).problem
68
+ end
69
+
70
+ it 'should create a error' do
71
+ expect(problems).to contain_error(opening_brace_msg).on_line(1).in_column(14)
72
+ end
73
+ end
74
+
75
+ context 'with fix enabled' do
76
+ before do
77
+ PuppetLint.configuration.fix = true
78
+ end
79
+
80
+ after do
81
+ PuppetLint.configuration.fix = false
82
+ end
83
+
84
+ it 'should add a space' do
85
+ expect(manifest).to eq(
86
+ <<~EOF,
87
+ class example {
88
+ # some generic comment
89
+ }
90
+ EOF
91
+ )
92
+ end
34
93
  end
35
94
  end
36
95
 
@@ -367,7 +426,7 @@ describe 'manifest_whitespace_opening_brace_before' do
367
426
 
368
427
  context 'with fix disabled' do
369
428
  it 'should detect a single problem' do
370
- expect(problems).to have(0).problem
429
+ expect(problems).to be_empty
371
430
  end
372
431
  end
373
432
  end
@@ -406,7 +465,7 @@ describe 'manifest_whitespace_opening_brace_before' do
406
465
 
407
466
  context 'with fix disabled' do
408
467
  it 'should detect no problem' do
409
- expect(problems).to have(0).problems
468
+ expect(problems).to be_empty
410
469
  end
411
470
  end
412
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 iterator' do
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 have(0).problem
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 have(0).problem
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 have(0).problem
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 have(0).problem
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 have(0).problem
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 have(0).problem
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 have(0).problem
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.1.16
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: 2020-06-26 00:00:00.000000000 Z
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
- rubyforge_project:
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: []