puppet-lint-manifest_whitespace-check 0.2.3 → 0.2.5
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: c3fe61412435fe6e35447e02c54fe9b71937f5b1ceb30c65308eb8e1b61adaf0
|
4
|
+
data.tar.gz: d50c16634bb1f6609b5029b163a615d21e26e49df289be506634ee2f5240c205
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db462d214af83d3f3f32ae1d4aa91aad45c32d7c1ead916bc459cc56e1d345c258d4e28c3a5d48b2c13b890f7fa4a929177c3b91c3ce08d15a3618467c0d4a10
|
7
|
+
data.tar.gz: 2d57e6f697d41bf685bbc8b403fa11a2408c0aae3995b462f3f7f700c29ebc840a236767e841dce0c37233bd124227e3eec2f047c95ca1150caf7603d1072c79
|
@@ -14,7 +14,6 @@ PuppetLint.new_check(:manifest_whitespace_opening_brace_before) do
|
|
14
14
|
if %i[LPAREN LBRACK LBRACE].include?(prev_code_token.type)
|
15
15
|
next if tokens.index(prev_code_token) == tokens.index(brace_token) - 1
|
16
16
|
next if tokens[tokens.index(prev_code_token)..tokens.index(brace_token)].collect(&:type).include?(:NEWLINE)
|
17
|
-
|
18
17
|
else
|
19
18
|
next unless tokens.index(prev_code_token) != tokens.index(brace_token) - 2 ||
|
20
19
|
!is_single_space(prev_token)
|
@@ -4,15 +4,33 @@ PuppetLint.new_check(:manifest_whitespace_opening_bracket_before) do
|
|
4
4
|
def check
|
5
5
|
tokens.select { |token| token.type == :LBRACK }.each do |bracket_token|
|
6
6
|
prev_token = bracket_token.prev_token
|
7
|
+
|
8
|
+
next if %i[CLASSREF VARIABLE NAME].include?(prev_token.type)
|
9
|
+
|
7
10
|
prev_code_token = prev_non_space_token(bracket_token)
|
8
11
|
|
9
|
-
next
|
10
|
-
next if %i[
|
11
|
-
next
|
12
|
+
next if %i[SEMIC COMMA COLON].include?(prev_code_token.type) && %i[INDENT NEWLINE].include?(prev_token.type)
|
13
|
+
next if %i[COMMENT].include?(prev_code_token.type)
|
14
|
+
next if %i[INDENT NEWLINE].include?(prev_token.type) && %i[NAME RBRACK RBRACE].include?(prev_code_token.type)
|
15
|
+
|
16
|
+
if %i[RBRACK RBRACE RPAREN LPAREN LBRACK LBRACE TYPE].include?(prev_code_token.type)
|
17
|
+
next if prev_code_token == prev_token
|
18
|
+
next if %i[INDENT NEWLINE].include?(prev_token.type)
|
19
|
+
elsif %i[CLASSREF VARIABLE].include?(prev_code_token.type)
|
20
|
+
# not good
|
21
|
+
elsif tokens.index(prev_code_token) == tokens.index(bracket_token) - 2 &&
|
22
|
+
is_single_space(prev_token)
|
23
|
+
next
|
24
|
+
end
|
25
|
+
|
26
|
+
if prev_code_token.type == :LBRACE
|
27
|
+
ppct = prev_non_space_token(prev_code_token)
|
12
28
|
|
13
|
-
|
14
|
-
|
15
|
-
|
29
|
+
if ppct && ppct.type == :NAME
|
30
|
+
next if %i[INDENT NEWLINE].include?(prev_token.type)
|
31
|
+
next if tokens.index(prev_code_token) == tokens.index(bracket_token) - 2 && is_single_space(prev_token)
|
32
|
+
end
|
33
|
+
end
|
16
34
|
|
17
35
|
notify(
|
18
36
|
:error,
|
@@ -36,7 +54,7 @@ PuppetLint.new_check(:manifest_whitespace_opening_bracket_before) do
|
|
36
54
|
prev_token = prev_token.prev_token
|
37
55
|
end
|
38
56
|
|
39
|
-
add_token(tokens.index(token), new_single_space)
|
57
|
+
add_token(tokens.index(token), new_single_space) unless %i[LPAREN LBRACK LBRACE].include?(prev_code_token.type)
|
40
58
|
end
|
41
59
|
end
|
42
60
|
|
@@ -38,6 +38,18 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
context 'with array key in interpolation' do
|
42
|
+
let(:code) do
|
43
|
+
<<~EOF
|
44
|
+
"${my_array['keyname']}"
|
45
|
+
EOF
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should detect no problems' do
|
49
|
+
expect(problems).to be_empty
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
41
53
|
context 'with multiline iterator' do
|
42
54
|
let(:code) do
|
43
55
|
<<~EOF
|
@@ -65,7 +77,17 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
65
77
|
|
66
78
|
class example (
|
67
79
|
String $content,
|
68
|
-
|
80
|
+
Optional[String] $some_other_content,
|
81
|
+
Array $var = lookup('foo::bar', Array, undef, [])
|
82
|
+
) {
|
83
|
+
if $fact["${var}"] != $var2.keys[0] {
|
84
|
+
# noop
|
85
|
+
}
|
86
|
+
|
87
|
+
if fact["${var}"] != $var2.keys[0] {
|
88
|
+
# noop
|
89
|
+
}
|
90
|
+
|
69
91
|
$value = [{ 'key' => 'value' }]
|
70
92
|
$value2 = [
|
71
93
|
{
|
@@ -80,11 +102,20 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
80
102
|
$value5 = []
|
81
103
|
$value6 = {}
|
82
104
|
|
83
|
-
if somecondition{
|
84
|
-
class{ 'example2':
|
105
|
+
if somecondition {
|
106
|
+
class { 'example2':
|
85
107
|
param1 => 'value1',
|
86
108
|
require => File['somefile'],
|
87
109
|
}
|
110
|
+
package { ['pack1', 'pack2']:
|
111
|
+
ensure => present,
|
112
|
+
}
|
113
|
+
package {
|
114
|
+
['pack3', 'pack4']:
|
115
|
+
ensure => present;
|
116
|
+
['pack5', 'pack6']:
|
117
|
+
ensure => present;
|
118
|
+
}
|
88
119
|
}
|
89
120
|
}
|
90
121
|
EOF
|
@@ -97,6 +128,41 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
97
128
|
end
|
98
129
|
end
|
99
130
|
|
131
|
+
context 'with resource inline' do
|
132
|
+
let(:code) do
|
133
|
+
<<~EOF
|
134
|
+
package { ['pack1', 'pack2']:
|
135
|
+
ensure => present,
|
136
|
+
}
|
137
|
+
EOF
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'with fix disabled' do
|
141
|
+
it 'should detect 0 problems' do
|
142
|
+
expect(problems).to be_empty
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'with resource next line' do
|
148
|
+
let(:code) do
|
149
|
+
<<~EOF
|
150
|
+
package {
|
151
|
+
['pack3', 'pack4']:
|
152
|
+
ensure => present;
|
153
|
+
['pack5', 'pack6']:
|
154
|
+
ensure => present;
|
155
|
+
}
|
156
|
+
EOF
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'with fix disabled' do
|
160
|
+
it 'should detect 0 problems' do
|
161
|
+
expect(problems).to be_empty
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
100
166
|
context 'with two spaces' do
|
101
167
|
let(:code) do
|
102
168
|
<<~EOF
|
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.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jo Vandeginste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|