puppet-lint-manifest_whitespace-check 0.1.0 → 0.1.7
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 +4 -4
- data/README.md +25 -3
- data/lib/puppet-lint/plugins/check_manifest_whitespace_class_inherits_single_space.rb +1 -44
- data/lib/puppet-lint/plugins/check_manifest_whitespace_class_name_single_space.rb +10 -10
- data/lib/puppet-lint/plugins/check_manifest_whitespace_closing_brace.rb +96 -0
- data/lib/puppet-lint/plugins/check_manifest_whitespace_closing_bracket.rb +86 -0
- data/lib/puppet-lint/plugins/check_manifest_whitespace_opening_brace.rb +83 -0
- data/lib/puppet-lint/plugins/check_manifest_whitespace_opening_bracket.rb +79 -0
- data/lib/puppet-lint/plugins/tools.rb +16 -0
- data/spec/puppet-lint/plugins/manifest_whitespace_class_header_spec.rb +35 -245
- data/spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb +0 -239
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_brace_spec.rb +460 -0
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_bracket_spec.rb +277 -0
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_brace_spec.rb +792 -0
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_bracket_spec.rb +470 -0
- metadata +14 -3
- data/lib/puppet-lint/plugins/check_manifest_whitespace_class_opening_curly_brace.rb +0 -40
@@ -67,242 +67,3 @@ describe 'manifest_whitespace_inherits_name_single_space_before' do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
71
|
-
describe 'manifest_whitespace_inherits_name_single_space_after' do
|
72
|
-
let(:single_space_msg) { 'there should be a single space between the class or resource name and the first bracket' }
|
73
|
-
|
74
|
-
context 'with no spaces' do
|
75
|
-
let(:code) do
|
76
|
-
<<~EOF
|
77
|
-
# example
|
78
|
-
#
|
79
|
-
# Main class, includes all other classes.
|
80
|
-
#
|
81
|
-
|
82
|
-
class example inherits other::example{
|
83
|
-
class { 'example2':
|
84
|
-
param1 => 'value1',
|
85
|
-
}
|
86
|
-
}
|
87
|
-
EOF
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'with fix disabled' do
|
91
|
-
it 'should detect a single problem' do
|
92
|
-
expect(problems).to have(1).problem
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should create a error' do
|
96
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(38)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'with fix enabled' do
|
101
|
-
before do
|
102
|
-
PuppetLint.configuration.fix = true
|
103
|
-
end
|
104
|
-
|
105
|
-
after do
|
106
|
-
PuppetLint.configuration.fix = false
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'should detect a single problem' do
|
110
|
-
expect(problems).to have(1).problem
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'should fix the manifest' do
|
114
|
-
expect(problems).to contain_fixed(single_space_msg)
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'should fix the newline' do
|
118
|
-
expect(manifest).to eq(
|
119
|
-
<<~EOF,
|
120
|
-
# example
|
121
|
-
#
|
122
|
-
# Main class, includes all other classes.
|
123
|
-
#
|
124
|
-
|
125
|
-
class example inherits other::example {
|
126
|
-
class { 'example2':
|
127
|
-
param1 => 'value1',
|
128
|
-
}
|
129
|
-
}
|
130
|
-
EOF
|
131
|
-
)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
context 'with two spaces' do
|
137
|
-
let(:code) do
|
138
|
-
<<~EOF
|
139
|
-
# example
|
140
|
-
#
|
141
|
-
# Main class, includes all other classes.
|
142
|
-
#
|
143
|
-
|
144
|
-
class example inherits other::example {
|
145
|
-
class { 'example2':
|
146
|
-
param1 => 'value1',
|
147
|
-
}
|
148
|
-
}
|
149
|
-
EOF
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'with fix disabled' do
|
153
|
-
it 'should detect a single problem' do
|
154
|
-
expect(problems).to have(1).problem
|
155
|
-
end
|
156
|
-
|
157
|
-
it 'should create a error' do
|
158
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(38)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
context 'with fix enabled' do
|
163
|
-
before do
|
164
|
-
PuppetLint.configuration.fix = true
|
165
|
-
end
|
166
|
-
|
167
|
-
after do
|
168
|
-
PuppetLint.configuration.fix = false
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'should detect a single problem' do
|
172
|
-
expect(problems).to have(1).problem
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'should fix the manifest' do
|
176
|
-
expect(problems).to contain_fixed(single_space_msg)
|
177
|
-
end
|
178
|
-
|
179
|
-
it 'should fix the space' do
|
180
|
-
expect(manifest).to eq(
|
181
|
-
<<~EOF,
|
182
|
-
# example
|
183
|
-
#
|
184
|
-
# Main class, includes all other classes.
|
185
|
-
#
|
186
|
-
|
187
|
-
class example inherits other::example {
|
188
|
-
class { 'example2':
|
189
|
-
param1 => 'value1',
|
190
|
-
}
|
191
|
-
}
|
192
|
-
EOF
|
193
|
-
)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
context 'with newline' do
|
199
|
-
let(:code) do
|
200
|
-
<<~EOF
|
201
|
-
# example
|
202
|
-
#
|
203
|
-
# Main class, includes all other classes.
|
204
|
-
#
|
205
|
-
|
206
|
-
class example inherits other::example
|
207
|
-
|
208
|
-
|
209
|
-
{
|
210
|
-
class { 'example2':
|
211
|
-
param1 => 'value1',
|
212
|
-
}
|
213
|
-
}
|
214
|
-
EOF
|
215
|
-
end
|
216
|
-
|
217
|
-
context 'with fix disabled' do
|
218
|
-
it 'should detect a single problem' do
|
219
|
-
expect(problems).to have(1).problem
|
220
|
-
end
|
221
|
-
|
222
|
-
it 'should create a error' do
|
223
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(38)
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
context 'with fix enabled' do
|
228
|
-
before do
|
229
|
-
PuppetLint.configuration.fix = true
|
230
|
-
end
|
231
|
-
|
232
|
-
after do
|
233
|
-
PuppetLint.configuration.fix = false
|
234
|
-
end
|
235
|
-
|
236
|
-
it 'should detect a single problem' do
|
237
|
-
expect(problems).to have(1).problem
|
238
|
-
end
|
239
|
-
|
240
|
-
it 'should fix the manifest' do
|
241
|
-
expect(problems).to contain_fixed(single_space_msg)
|
242
|
-
end
|
243
|
-
|
244
|
-
it 'should fix the newline' do
|
245
|
-
expect(manifest).to eq(
|
246
|
-
<<~EOF,
|
247
|
-
# example
|
248
|
-
#
|
249
|
-
# Main class, includes all other classes.
|
250
|
-
#
|
251
|
-
|
252
|
-
class example inherits other::example {
|
253
|
-
class { 'example2':
|
254
|
-
param1 => 'value1',
|
255
|
-
}
|
256
|
-
}
|
257
|
-
EOF
|
258
|
-
)
|
259
|
-
end
|
260
|
-
end
|
261
|
-
end
|
262
|
-
|
263
|
-
context 'with comment' do
|
264
|
-
let(:code) do
|
265
|
-
<<~EOF
|
266
|
-
# example
|
267
|
-
#
|
268
|
-
# Main class, includes all other classes.
|
269
|
-
#
|
270
|
-
|
271
|
-
class example inherits other::example # the class
|
272
|
-
{
|
273
|
-
class { 'example2':
|
274
|
-
param1 => 'value1',
|
275
|
-
}
|
276
|
-
}
|
277
|
-
EOF
|
278
|
-
end
|
279
|
-
|
280
|
-
context 'with fix disabled' do
|
281
|
-
it 'should detect a single problem' do
|
282
|
-
expect(problems).to have(1).problem
|
283
|
-
end
|
284
|
-
|
285
|
-
it 'should create a error' do
|
286
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(38)
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
context 'with fix enabled' do
|
291
|
-
before do
|
292
|
-
PuppetLint.configuration.fix = true
|
293
|
-
end
|
294
|
-
|
295
|
-
after do
|
296
|
-
PuppetLint.configuration.fix = false
|
297
|
-
end
|
298
|
-
|
299
|
-
it 'should detect a single problem' do
|
300
|
-
expect(problems).to have(1).problem
|
301
|
-
end
|
302
|
-
|
303
|
-
it 'should not fix the manifest' do
|
304
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(38)
|
305
|
-
end
|
306
|
-
end
|
307
|
-
end
|
308
|
-
end
|
@@ -0,0 +1,460 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'manifest_whitespace_closing_brace_before' do
|
6
|
+
let(:closing_brace_msg) { 'there should be a bracket or a single newline before a closing brace' }
|
7
|
+
|
8
|
+
context 'with comment only' do
|
9
|
+
let(:code) do
|
10
|
+
<<~EOF
|
11
|
+
$value7 = {
|
12
|
+
# nothing
|
13
|
+
}
|
14
|
+
EOF
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should detect no problems' do
|
18
|
+
expect(problems).to have(0).problem
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with no spaces' do
|
23
|
+
let(:code) do
|
24
|
+
<<~EOF
|
25
|
+
# example
|
26
|
+
#
|
27
|
+
# Main class, includes all other classes.
|
28
|
+
#
|
29
|
+
|
30
|
+
class example (
|
31
|
+
String $content,
|
32
|
+
) {
|
33
|
+
$value = [{ 'key' => 'value'}]
|
34
|
+
$value2 = [
|
35
|
+
{
|
36
|
+
'key' => 'value1',
|
37
|
+
},
|
38
|
+
{
|
39
|
+
'key' => 'value2',
|
40
|
+
},
|
41
|
+
]
|
42
|
+
$value3 = myfunc($value1)
|
43
|
+
$value4 = ['somekey']
|
44
|
+
$value5 = []
|
45
|
+
$value6 = {}
|
46
|
+
$value7 = "x${server_facts['environment']}y"
|
47
|
+
$value8 = {
|
48
|
+
# nothing
|
49
|
+
}
|
50
|
+
|
51
|
+
if someothercondition { include ::otherclass}
|
52
|
+
if somecondition {
|
53
|
+
class { 'example2':
|
54
|
+
param1 => 'value1',
|
55
|
+
require => File['somefile'],
|
56
|
+
}
|
57
|
+
class { 'example3':}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
EOF
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'with fix disabled' do
|
64
|
+
it 'should detect 3 problems' do
|
65
|
+
expect(problems).to have(3).problem
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should create a error' do
|
69
|
+
expect(problems).to contain_error(closing_brace_msg).on_line(9).in_column(31)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'with fix enabled' do
|
74
|
+
before do
|
75
|
+
PuppetLint.configuration.fix = true
|
76
|
+
end
|
77
|
+
|
78
|
+
after do
|
79
|
+
PuppetLint.configuration.fix = false
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should fix a error' do
|
83
|
+
expect(problems).to contain_fixed(closing_brace_msg)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should add spaces' do
|
87
|
+
expect(manifest).to eq(
|
88
|
+
<<~EOF,
|
89
|
+
# example
|
90
|
+
#
|
91
|
+
# Main class, includes all other classes.
|
92
|
+
#
|
93
|
+
|
94
|
+
class example (
|
95
|
+
String $content,
|
96
|
+
) {
|
97
|
+
$value = [{ 'key' => 'value' }]
|
98
|
+
$value2 = [
|
99
|
+
{
|
100
|
+
'key' => 'value1',
|
101
|
+
},
|
102
|
+
{
|
103
|
+
'key' => 'value2',
|
104
|
+
},
|
105
|
+
]
|
106
|
+
$value3 = myfunc($value1)
|
107
|
+
$value4 = ['somekey']
|
108
|
+
$value5 = []
|
109
|
+
$value6 = {}
|
110
|
+
$value7 = "x${server_facts['environment']}y"
|
111
|
+
$value8 = {
|
112
|
+
# nothing
|
113
|
+
}
|
114
|
+
|
115
|
+
if someothercondition { include ::otherclass }
|
116
|
+
if somecondition {
|
117
|
+
class { 'example2':
|
118
|
+
param1 => 'value1',
|
119
|
+
require => File['somefile'],
|
120
|
+
}
|
121
|
+
class { 'example3': }
|
122
|
+
}
|
123
|
+
}
|
124
|
+
EOF
|
125
|
+
)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'with too many spaces' do
|
131
|
+
let(:code) do
|
132
|
+
<<~EOF
|
133
|
+
# example
|
134
|
+
#
|
135
|
+
# Main class, includes all other classes.
|
136
|
+
#
|
137
|
+
|
138
|
+
class example (
|
139
|
+
String $content,
|
140
|
+
) {
|
141
|
+
$value = [{ 'key' => 'value' }]
|
142
|
+
$value2 = [
|
143
|
+
{
|
144
|
+
'key' => 'value1',
|
145
|
+
},
|
146
|
+
{
|
147
|
+
'key' => 'value2',
|
148
|
+
},
|
149
|
+
|
150
|
+
]
|
151
|
+
$value3 = myfunc($value1)
|
152
|
+
$value4 = ['somekey'
|
153
|
+
$value5 = []
|
154
|
+
$value6 = { }
|
155
|
+
$value7 = "x${server_facts['environment']}y"
|
156
|
+
|
157
|
+
if someothercondition { include ::otherclass }
|
158
|
+
if somecondition {
|
159
|
+
class { 'example2':
|
160
|
+
param1 => 'value1',
|
161
|
+
require => File['somefile'],
|
162
|
+
}
|
163
|
+
class { 'example3': }
|
164
|
+
}
|
165
|
+
}
|
166
|
+
EOF
|
167
|
+
end
|
168
|
+
|
169
|
+
context 'with fix disabled' do
|
170
|
+
it 'should detect 4 problems' do
|
171
|
+
expect(problems).to have(4).problems
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should create a error' do
|
175
|
+
expect(problems).to contain_error(closing_brace_msg).on_line(9).in_column(31)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
context 'with fix enabled' do
|
180
|
+
before do
|
181
|
+
PuppetLint.configuration.fix = true
|
182
|
+
end
|
183
|
+
|
184
|
+
after do
|
185
|
+
PuppetLint.configuration.fix = false
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should fix a error' do
|
189
|
+
expect(problems).to contain_fixed(closing_brace_msg)
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'should add spaces' do
|
193
|
+
expect(manifest).to eq(
|
194
|
+
<<~EOF,
|
195
|
+
# example
|
196
|
+
#
|
197
|
+
# Main class, includes all other classes.
|
198
|
+
#
|
199
|
+
|
200
|
+
class example (
|
201
|
+
String $content,
|
202
|
+
) {
|
203
|
+
$value = [{ 'key' => 'value' }]
|
204
|
+
$value2 = [
|
205
|
+
{
|
206
|
+
'key' => 'value1',
|
207
|
+
},
|
208
|
+
{
|
209
|
+
'key' => 'value2',
|
210
|
+
},
|
211
|
+
|
212
|
+
]
|
213
|
+
$value3 = myfunc($value1)
|
214
|
+
$value4 = ['somekey'
|
215
|
+
$value5 = []
|
216
|
+
$value6 = {}
|
217
|
+
$value7 = "x${server_facts['environment']}y"
|
218
|
+
|
219
|
+
if someothercondition { include ::otherclass }
|
220
|
+
if somecondition {
|
221
|
+
class { 'example2':
|
222
|
+
param1 => 'value1',
|
223
|
+
require => File['somefile'],
|
224
|
+
}
|
225
|
+
class { 'example3': }
|
226
|
+
}
|
227
|
+
}
|
228
|
+
EOF
|
229
|
+
)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
context 'with too many newlines' do
|
235
|
+
let(:code) do
|
236
|
+
<<~EOF
|
237
|
+
# example
|
238
|
+
#
|
239
|
+
# Main class, includes all other classes.
|
240
|
+
#
|
241
|
+
|
242
|
+
class example (
|
243
|
+
String $content,
|
244
|
+
) {
|
245
|
+
$value = [{ 'key' => 'value' }]
|
246
|
+
$value2 = [
|
247
|
+
{
|
248
|
+
'key' => 'value1',
|
249
|
+
},
|
250
|
+
{
|
251
|
+
'key' => 'value2',
|
252
|
+
|
253
|
+
},
|
254
|
+
]
|
255
|
+
$value3 = myfunc($value1)
|
256
|
+
$value4 = ['somekey'
|
257
|
+
$value5 = []
|
258
|
+
$value6 = {
|
259
|
+
|
260
|
+
}
|
261
|
+
$value7 = "x${server_facts['environment']}y"
|
262
|
+
|
263
|
+
if someothercondition { include ::otherclass }
|
264
|
+
if somecondition {
|
265
|
+
class { 'example2':
|
266
|
+
param1 => 'value1',
|
267
|
+
require => File['somefile'],
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
class { 'example3': }
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
}
|
276
|
+
EOF
|
277
|
+
end
|
278
|
+
|
279
|
+
context 'with fix disabled' do
|
280
|
+
it 'should detect 5 problems' do
|
281
|
+
expect(problems).to have(5).problems
|
282
|
+
end
|
283
|
+
|
284
|
+
it 'should create a error' do
|
285
|
+
expect(problems).to contain_error(closing_brace_msg).on_line(15).in_column(25)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
context 'with fix enabled' do
|
290
|
+
before do
|
291
|
+
PuppetLint.configuration.fix = true
|
292
|
+
end
|
293
|
+
|
294
|
+
after do
|
295
|
+
PuppetLint.configuration.fix = false
|
296
|
+
end
|
297
|
+
|
298
|
+
it 'should fix a error' do
|
299
|
+
expect(problems).to contain_fixed(closing_brace_msg)
|
300
|
+
end
|
301
|
+
|
302
|
+
it 'should remove newlines' do
|
303
|
+
expect(manifest).to eq(
|
304
|
+
<<~EOF,
|
305
|
+
# example
|
306
|
+
#
|
307
|
+
# Main class, includes all other classes.
|
308
|
+
#
|
309
|
+
|
310
|
+
class example (
|
311
|
+
String $content,
|
312
|
+
) {
|
313
|
+
$value = [{ 'key' => 'value' }]
|
314
|
+
$value2 = [
|
315
|
+
{
|
316
|
+
'key' => 'value1',
|
317
|
+
},
|
318
|
+
{
|
319
|
+
'key' => 'value2',
|
320
|
+
},
|
321
|
+
]
|
322
|
+
$value3 = myfunc($value1)
|
323
|
+
$value4 = ['somekey'
|
324
|
+
$value5 = []
|
325
|
+
$value6 = {
|
326
|
+
}
|
327
|
+
$value7 = "x${server_facts['environment']}y"
|
328
|
+
|
329
|
+
if someothercondition { include ::otherclass }
|
330
|
+
if somecondition {
|
331
|
+
class { 'example2':
|
332
|
+
param1 => 'value1',
|
333
|
+
require => File['somefile'],
|
334
|
+
}
|
335
|
+
|
336
|
+
class { 'example3': }
|
337
|
+
}
|
338
|
+
}
|
339
|
+
EOF
|
340
|
+
)
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
describe 'manifest_whitespace_closing_brace_after' do
|
347
|
+
let(:closing_brace_msg) { 'there should be either a bracket, comma, colon, closing quote or a newline after a closing brace, or whitespace and none of the aforementioned' }
|
348
|
+
|
349
|
+
context 'with spaces' do
|
350
|
+
let(:code) do
|
351
|
+
<<~EOF
|
352
|
+
# example
|
353
|
+
#
|
354
|
+
# Main class, includes all other classes.
|
355
|
+
#
|
356
|
+
|
357
|
+
class example (
|
358
|
+
String $content,
|
359
|
+
) {
|
360
|
+
$value = [{ 'key' => 'value' } ]
|
361
|
+
$value2 = [
|
362
|
+
{
|
363
|
+
'key' => 'value1',
|
364
|
+
},
|
365
|
+
{
|
366
|
+
'key' => 'value2',
|
367
|
+
} ,
|
368
|
+
]
|
369
|
+
|
370
|
+
$value2bis = {
|
371
|
+
'key' => 'value',
|
372
|
+
} # this comment is fine
|
373
|
+
|
374
|
+
$value3 = myfunc({} )
|
375
|
+
$value4 = ['somekey']
|
376
|
+
$value5 = []
|
377
|
+
$value6 = {}
|
378
|
+
$value7 = "x${server_facts['environment']}y"
|
379
|
+
|
380
|
+
if someothercondition { include ::otherclass }
|
381
|
+
if somecondition {
|
382
|
+
class { 'example2':
|
383
|
+
param1 => 'value1',
|
384
|
+
require => File['somefile'],
|
385
|
+
}
|
386
|
+
class { 'example3': }
|
387
|
+
}
|
388
|
+
}
|
389
|
+
EOF
|
390
|
+
end
|
391
|
+
|
392
|
+
context 'with fix disabled' do
|
393
|
+
it 'should detect 3 problems' do
|
394
|
+
expect(problems).to have(3).problem
|
395
|
+
end
|
396
|
+
|
397
|
+
it 'should create a error' do
|
398
|
+
expect(problems).to contain_error(closing_brace_msg).on_line(9).in_column(33)
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
context 'with fix enabled' do
|
403
|
+
before do
|
404
|
+
PuppetLint.configuration.fix = true
|
405
|
+
end
|
406
|
+
|
407
|
+
after do
|
408
|
+
PuppetLint.configuration.fix = false
|
409
|
+
end
|
410
|
+
|
411
|
+
it 'should fix a error' do
|
412
|
+
expect(problems).to contain_fixed(closing_brace_msg)
|
413
|
+
end
|
414
|
+
|
415
|
+
it 'should add spaces' do
|
416
|
+
expect(manifest).to eq(
|
417
|
+
<<~EOF,
|
418
|
+
# example
|
419
|
+
#
|
420
|
+
# Main class, includes all other classes.
|
421
|
+
#
|
422
|
+
|
423
|
+
class example (
|
424
|
+
String $content,
|
425
|
+
) {
|
426
|
+
$value = [{ 'key' => 'value' }]
|
427
|
+
$value2 = [
|
428
|
+
{
|
429
|
+
'key' => 'value1',
|
430
|
+
},
|
431
|
+
{
|
432
|
+
'key' => 'value2',
|
433
|
+
},
|
434
|
+
]
|
435
|
+
|
436
|
+
$value2bis = {
|
437
|
+
'key' => 'value',
|
438
|
+
} # this comment is fine
|
439
|
+
|
440
|
+
$value3 = myfunc({})
|
441
|
+
$value4 = ['somekey']
|
442
|
+
$value5 = []
|
443
|
+
$value6 = {}
|
444
|
+
$value7 = "x${server_facts['environment']}y"
|
445
|
+
|
446
|
+
if someothercondition { include ::otherclass }
|
447
|
+
if somecondition {
|
448
|
+
class { 'example2':
|
449
|
+
param1 => 'value1',
|
450
|
+
require => File['somefile'],
|
451
|
+
}
|
452
|
+
class { 'example3': }
|
453
|
+
}
|
454
|
+
}
|
455
|
+
EOF
|
456
|
+
)
|
457
|
+
end
|
458
|
+
end
|
459
|
+
end
|
460
|
+
end
|