puppet-lint-manifest_whitespace-check 0.1.8 → 0.1.13
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/lib/puppet-lint/plugins/check_manifest_whitespace_closing_brace.rb +3 -3
- data/lib/puppet-lint/plugins/check_manifest_whitespace_closing_bracket.rb +1 -1
- data/lib/puppet-lint/plugins/check_manifest_whitespace_opening_brace.rb +4 -2
- data/lib/puppet-lint/plugins/check_manifest_whitespace_opening_bracket.rb +3 -0
- data/lib/puppet-lint/plugins/tools.rb +1 -1
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_brace_spec.rb +42 -1
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_bracket_spec.rb +33 -5
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_brace_spec.rb +15 -0
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_bracket_spec.rb +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6eb78b1b0aa97896074ac01224d0d9ec8d62fd113308cd715c0bb60ff26707c
|
4
|
+
data.tar.gz: f9c4c73d8a5698e6b3b44732f400a7f3506e9a784622ab8e741332c03f67d2d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82aeade9ab4d7c4106411ba01250e21c983f78e5d5aa5f53ac8e518f9344be7e219b8182ad6801330e721147d313458bdcbba97882f30170340d9ab5d4250715
|
7
|
+
data.tar.gz: fbe9b003c323b27e7361f8548e9d234558255fbd7a6229bd863c9f9c2482ef886f787d75455ebad9476127e1d9e08834f73e1467d57468e1af4f28211a68f9cb
|
@@ -7,9 +7,9 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_before) do
|
|
7
7
|
prev_code_token = prev_non_space_token(brace_token)
|
8
8
|
|
9
9
|
next unless prev_token && prev_code_token
|
10
|
-
next if %i[LBRACE
|
10
|
+
next if %i[LBRACE].include?(prev_token.type)
|
11
11
|
|
12
|
-
unless %i[LBRACE
|
12
|
+
unless %i[LBRACE].include?(prev_code_token.type)
|
13
13
|
if is_single_space(prev_token) && tokens.index(prev_code_token) == tokens.index(brace_token) - 2
|
14
14
|
next
|
15
15
|
end
|
@@ -73,7 +73,7 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_after) do
|
|
73
73
|
|
74
74
|
notify(
|
75
75
|
:error,
|
76
|
-
message: 'there should be either a bracket,
|
76
|
+
message: 'there should be either a bracket, punctuation mark, closing quote or a newline after a closing brace, or whitespace and none of the aforementioned',
|
77
77
|
line: next_token.line,
|
78
78
|
column: next_token.column,
|
79
79
|
token: next_token,
|
@@ -63,7 +63,7 @@ PuppetLint.new_check(:manifest_whitespace_closing_bracket_after) do
|
|
63
63
|
|
64
64
|
notify(
|
65
65
|
:error,
|
66
|
-
message: 'there should be either a bracket,
|
66
|
+
message: 'there should be either a bracket, punctuation mark, closing quote or a newline after a closing bracket, or whitespace and none of the aforementioned',
|
67
67
|
line: next_token.line,
|
68
68
|
column: next_token.column,
|
69
69
|
token: next_token,
|
@@ -7,7 +7,9 @@ PuppetLint.new_check(:manifest_whitespace_opening_brace_before) do
|
|
7
7
|
prev_code_token = prev_non_space_token(brace_token)
|
8
8
|
|
9
9
|
next unless prev_token && prev_code_token
|
10
|
-
|
10
|
+
if %i[LBRACK LBRACE COLON COMMA COMMENT].include?(prev_code_token.type)
|
11
|
+
next
|
12
|
+
end
|
11
13
|
next unless tokens.index(prev_code_token) != tokens.index(brace_token) - 2 ||
|
12
14
|
!is_single_space(prev_token)
|
13
15
|
|
@@ -45,7 +47,7 @@ PuppetLint.new_check(:manifest_whitespace_opening_brace_after) do
|
|
45
47
|
next_token = brace_token.next_token
|
46
48
|
|
47
49
|
next unless next_token && !is_single_space(next_token)
|
48
|
-
next if %i[
|
50
|
+
next if %i[RBRACE].include?(next_token.type)
|
49
51
|
|
50
52
|
if next_token.type == :NEWLINE
|
51
53
|
next_token = next_token.next_token
|
@@ -9,6 +9,9 @@ PuppetLint.new_check(:manifest_whitespace_opening_bracket_before) do
|
|
9
9
|
next unless prev_token && prev_code_token
|
10
10
|
next if %i[LBRACK LBRACE COMMA SEMIC].include?(prev_code_token.type)
|
11
11
|
next unless %i[WHITESPACE NEWLINE INDENT].include?(prev_token.type)
|
12
|
+
if prev_token.type == :NEWLINE && %i[RBRACK RBRACE].include?(prev_code_token.type)
|
13
|
+
next
|
14
|
+
end
|
12
15
|
next unless tokens.index(prev_code_token) != tokens.index(bracket_token) - 2 ||
|
13
16
|
!is_single_space(prev_token)
|
14
17
|
|
@@ -5,6 +5,34 @@ require 'spec_helper'
|
|
5
5
|
describe 'manifest_whitespace_closing_brace_before' do
|
6
6
|
let(:closing_brace_msg) { 'there should be a bracket or a single newline before a closing brace' }
|
7
7
|
|
8
|
+
context 'with nested hash' do
|
9
|
+
let(:code) do
|
10
|
+
<<~EOF
|
11
|
+
Hash $instances = { 'localhost' => { 'url' => 'http://localhost/mod_status?auto' } },
|
12
|
+
EOF
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should detect no problems' do
|
16
|
+
expect(problems).to have(0).problem
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'with iterator' do
|
21
|
+
let(:code) do
|
22
|
+
<<~EOF
|
23
|
+
['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
|
24
|
+
}
|
25
|
+
|
26
|
+
['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
|
27
|
+
}
|
28
|
+
EOF
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should detect no problems' do
|
32
|
+
expect(problems).to have(0).problem
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
8
36
|
context 'with comment only' do
|
9
37
|
let(:code) do
|
10
38
|
<<~EOF
|
@@ -344,7 +372,20 @@ describe 'manifest_whitespace_closing_brace_before' do
|
|
344
372
|
end
|
345
373
|
|
346
374
|
describe 'manifest_whitespace_closing_brace_after' do
|
347
|
-
let(:closing_brace_msg) { 'there should be either a bracket,
|
375
|
+
let(:closing_brace_msg) { 'there should be either a bracket, punctuation mark, closing quote or a newline after a closing brace, or whitespace and none of the aforementioned' }
|
376
|
+
|
377
|
+
context 'with iterator' do
|
378
|
+
let(:code) do
|
379
|
+
<<~EOF
|
380
|
+
['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
|
381
|
+
}
|
382
|
+
EOF
|
383
|
+
end
|
384
|
+
|
385
|
+
it 'should detect no problems' do
|
386
|
+
expect(problems).to have(0).problem
|
387
|
+
end
|
388
|
+
end
|
348
389
|
|
349
390
|
context 'with spaces' do
|
350
391
|
let(:code) do
|
@@ -153,7 +153,35 @@ describe 'manifest_whitespace_closing_bracket_before' do
|
|
153
153
|
end
|
154
154
|
|
155
155
|
describe 'manifest_whitespace_closing_bracket_after' do
|
156
|
-
let(:closing_bracket_msg) { 'there should be either a bracket,
|
156
|
+
let(:closing_bracket_msg) { 'there should be either a bracket, punctuation mark, closing quote or a newline after a closing bracket, or whitespace and none of the aforementioned' }
|
157
|
+
|
158
|
+
context 'with many brackets' do
|
159
|
+
let(:code) do
|
160
|
+
<<~EOF
|
161
|
+
ensure_packages($spaceweather::packages, { require => Class['Mongodb::Globals'] })
|
162
|
+
EOF
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'should detect no problems' do
|
166
|
+
expect(problems).to have(0).problem
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'with iterator' do
|
171
|
+
let(:code) do
|
172
|
+
<<~EOF
|
173
|
+
['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
|
174
|
+
}
|
175
|
+
|
176
|
+
['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
|
177
|
+
}
|
178
|
+
EOF
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'should detect no problems' do
|
182
|
+
expect(problems).to have(0).problem
|
183
|
+
end
|
184
|
+
end
|
157
185
|
|
158
186
|
context 'with spaces' do
|
159
187
|
let(:code) do
|
@@ -203,12 +231,12 @@ describe 'manifest_whitespace_closing_bracket_after' do
|
|
203
231
|
end
|
204
232
|
|
205
233
|
context 'with fix disabled' do
|
206
|
-
it 'should detect
|
207
|
-
expect(problems).to have(
|
234
|
+
it 'should detect 2 problems' do
|
235
|
+
expect(problems).to have(2).problem
|
208
236
|
end
|
209
237
|
|
210
238
|
it 'should create a error' do
|
211
|
-
expect(problems).to contain_error(closing_bracket_msg).on_line(
|
239
|
+
expect(problems).to contain_error(closing_bracket_msg).on_line(23).in_column(22)
|
212
240
|
end
|
213
241
|
end
|
214
242
|
|
@@ -236,7 +264,7 @@ describe 'manifest_whitespace_closing_bracket_after' do
|
|
236
264
|
class example (
|
237
265
|
String $content,
|
238
266
|
) {
|
239
|
-
$value = { 'key' => ['value']}
|
267
|
+
$value = { 'key' => ['value'] }
|
240
268
|
$value2 = [
|
241
269
|
{
|
242
270
|
'key' => 'value1',
|
@@ -19,6 +19,21 @@ describe 'manifest_whitespace_opening_brace_before' do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
context 'with cases' do
|
23
|
+
let(:code) do
|
24
|
+
<<~EOF
|
25
|
+
case $facts['kernel'] {
|
26
|
+
'OpenBSD': { $has_wordexp = false }
|
27
|
+
default: { $has_wordexp = true }
|
28
|
+
}
|
29
|
+
EOF
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should detect no problems' do
|
33
|
+
expect(problems).to have(0).problem
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
22
37
|
context 'with no spaces' do
|
23
38
|
let(:code) do
|
24
39
|
<<~EOF
|
@@ -5,6 +5,22 @@ require 'spec_helper'
|
|
5
5
|
describe 'manifest_whitespace_opening_bracket_before' do
|
6
6
|
let(:opening_bracket_msg) { 'there should be a single space before an opening bracket' }
|
7
7
|
|
8
|
+
context 'with iterator' do
|
9
|
+
let(:code) do
|
10
|
+
<<~EOF
|
11
|
+
['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
|
12
|
+
}
|
13
|
+
|
14
|
+
['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
|
15
|
+
}
|
16
|
+
EOF
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should detect no problems' do
|
20
|
+
expect(problems).to have(0).problem
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
8
24
|
context 'with no spaces' do
|
9
25
|
let(:code) do
|
10
26
|
<<~EOF
|
@@ -228,6 +244,22 @@ end
|
|
228
244
|
describe 'manifest_whitespace_opening_bracket_after' do
|
229
245
|
let(:opening_bracket_msg) { 'there should be no whitespace or a single newline after an opening bracket' }
|
230
246
|
|
247
|
+
context 'with iterator' do
|
248
|
+
let(:code) do
|
249
|
+
<<~EOF
|
250
|
+
['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
|
251
|
+
}
|
252
|
+
|
253
|
+
['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
|
254
|
+
}
|
255
|
+
EOF
|
256
|
+
end
|
257
|
+
|
258
|
+
it 'should detect no problems' do
|
259
|
+
expect(problems).to have(0).problem
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
231
263
|
context 'with a single space' do
|
232
264
|
let(:code) do
|
233
265
|
<<~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.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jo Vandeginste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|