puppet-lint-array_formatting-check 0.10.0 → 0.11.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 253a737a788c7d2d46e0452562fa67d5177f096204039fb294f98633c5435b70
|
4
|
+
data.tar.gz: 44a81890888cd86b28cd8ba156b311f2e370b6a02f6a5ba3a1d8db74e87652aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 927806a62b811ac503f789a3f9a7eca73307bf162dc16c42eb78f5368983732dcf3ebf1d9df8c7aec2261a2b374c032e09c9364c85871732415a14f48e97f8a5
|
7
|
+
data.tar.gz: 13c068cb3b5a180d3f0c42dc799686343bed9eae54c450e4ed8d307859f21efb50ac8ce2ed343070032bb2bd73a7d0746807cb20db8726e42754e98a9dec9a20
|
@@ -24,9 +24,19 @@ PuppetLint.new_check(:array_formatting) do
|
|
24
24
|
# Recursively process this nested array.
|
25
25
|
# Store return so we know if the child array was processed or not.
|
26
26
|
len_of_nested_array = process_array
|
27
|
-
# If we encounter
|
28
|
-
|
29
|
-
|
27
|
+
# If we encounter a DQPRE, we need to scan ahead until we find the matching DQPOST
|
28
|
+
elsif [:DQPRE].include?(token.type)
|
29
|
+
# Tight loop until we find a DQPOST, or a Nil in case of an unterminated string
|
30
|
+
until [:DQPOST].include?(token.type) || token.nil?
|
31
|
+
# Advance. We're still looking for that DQPOST
|
32
|
+
token = @manifest.next
|
33
|
+
end
|
34
|
+
# Store the DQPOST
|
35
|
+
manifest_array.push token
|
36
|
+
# We're really only keeping track of array *items* here for the sake of the length calculation.
|
37
|
+
# We're going to ignore everything that doesn't count as an *item*, like commas, comments, and whitespaces
|
38
|
+
# We need to push NEWLINE(s) though because there might be too many
|
39
|
+
elsif !%i[COMMA COMMENT WHITESPACE INDENT].include?(token.type)
|
30
40
|
manifest_array.push token
|
31
41
|
end
|
32
42
|
# Advance. (We're still looking for that RBRACK)
|
@@ -85,7 +95,7 @@ PuppetLint.new_check(:array_formatting) do
|
|
85
95
|
# If the last token (not including the RBRACK) wasn't a newline, throw a warning.
|
86
96
|
# Since we previously used token to scan forward to the ],
|
87
97
|
# token is already pointing to the offending ].
|
88
|
-
if !prev_token_was_newline # rubocop:disable NegatedIf "I find this clearer than `unless prev_token_was_newline`"
|
98
|
+
if !prev_token_was_newline # rubocop:disable Style/NegatedIf "I find this clearer than `unless prev_token_was_newline`"
|
89
99
|
notify :warning,
|
90
100
|
message: EXPECTED_NEWLINE_BEFORE_CLOSE,
|
91
101
|
line: token.line,
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'array_formatting' do
|
6
|
+
let(:msg) { 'expected newline before element' }
|
7
|
+
let(:msg_end) { 'expected newline before close' }
|
8
|
+
let(:msg_newline) { 'unexpected newline' }
|
9
|
+
|
10
|
+
context 'with fix disabled' do
|
11
|
+
context 'on code with an empty array' do
|
12
|
+
let(:code) { '$services = []' }
|
13
|
+
|
14
|
+
it 'should detect no problem' do
|
15
|
+
expect(problems).to have(0).problems
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
context 'with fix enabled' do
|
20
|
+
before do
|
21
|
+
PuppetLint.configuration.fix = true
|
22
|
+
end
|
23
|
+
|
24
|
+
after do
|
25
|
+
PuppetLint.configuration.fix = false
|
26
|
+
end
|
27
|
+
context 'on code with an empty array' do
|
28
|
+
let(:code) { '$services = []' }
|
29
|
+
|
30
|
+
it 'should detect no problem' do
|
31
|
+
expect(problems).to have(0).problems
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should not modify the manifest' do
|
35
|
+
expect(manifest).to eq(code)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -381,6 +381,68 @@ describe 'array_formatting' do
|
|
381
381
|
expect(problems).to contain_warning(msg_end).on_line(14).in_column(42)
|
382
382
|
end
|
383
383
|
end
|
384
|
+
context 'on a string with a properly formatted multidimensional hash (Issue #18)' do
|
385
|
+
let(:code) do
|
386
|
+
<<-CODE.gsub(/^ {10}/, '')
|
387
|
+
Apt::Source["yubihsm-${facts['os']['distro']['codename']}"],
|
388
|
+
CODE
|
389
|
+
end
|
390
|
+
it 'should detect no problem' do
|
391
|
+
expect(problems).to have(0).problems
|
392
|
+
end
|
393
|
+
end
|
394
|
+
context 'on a code snippet with a properly formatted multidimensional hash (Issue #18)' do
|
395
|
+
let(:code) do
|
396
|
+
<<-CODE.gsub(/^ {10}/, '')
|
397
|
+
package { $packages:
|
398
|
+
ensure => $version,
|
399
|
+
require => [
|
400
|
+
Class['apt::update'],
|
401
|
+
Apt::Source["yubihsm-${facts['os']['distro']['codename']}"],
|
402
|
+
],
|
403
|
+
}
|
404
|
+
CODE
|
405
|
+
end
|
406
|
+
it 'should detect no problem' do
|
407
|
+
expect(problems).to have(0).problems
|
408
|
+
end
|
409
|
+
end
|
410
|
+
context 'on a string with a properly formatted variable (Issue #19)' do
|
411
|
+
let(:code) do
|
412
|
+
<<-CODE.gsub(/^ {10}/, '')
|
413
|
+
file { [
|
414
|
+
"${root_dir}/index.txt",
|
415
|
+
"${root_dir}/index.txt.attr"
|
416
|
+
]:
|
417
|
+
ensure => file,
|
418
|
+
owner => 0,
|
419
|
+
group => 0,
|
420
|
+
mode => '0400',
|
421
|
+
}
|
422
|
+
CODE
|
423
|
+
end
|
424
|
+
it 'should detect no problem' do
|
425
|
+
expect(problems).to have(0).problems
|
426
|
+
end
|
427
|
+
end
|
428
|
+
context 'on an array with comments after some values (Issue #20)' do
|
429
|
+
let(:code) do
|
430
|
+
<<-CODE.gsub(/^ {10}/, '')
|
431
|
+
proxy_set_header => [
|
432
|
+
'Host $http_host:8043',
|
433
|
+
'X-Real-IP $remote_addr',
|
434
|
+
'X-Forwarded-For $proxy_add_x_forwarded_for',
|
435
|
+
'Cookie $http_cookie',
|
436
|
+
'X-Forwarded-Proto $scheme',
|
437
|
+
'Upgrade $http_upgrade', #websockets
|
438
|
+
'Connection "Upgrade"', #websockets
|
439
|
+
],
|
440
|
+
CODE
|
441
|
+
end
|
442
|
+
it 'should detect no problem' do
|
443
|
+
expect(problems).to have(0).problems
|
444
|
+
end
|
445
|
+
end
|
384
446
|
end
|
385
447
|
context 'with fix enabled' do
|
386
448
|
before do
|
@@ -1016,5 +1078,83 @@ describe 'array_formatting' do
|
|
1016
1078
|
)
|
1017
1079
|
end
|
1018
1080
|
end
|
1081
|
+
context 'on a string with a properly formatted multidimensional hash (Issue #18)' do
|
1082
|
+
let(:code) do
|
1083
|
+
<<-CODE.gsub(/^ {10}/, '')
|
1084
|
+
Apt::Source["yubihsm-${facts['os']['distro']['codename']}"],
|
1085
|
+
CODE
|
1086
|
+
end
|
1087
|
+
it 'should detect no problem' do
|
1088
|
+
expect(problems).to have(0).problems
|
1089
|
+
end
|
1090
|
+
|
1091
|
+
it 'should not modify the manifest' do
|
1092
|
+
expect(manifest).to eq(code)
|
1093
|
+
end
|
1094
|
+
end
|
1095
|
+
context 'on a code snippet with a properly formatted multidimensional hash (Issue #18)' do
|
1096
|
+
let(:code) do
|
1097
|
+
<<-CODE.gsub(/^ {10}/, '')
|
1098
|
+
package { $packages:
|
1099
|
+
ensure => $version,
|
1100
|
+
require => [
|
1101
|
+
Class['apt::update'],
|
1102
|
+
Apt::Source["yubihsm-${facts['os']['distro']['codename']}"],
|
1103
|
+
],
|
1104
|
+
}
|
1105
|
+
CODE
|
1106
|
+
end
|
1107
|
+
it 'should detect no problem' do
|
1108
|
+
expect(problems).to have(0).problems
|
1109
|
+
end
|
1110
|
+
|
1111
|
+
it 'should not modify the manifest' do
|
1112
|
+
expect(manifest).to eq(code)
|
1113
|
+
end
|
1114
|
+
end
|
1115
|
+
context 'on a string with a properly formatted variable (Issue #19)' do
|
1116
|
+
let(:code) do
|
1117
|
+
<<-CODE.gsub(/^ {10}/, '')
|
1118
|
+
file { [
|
1119
|
+
"${root_dir}/index.txt",
|
1120
|
+
"${root_dir}/index.txt.attr"
|
1121
|
+
]:
|
1122
|
+
ensure => file,
|
1123
|
+
owner => 0,
|
1124
|
+
group => 0,
|
1125
|
+
mode => '0400',
|
1126
|
+
}
|
1127
|
+
CODE
|
1128
|
+
end
|
1129
|
+
it 'should detect no problem' do
|
1130
|
+
expect(problems).to have(0).problems
|
1131
|
+
end
|
1132
|
+
|
1133
|
+
it 'should not modify the manifest' do
|
1134
|
+
expect(manifest).to eq(code)
|
1135
|
+
end
|
1136
|
+
end
|
1137
|
+
context 'on an array with comments after some values (Issue #20)' do
|
1138
|
+
let(:code) do
|
1139
|
+
<<-CODE.gsub(/^ {10}/, '')
|
1140
|
+
proxy_set_header => [
|
1141
|
+
'Host $http_host:8043',
|
1142
|
+
'X-Real-IP $remote_addr',
|
1143
|
+
'X-Forwarded-For $proxy_add_x_forwarded_for',
|
1144
|
+
'Cookie $http_cookie',
|
1145
|
+
'X-Forwarded-Proto $scheme',
|
1146
|
+
'Upgrade $http_upgrade', #websockets
|
1147
|
+
'Connection "Upgrade"', #websockets
|
1148
|
+
],
|
1149
|
+
CODE
|
1150
|
+
end
|
1151
|
+
it 'should detect no problem' do
|
1152
|
+
expect(problems).to have(0).problems
|
1153
|
+
end
|
1154
|
+
|
1155
|
+
it 'should not modify the manifest' do
|
1156
|
+
expect(manifest).to eq(code)
|
1157
|
+
end
|
1158
|
+
end
|
1019
1159
|
end
|
1020
1160
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-array_formatting-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Manzer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- LICENSE
|
41
41
|
- README.md
|
42
42
|
- lib/puppet-lint/plugins/check_array_formatting.rb
|
43
|
+
- spec/puppet-lint/plugins/check_array_formatting_selected_spec.rb
|
43
44
|
- spec/puppet-lint/plugins/check_array_formatting_spec.rb
|
44
45
|
- spec/spec_helper.rb
|
45
46
|
homepage: https://gitlab.com/amanzer/puppet-lint-array_formatting-check
|