puppet-lint-trailing_comma-check 0.2.0 → 0.2.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efe5aee738e1475cc878f16a346cd865a65816d5
|
4
|
+
data.tar.gz: c28c215aa8395c695d3a2110a3d80fb1094d5aec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90b31b52f716941fb3febcc736b8bc87b0f507d4355cd2bbe1205db5f843cf968b96b38b46b5c2e48b22bafb7a60edeca75bcdd5f2b168bbc259b6d924366c98
|
7
|
+
data.tar.gz: 4b983edc4f6f5f6ddbb6f4943af3accd9754b1bf0119835772c588f49809d00cd83c82683531a96eb7a905a87be6b673c91e5f6ce0cc3e3a44612a9ec3a70e06
|
@@ -41,9 +41,9 @@ PuppetLint.new_check(:trailing_comma) do
|
|
41
41
|
results
|
42
42
|
end
|
43
43
|
|
44
|
-
def check_elem(elem)
|
44
|
+
def check_elem(elem, except_type)
|
45
45
|
lbo_token = elem[:tokens][-1].prev_code_token
|
46
|
-
if lbo_token && lbo_token.type !=
|
46
|
+
if lbo_token && lbo_token.type != except_type && \
|
47
47
|
elem[:tokens][-1].type != :SEMIC && \
|
48
48
|
lbo_token.type != :COMMA && \
|
49
49
|
lbo_token.next_token.type == :NEWLINE
|
@@ -59,17 +59,17 @@ PuppetLint.new_check(:trailing_comma) do
|
|
59
59
|
def check
|
60
60
|
# Resource and class declarations
|
61
61
|
resource_indexes.each do |resource|
|
62
|
-
check_elem(resource)
|
62
|
+
check_elem(resource, :COLON)
|
63
63
|
end
|
64
64
|
|
65
65
|
# Arrays
|
66
66
|
array_indexes.each do |array|
|
67
|
-
check_elem(array)
|
67
|
+
check_elem(array, :LBRACK)
|
68
68
|
end
|
69
69
|
|
70
70
|
# Defaults
|
71
71
|
defaults_indexes.each do |defaults|
|
72
|
-
check_elem(defaults)
|
72
|
+
check_elem(defaults, :LBRACE)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -33,6 +33,8 @@ describe 'trailing_comma' do
|
|
33
33
|
'bar',
|
34
34
|
],
|
35
35
|
groupss => ['baz', 'qux'],
|
36
|
+
groupz => [
|
37
|
+
],
|
36
38
|
}
|
37
39
|
|
38
40
|
File {
|
@@ -76,6 +78,8 @@ describe 'trailing_comma' do
|
|
76
78
|
'bar'
|
77
79
|
],
|
78
80
|
groupss => ['baz', 'qux'],
|
81
|
+
groupz => [
|
82
|
+
],
|
79
83
|
}
|
80
84
|
|
81
85
|
File {
|
@@ -93,7 +97,7 @@ describe 'trailing_comma' do
|
|
93
97
|
expect(problems).to contain_warning(msg).on_line(3).in_column(32)
|
94
98
|
expect(problems).to contain_warning(msg).on_line(10).in_column(27)
|
95
99
|
expect(problems).to contain_warning(msg).on_line(24).in_column(18)
|
96
|
-
expect(problems).to contain_warning(msg).on_line(
|
100
|
+
expect(problems).to contain_warning(msg).on_line(33).in_column(23)
|
97
101
|
end
|
98
102
|
end
|
99
103
|
end
|
@@ -136,6 +140,8 @@ describe 'trailing_comma' do
|
|
136
140
|
'bar',
|
137
141
|
],
|
138
142
|
groupss => ['baz', 'qux'],
|
143
|
+
groupz => [
|
144
|
+
],
|
139
145
|
}
|
140
146
|
|
141
147
|
File {
|
@@ -183,6 +189,8 @@ describe 'trailing_comma' do
|
|
183
189
|
'bar'
|
184
190
|
],
|
185
191
|
groupss => ['baz', 'qux'],
|
192
|
+
groupz => [
|
193
|
+
],
|
186
194
|
}
|
187
195
|
|
188
196
|
File {
|
@@ -200,7 +208,7 @@ describe 'trailing_comma' do
|
|
200
208
|
expect(problems).to contain_fixed(msg).on_line(3).in_column(32)
|
201
209
|
expect(problems).to contain_fixed(msg).on_line(10).in_column(27)
|
202
210
|
expect(problems).to contain_fixed(msg).on_line(24).in_column(18)
|
203
|
-
expect(problems).to contain_fixed(msg).on_line(
|
211
|
+
expect(problems).to contain_fixed(msg).on_line(33).in_column(23)
|
204
212
|
end
|
205
213
|
|
206
214
|
it 'should add trailing commas' do
|
@@ -232,6 +240,8 @@ describe 'trailing_comma' do
|
|
232
240
|
'bar',
|
233
241
|
],
|
234
242
|
groupss => ['baz', 'qux'],
|
243
|
+
groupz => [
|
244
|
+
],
|
235
245
|
}
|
236
246
|
|
237
247
|
File {
|