puppet-lint-manifest_whitespace-check 0.2.3 → 0.2.4
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: 1a7733009c47320dbae135031b97cd389cd2edab33095ef5a9c64d2b61375d8c
|
4
|
+
data.tar.gz: 5e356c323847a31282c948131d41cd6c9b4f40338818bf42f46b65d3320694b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8621832c8cf644f7ad467a1215d944ce2427ad97c127f2b60521bd6e6f743f9d37265a030dc11e9491455ab4ce50bab6db6cef1de0417d058c28fa8731fb110
|
7
|
+
data.tar.gz: 7bd64637bf4bde4a1e71c9dd50534a69a63bb698bda7097f68de2759da4bcd8e0b8f7146686c5dc6e38bd539a8e31c1c67708229127e3f4ea448dbbc80bc198e
|
@@ -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)
|
@@ -6,13 +6,29 @@ PuppetLint.new_check(:manifest_whitespace_opening_bracket_before) do
|
|
6
6
|
prev_token = bracket_token.prev_token
|
7
7
|
prev_code_token = prev_non_space_token(bracket_token)
|
8
8
|
|
9
|
-
next
|
10
|
-
next if %i[
|
11
|
-
next
|
9
|
+
next if %i[SEMIC COMMA COLON].include?(prev_code_token.type) && %i[INDENT NEWLINE].include?(prev_token.type)
|
10
|
+
next if %i[COMMENT].include?(prev_code_token.type)
|
11
|
+
next if %i[INDENT NEWLINE].include?(prev_token.type) && %i[NAME RBRACK RBRACE].include?(prev_code_token.type)
|
12
|
+
next if %i[CLASSREF VARIABLE].include?(prev_code_token.type) && (prev_code_token == prev_token)
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
if %i[RBRACK RBRACE RPAREN LPAREN LBRACK LBRACE TYPE].include?(prev_code_token.type)
|
15
|
+
next if prev_code_token == prev_token
|
16
|
+
next if %i[INDENT NEWLINE].include?(prev_token.type)
|
17
|
+
elsif %i[CLASSREF VARIABLE].include?(prev_code_token.type)
|
18
|
+
# not good
|
19
|
+
elsif tokens.index(prev_code_token) == tokens.index(bracket_token) - 2 &&
|
20
|
+
is_single_space(prev_token)
|
21
|
+
next
|
22
|
+
end
|
23
|
+
|
24
|
+
if prev_code_token.type == :LBRACE
|
25
|
+
ppct = prev_non_space_token(prev_code_token)
|
26
|
+
|
27
|
+
if ppct && ppct.type == :NAME
|
28
|
+
next if %i[INDENT NEWLINE].include?(prev_token.type)
|
29
|
+
next if tokens.index(prev_code_token) == tokens.index(bracket_token) - 2 && is_single_space(prev_token)
|
30
|
+
end
|
31
|
+
end
|
16
32
|
|
17
33
|
notify(
|
18
34
|
:error,
|
@@ -36,7 +52,7 @@ PuppetLint.new_check(:manifest_whitespace_opening_bracket_before) do
|
|
36
52
|
prev_token = prev_token.prev_token
|
37
53
|
end
|
38
54
|
|
39
|
-
add_token(tokens.index(token), new_single_space)
|
55
|
+
add_token(tokens.index(token), new_single_space) unless %i[LPAREN LBRACK LBRACE].include?(prev_code_token.type)
|
40
56
|
end
|
41
57
|
end
|
42
58
|
|
@@ -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,8 @@ 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
|
+
) {
|
69
82
|
$value = [{ 'key' => 'value' }]
|
70
83
|
$value2 = [
|
71
84
|
{
|
@@ -80,11 +93,20 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
80
93
|
$value5 = []
|
81
94
|
$value6 = {}
|
82
95
|
|
83
|
-
if somecondition{
|
84
|
-
class{ 'example2':
|
96
|
+
if somecondition {
|
97
|
+
class { 'example2':
|
85
98
|
param1 => 'value1',
|
86
99
|
require => File['somefile'],
|
87
100
|
}
|
101
|
+
package { ['pack1', 'pack2']:
|
102
|
+
ensure => present,
|
103
|
+
}
|
104
|
+
package {
|
105
|
+
['pack3', 'pack4']:
|
106
|
+
ensure => present;
|
107
|
+
['pack5', 'pack6']:
|
108
|
+
ensure => present;
|
109
|
+
}
|
88
110
|
}
|
89
111
|
}
|
90
112
|
EOF
|
@@ -97,6 +119,41 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
97
119
|
end
|
98
120
|
end
|
99
121
|
|
122
|
+
context 'with resource inline' do
|
123
|
+
let(:code) do
|
124
|
+
<<~EOF
|
125
|
+
package { ['pack1', 'pack2']:
|
126
|
+
ensure => present,
|
127
|
+
}
|
128
|
+
EOF
|
129
|
+
end
|
130
|
+
|
131
|
+
context 'with fix disabled' do
|
132
|
+
it 'should detect 0 problems' do
|
133
|
+
expect(problems).to be_empty
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
context 'with resource next line' do
|
139
|
+
let(:code) do
|
140
|
+
<<~EOF
|
141
|
+
package {
|
142
|
+
['pack3', 'pack4']:
|
143
|
+
ensure => present;
|
144
|
+
['pack5', 'pack6']:
|
145
|
+
ensure => present;
|
146
|
+
}
|
147
|
+
EOF
|
148
|
+
end
|
149
|
+
|
150
|
+
context 'with fix disabled' do
|
151
|
+
it 'should detect 0 problems' do
|
152
|
+
expect(problems).to be_empty
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
100
157
|
context 'with two spaces' do
|
101
158
|
let(:code) do
|
102
159
|
<<~EOF
|