puppet-lint-trailing_comma-check 3.0.0 → 3.0.1

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: 0c9f46f9eb5dcd7e422c2bb43a826240fe03ba9f72ff22308df4ac0033f785b7
4
- data.tar.gz: dc033e54cb68f116b8c154c85341ca872c6990ab97cc738d753b6266b7756fe2
3
+ metadata.gz: 6ac708c60b0d04b2fee14b3c0a02a94b24ee33e4e20859b497e00871c964c8d1
4
+ data.tar.gz: 642166230b6b41d80b88d3eda8aa9437786477eee943b79f06482f0b5bd45a06
5
5
  SHA512:
6
- metadata.gz: 4acfb16cb9d12f6a13278e384b12c0768d5082dc987c16edc25805512afc07201433a4ee0dc832f3cb8b0c3a36790233886514e8f969f83400fff8d8915d662a
7
- data.tar.gz: 6f0089157a3db72afc963c7f4ce1234d4698c647fd5013ab5f4641c8e5dd90ce735f7e8a9a47faa455544a4e73b3759dde1e6ba28c95f4ae5771011f3eaa9444
6
+ metadata.gz: cba19b819fa4d2274bdccbea79ba3721041c918bfd769b56044a3a9f785820a6dd8794915690784c1f8e2d3753ab4323b36bdcf71913c1584abdacd58a2a1723
7
+ data.tar.gz: d08b41b79afa570a7bde19c427cb9dbd42367a5470e60b1374b8ae3c86d8975e79f31911603d567e90297254f2802c4452fceada8058d44364476557b4d88d35
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [3.0.1](https://github.com/voxpupuli/puppet-lint-trailing_comma-check/tree/3.0.1) (2025-12-09)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/puppet-lint-trailing_comma-check/compare/3.0.0...3.0.1)
8
+
9
+ **Fixed bugs:**
10
+
11
+ - Autofix adds double comma on nested structure [\#44](https://github.com/voxpupuli/puppet-lint-trailing_comma-check/issues/44)
12
+ - Fix bracket matching of nested arrays [\#45](https://github.com/voxpupuli/puppet-lint-trailing_comma-check/pull/45) ([alexjfisher](https://github.com/alexjfisher))
13
+
5
14
  ## [3.0.0](https://github.com/voxpupuli/puppet-lint-trailing_comma-check/tree/3.0.0) (2025-09-25)
6
15
 
7
16
  [Full Changelog](https://github.com/voxpupuli/puppet-lint-trailing_comma-check/compare/2.0.0...3.0.0)
@@ -5,10 +5,14 @@ PuppetLint.new_check(:trailing_comma) do
5
5
  tokens.each_with_index do |token, token_idx|
6
6
  next unless token.type == :LBRACK
7
7
 
8
+ level = 0
8
9
  real_idx = 0
9
10
  tokens[token_idx + 1..-1].each_with_index do |cur_token, cur_token_idx|
10
11
  real_idx = token_idx + 1 + cur_token_idx
11
- break if cur_token.type == :RBRACK
12
+
13
+ level += 1 if cur_token.type == :LBRACK
14
+ level -= 1 if cur_token.type == :RBRACK
15
+ break if level < 0
12
16
  end
13
17
 
14
18
  # Ignore resource references
@@ -167,6 +167,31 @@ describe 'trailing_comma' do
167
167
  expect(problems).to contain_warning(msg).on_line(46).in_column(25)
168
168
  expect(problems).to contain_warning(msg).on_line(58).in_column(14)
169
169
  end
170
+
171
+ context 'with nested arrays' do
172
+ let(:code) do
173
+ <<~EOS
174
+ class { 'myclass':
175
+ directives => [
176
+ {
177
+ directives => [
178
+ 'if net = 0.0.0.0/0 then reject',
179
+ 'else accept'
180
+ ],
181
+ },
182
+ ],
183
+ }
184
+ EOS
185
+ end
186
+
187
+ it 'detects 1 problem' do
188
+ expect(problems).to have(1).problems
189
+ end
190
+
191
+ it 'creates a warning' do
192
+ expect(problems).to contain_warning(msg).on_line(6).in_column(24)
193
+ end
194
+ end
170
195
  end
171
196
 
172
197
  context 'with heredoc' do
@@ -458,6 +483,44 @@ describe 'trailing_comma' do
458
483
  EOS
459
484
  )
460
485
  end
486
+
487
+ context 'with nested arrays' do
488
+ let(:code) do
489
+ <<~EOS
490
+ class { 'myclass':
491
+ directives => [
492
+ {
493
+ directives => [
494
+ 'if net = 0.0.0.0/0 then reject',
495
+ 'else accept'
496
+ ],
497
+ },
498
+ ],
499
+ }
500
+ EOS
501
+ end
502
+
503
+ it 'detects 1 problem' do
504
+ expect(problems).to have(1).problems
505
+ end
506
+
507
+ it 'adds single trailing comma' do
508
+ expect(manifest).to eq(
509
+ <<~EOS,
510
+ class { 'myclass':
511
+ directives => [
512
+ {
513
+ directives => [
514
+ 'if net = 0.0.0.0/0 then reject',
515
+ 'else accept',
516
+ ],
517
+ },
518
+ ],
519
+ }
520
+ EOS
521
+ )
522
+ end
523
+ end
461
524
  end
462
525
 
463
526
  context 'with heredoc' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-trailing_comma-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli