puppet-lint-trailing_comma-check 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54c8aa1aee4468b15ba95fb44d739f5bf8cb7aa6701d2ef356b6fac6521c586c
4
- data.tar.gz: 4d7d7d5e31bb93253e68421761f2f949d03123bbedb7c75aba7b6a2037503a6e
3
+ metadata.gz: 86adcccda246662d25e00fa8d9daa1527e6203493c1ee0cbd2bda4e2c4b769cc
4
+ data.tar.gz: 26976dd1f21925da59d0a0ddc11339ab7a9a1044ae740267b237d601d1547637
5
5
  SHA512:
6
- metadata.gz: fdf70e104a01928c9eafdc0c71d7fc866552d4e8db6fcbf72403e93120f3c918bcf2321abca54051a8c3f0f290b1ede13482aab9b7b5293cbb374dd149bff226
7
- data.tar.gz: dbb02bce63093fa298adbf933e16f06de60a10e6030b2931957110b3f8c5680a4bc62acb5ae0fb3fd229a406ebee107171ebf5f54e63130c06dd671fbb3d723a
6
+ metadata.gz: 294d7eb8f6f53ea7c349b961ad0a6216aae23c95294b15c7b4089d42507e0743eb3685732c66cdbdfdeb119ff48a5caf95080c14ecee91485f89f2500bca42a7
7
+ data.tar.gz: 6b239638d055253653177221acf1a5c9d0b8e6611bd0825c611017236c64761995c0d79f96d93e3db5e3791f9f072486e57d83fd0f1b274e0d6cd4ffc25e3563
@@ -83,10 +83,19 @@ PuppetLint.new_check(:trailing_comma) do
83
83
 
84
84
  def check_elem(elem, except_type)
85
85
  lbo_token = elem[:tokens][-1].prev_code_token
86
+
87
+ # If we get a token indicating the end of a HEREDOC, backtrack
88
+ # until we find HEREDOC_OPEN. That is the line which should
89
+ # be examined for the comma.
90
+ if lbo_token && [:HEREDOC, :HEREDOC_POST].include?(lbo_token.type)
91
+ while lbo_token && lbo_token.type != :HEREDOC_OPEN do
92
+ lbo_token = lbo_token.prev_code_token
93
+ end
94
+ end
95
+
86
96
  if lbo_token && lbo_token.type != except_type && \
87
97
  elem[:tokens][-1].type != :SEMIC && \
88
98
  lbo_token.type != :COMMA && \
89
- lbo_token.type != :HEREDOC && \
90
99
  lbo_token.next_token.type == :NEWLINE
91
100
  notify :warning, {
92
101
  :message => 'missing trailing comma after last element',
@@ -95,17 +104,6 @@ PuppetLint.new_check(:trailing_comma) do
95
104
  :token => lbo_token.next_token,
96
105
  }
97
106
  end
98
- if lbo_token && lbo_token.type == :HEREDOC && \
99
- lbo_token.prev_code_token.type != :COMMA && \
100
- lbo_token.prev_code_token.next_token.type == :NEWLINE
101
- notify :warning, {
102
- :message => 'missing trailing comma after last element',
103
- :line => lbo_token.prev_code_token.next_token.line,
104
- :column => lbo_token.prev_code_token.next_token.column,
105
- :token => lbo_token.prev_code_token.next_token,
106
- }
107
- end
108
-
109
107
  end
110
108
 
111
109
  def check
@@ -153,6 +153,15 @@ describe 'trailing_comma' do
153
153
  World
154
154
  EOT
155
155
  }
156
+
157
+ file { '/tmp/test2.txt':
158
+ ensure => 'file',
159
+ content => @("FRAGMENT"),
160
+ ${var1}
161
+ some text
162
+ ${var2}
163
+ | FRAGMENT
164
+ }
156
165
  EOS
157
166
  }
158
167
 
@@ -171,15 +180,25 @@ describe 'trailing_comma' do
171
180
  World
172
181
  EOT
173
182
  }
183
+
184
+ file { '/tmp/test2.txt':
185
+ ensure => 'file',
186
+ content => @("FRAGMENT")
187
+ ${var1}
188
+ some text
189
+ ${var2}
190
+ | FRAGMENT
191
+ }
174
192
  EOS
175
193
  }
176
194
 
177
195
  it 'should detect a problem' do
178
- expect(problems).to have(1).problems
196
+ expect(problems).to have(2).problems
179
197
  end
180
198
 
181
199
  it 'should create a warning' do
182
200
  expect(problems).to contain_warning(msg).on_line(3).in_column(30)
201
+ expect(problems).to contain_warning(msg).on_line(11).in_column(37)
183
202
  end
184
203
  end
185
204
  end
@@ -391,6 +410,15 @@ describe 'trailing_comma' do
391
410
  World
392
411
  EOT
393
412
  }
413
+
414
+ file { '/tmp/test2.txt':
415
+ ensure => 'file',
416
+ content => @("FRAGMENT"),
417
+ ${var1}
418
+ some text
419
+ ${var2}
420
+ | FRAGMENT
421
+ }
394
422
  EOS
395
423
  }
396
424
 
@@ -413,15 +441,25 @@ describe 'trailing_comma' do
413
441
  World
414
442
  EOT
415
443
  }
444
+
445
+ file { '/tmp/test2.txt':
446
+ ensure => 'file',
447
+ content => @("FRAGMENT")
448
+ ${var1}
449
+ some text
450
+ ${var2}
451
+ | FRAGMENT
452
+ }
416
453
  EOS
417
454
  }
418
455
 
419
456
  it 'should detect a problem' do
420
- expect(problems).to have(1).problems
457
+ expect(problems).to have(2).problems
421
458
  end
422
459
 
423
460
  it 'should create a warning' do
424
461
  expect(problems).to contain_fixed(msg).on_line(3).in_column(30)
462
+ expect(problems).to contain_fixed(msg).on_line(11).in_column(37)
425
463
  end
426
464
 
427
465
  it 'should add trailing commas' do
@@ -434,6 +472,15 @@ describe 'trailing_comma' do
434
472
  World
435
473
  EOT
436
474
  }
475
+
476
+ file { '/tmp/test2.txt':
477
+ ensure => 'file',
478
+ content => @("FRAGMENT"),
479
+ ${var1}
480
+ some text
481
+ ${var2}
482
+ | FRAGMENT
483
+ }
437
484
  EOS
438
485
  )
439
486
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-trailing_comma-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Community
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-20 00:00:00.000000000 Z
11
+ date: 2018-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint