puppet-lint-manifest_whitespace-check 0.1.12 → 0.1.17
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_class_name_single_space.rb +9 -7
- data/lib/puppet-lint/plugins/check_manifest_whitespace_closing_brace.rb +2 -2
- 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_class_header_spec.rb +5 -5
- 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_brace_spec.rb +40 -0
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_bracket_spec.rb +19 -2
- 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: 242cfac889870bbdd8d1346f1adafb8348b868945e9cfbe9adebebf6c4468c59
|
4
|
+
data.tar.gz: 0fd2197f54e3f911e077d3315458a0e2c44e69230570757cf26a7fc26db0d89e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc1eea7da122458e2cda3cad1820548774a57149ec6ae6061fd75e20388a82af98e4d93e740f15bfdb623e6f4ee5cd647d189e6c30285238712040eddbcc8f0f
|
7
|
+
data.tar.gz: 80b25a77380531e248bb146af17a010818e4782698fe85972cf97245a27ab2383fb8b2a3cc69875c56afd6a3ef3e3fe769d05a770bd858a45e5de4e55af5aecd
|
@@ -43,20 +43,22 @@ PuppetLint.new_check(:manifest_whitespace_class_name_single_space_after) do
|
|
43
43
|
notify(
|
44
44
|
:error,
|
45
45
|
message: 'there should be a single space between the class or resource name and the next item',
|
46
|
-
line:
|
47
|
-
column:
|
48
|
-
token:
|
46
|
+
line: name_token.line,
|
47
|
+
column: name_token.column,
|
48
|
+
token: name_token,
|
49
49
|
)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
def fix(problem)
|
54
54
|
token = problem[:token]
|
55
|
-
next_code_token = next_non_space_token(token.prev_token)
|
56
55
|
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
next_token = token.next_token
|
57
|
+
next_code_token = next_non_space_token(token)
|
58
|
+
|
59
|
+
while next_token != next_code_token
|
60
|
+
remove_token(next_token)
|
61
|
+
next_token = next_token.next_token
|
60
62
|
end
|
61
63
|
|
62
64
|
add_token(tokens.index(next_code_token), new_single_space)
|
@@ -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
|
@@ -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 ||
|
@@ -119,7 +119,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
it 'should create a error' do
|
122
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(
|
122
|
+
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(7)
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
@@ -183,7 +183,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
|
|
183
183
|
end
|
184
184
|
|
185
185
|
it 'should create a error' do
|
186
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(
|
186
|
+
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(7)
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
@@ -245,7 +245,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
|
|
245
245
|
end
|
246
246
|
|
247
247
|
it 'should create a error' do
|
248
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(
|
248
|
+
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(7)
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
@@ -307,7 +307,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
|
|
307
307
|
end
|
308
308
|
|
309
309
|
it 'should create a error' do
|
310
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(
|
310
|
+
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(7)
|
311
311
|
end
|
312
312
|
end
|
313
313
|
|
@@ -372,7 +372,7 @@ describe 'manifest_whitespace_class_name_single_space_after' do
|
|
372
372
|
end
|
373
373
|
|
374
374
|
it 'should create a error' do
|
375
|
-
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(
|
375
|
+
expect(problems).to contain_error(single_space_msg).on_line(6).in_column(7)
|
376
376
|
end
|
377
377
|
end
|
378
378
|
|
@@ -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',
|
@@ -34,6 +34,46 @@ describe 'manifest_whitespace_opening_brace_before' do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
context 'with class no spaces' do
|
38
|
+
let(:code) do
|
39
|
+
<<~EOF
|
40
|
+
class example{
|
41
|
+
# some generic comment
|
42
|
+
}
|
43
|
+
EOF
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'with fix disabled' do
|
47
|
+
it 'should detect a problem' do
|
48
|
+
expect(problems).to have(1).problem
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should create a error' do
|
52
|
+
expect(problems).to contain_error(opening_brace_msg).on_line(1).in_column(14)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with fix enabled' do
|
57
|
+
before do
|
58
|
+
PuppetLint.configuration.fix = true
|
59
|
+
end
|
60
|
+
|
61
|
+
after do
|
62
|
+
PuppetLint.configuration.fix = false
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should add a space' do
|
66
|
+
expect(manifest).to eq(
|
67
|
+
<<~EOF,
|
68
|
+
class example {
|
69
|
+
# some generic comment
|
70
|
+
}
|
71
|
+
EOF
|
72
|
+
)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
37
77
|
context 'with no spaces' do
|
38
78
|
let(:code) do
|
39
79
|
<<~EOF
|
@@ -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
|
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.17
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|