puppet-lint-manifest_whitespace-check 0.1.11 → 0.1.16
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 +2 -2
- data/lib/puppet-lint/plugins/check_manifest_whitespace_opening_brace.rb +1 -1
- data/lib/puppet-lint/plugins/check_manifest_whitespace_opening_bracket.rb +5 -2
- data/lib/puppet-lint/plugins/tools.rb +1 -1
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_brace_spec.rb +31 -1
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_bracket_spec.rb +16 -4
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_bracket_spec.rb +19 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af72a48c82a227107871c1e7b83a3bec2a101aab3cef89bbd3d6ce426122334d
|
4
|
+
data.tar.gz: c7bc25b60155836000ec44971dd88832fafd413cac0e89107c49be5e86e804c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24961bb90cab1231db45ad634bf31444a276645d371401168956a436dd977e23166b19d5b1880e96d8ebfc64c3c53da68c4a65e92643a421094fae5a693ec2f0
|
7
|
+
data.tar.gz: c57d69810e67d335b597cb8257d627a07ac6c31fde14e37f64b8c05e4bb83fc750ca9e87699689211f299268ca287e89d76835259667d6b0876c3ed94f40b04e
|
@@ -25,7 +25,7 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_before) do
|
|
25
25
|
|
26
26
|
notify(
|
27
27
|
:error,
|
28
|
-
message: 'there should be a
|
28
|
+
message: 'there should be a single space or newline before a closing brace',
|
29
29
|
line: prev_code_token.next_token.line,
|
30
30
|
column: prev_code_token.next_token.column,
|
31
31
|
token: prev_code_token.next_token,
|
@@ -51,7 +51,7 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_before) do
|
|
51
51
|
next_token = next_token.next_token
|
52
52
|
end
|
53
53
|
|
54
|
-
if next_token.type == :RBRACE && !%i[LBRACE
|
54
|
+
if next_token.type == :RBRACE && !%i[LBRACE NEWLINE INDENT].include?(next_token.prev_token.type)
|
55
55
|
add_token(tokens.index(next_token), new_single_space)
|
56
56
|
end
|
57
57
|
end
|
@@ -47,7 +47,7 @@ PuppetLint.new_check(:manifest_whitespace_opening_brace_after) do
|
|
47
47
|
next_token = brace_token.next_token
|
48
48
|
|
49
49
|
next unless next_token && !is_single_space(next_token)
|
50
|
-
next if %i[
|
50
|
+
next if %i[RBRACE].include?(next_token.type)
|
51
51
|
|
52
52
|
if next_token.type == :NEWLINE
|
53
53
|
next_token = next_token.next_token
|
@@ -7,9 +7,12 @@ PuppetLint.new_check(:manifest_whitespace_opening_bracket_before) do
|
|
7
7
|
prev_code_token = prev_non_space_token(bracket_token)
|
8
8
|
|
9
9
|
next unless prev_token && prev_code_token
|
10
|
-
|
10
|
+
if %i[LBRACK LBRACE COMMA SEMIC COMMENT].include?(prev_code_token.type)
|
11
|
+
next
|
12
|
+
end
|
11
13
|
next unless %i[WHITESPACE NEWLINE INDENT].include?(prev_token.type)
|
12
|
-
|
14
|
+
|
15
|
+
if %i[INDENT NEWLINE].include?(prev_token.type) && %i[RBRACK RBRACE].include?(prev_code_token.type)
|
13
16
|
next
|
14
17
|
end
|
15
18
|
next unless tokens.index(prev_code_token) != tokens.index(bracket_token) - 2 ||
|
@@ -3,7 +3,37 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe 'manifest_whitespace_closing_brace_before' do
|
6
|
-
let(:closing_brace_msg) { 'there should be a
|
6
|
+
let(:closing_brace_msg) { 'there should be a single space or newline before a closing brace' }
|
7
|
+
|
8
|
+
context 'with plus' do
|
9
|
+
let(:code) do
|
10
|
+
<<~EOF
|
11
|
+
$my_images = { 'default' => {}}
|
12
|
+
EOF
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with fix enabled' do
|
16
|
+
before do
|
17
|
+
PuppetLint.configuration.fix = true
|
18
|
+
end
|
19
|
+
|
20
|
+
after do
|
21
|
+
PuppetLint.configuration.fix = false
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should fix a error' do
|
25
|
+
expect(problems).to contain_fixed(closing_brace_msg)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should add spaces' do
|
29
|
+
expect(manifest).to eq(
|
30
|
+
<<~EOF,
|
31
|
+
$my_images = { 'default' => {} }
|
32
|
+
EOF
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
7
37
|
|
8
38
|
context 'with nested hash' do
|
9
39
|
let(:code) do
|
@@ -155,6 +155,18 @@ end
|
|
155
155
|
describe 'manifest_whitespace_closing_bracket_after' do
|
156
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
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
|
+
|
158
170
|
context 'with iterator' do
|
159
171
|
let(:code) do
|
160
172
|
<<~EOF
|
@@ -219,12 +231,12 @@ describe 'manifest_whitespace_closing_bracket_after' do
|
|
219
231
|
end
|
220
232
|
|
221
233
|
context 'with fix disabled' do
|
222
|
-
it 'should detect
|
223
|
-
expect(problems).to have(
|
234
|
+
it 'should detect 2 problems' do
|
235
|
+
expect(problems).to have(2).problem
|
224
236
|
end
|
225
237
|
|
226
238
|
it 'should create a error' do
|
227
|
-
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)
|
228
240
|
end
|
229
241
|
end
|
230
242
|
|
@@ -252,7 +264,7 @@ describe 'manifest_whitespace_closing_bracket_after' do
|
|
252
264
|
class example (
|
253
265
|
String $content,
|
254
266
|
) {
|
255
|
-
$value = { 'key' => ['value']}
|
267
|
+
$value = { 'key' => ['value'] }
|
256
268
|
$value2 = [
|
257
269
|
{
|
258
270
|
'key' => 'value1',
|
@@ -8,10 +8,27 @@ describe 'manifest_whitespace_opening_bracket_before' do
|
|
8
8
|
context 'with iterator' do
|
9
9
|
let(:code) do
|
10
10
|
<<~EOF
|
11
|
-
|
11
|
+
{
|
12
|
+
# some generic comment
|
13
|
+
['some', 'values']
|
12
14
|
}
|
15
|
+
EOF
|
16
|
+
end
|
13
17
|
|
14
|
-
|
18
|
+
it 'should detect no problems' do
|
19
|
+
expect(problems).to have(0).problem
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'with iterator' do
|
24
|
+
let(:code) do
|
25
|
+
<<~EOF
|
26
|
+
{
|
27
|
+
if condition {
|
28
|
+
}
|
29
|
+
|
30
|
+
['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
|
31
|
+
}
|
15
32
|
}
|
16
33
|
EOF
|
17
34
|
end
|