puppet-lint-manifest_whitespace-check 0.2.0 → 0.2.2
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 +6 -16
- data/lib/puppet-lint/plugins/check_manifest_whitespace_closing_bracket.rb +3 -9
- data/lib/puppet-lint/plugins/check_manifest_whitespace_opening_brace.rb +14 -7
- data/lib/puppet-lint/plugins/check_manifest_whitespace_opening_bracket.rb +3 -9
- data/spec/puppet-lint/plugins/manifest_whitespace_class_header_spec.rb +3 -1
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_brace_spec.rb +15 -1
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_bracket_spec.rb +3 -1
- data/spec/puppet-lint/plugins/manifest_whitespace_double_newline_end_of_file_spec.rb +12 -12
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_brace_spec.rb +53 -0
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_bracket_spec.rb +0 -1
- 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: bd465f6f8f5fe07dc5de6b9a9c3eb36e8f99e5c647e3d48a6001cd0f32749cf9
|
4
|
+
data.tar.gz: e0bb7d7f3ee60d7bfed54e28ee24b78dae5a8477b870e41b33902bb86b3a5407
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85069ac6a3e3c7a349eea0e102a35f737204b210d35caf451e71ccd04da54bc241061947be20a93dc2adfc4a0ca91bc429243c27b7d4c50cc2fe072971dfecfd
|
7
|
+
data.tar.gz: a7bde6a55568780469a5576c2353d77108c86e5e6ca84a448992fb9549dd89530f140ca2a1aae1f268145c25321b3acc8467706215a16fd90093043016691459
|
@@ -9,19 +9,13 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_before) do
|
|
9
9
|
next unless prev_token && prev_code_token
|
10
10
|
next if %i[LBRACE].include?(prev_token.type)
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
next
|
15
|
-
end
|
12
|
+
if !%i[LBRACE].include?(prev_code_token.type) && (is_single_space(prev_token) && tokens.index(prev_code_token) == tokens.index(brace_token) - 2)
|
13
|
+
next
|
16
14
|
end
|
17
15
|
|
18
|
-
if prev_token.type == :INDENT
|
19
|
-
next if tokens.index(prev_code_token) == tokens.index(brace_token) - 3
|
20
|
-
end
|
16
|
+
next if prev_token.type == :INDENT && (tokens.index(prev_code_token) == tokens.index(brace_token) - 3)
|
21
17
|
|
22
|
-
if prev_token.type == :NEWLINE
|
23
|
-
next if tokens.index(prev_code_token) == tokens.index(brace_token) - 2
|
24
|
-
end
|
18
|
+
next if prev_token.type == :NEWLINE && (tokens.index(prev_code_token) == tokens.index(brace_token) - 2)
|
25
19
|
|
26
20
|
notify(
|
27
21
|
:error,
|
@@ -39,13 +33,9 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_before) do
|
|
39
33
|
next_token = token
|
40
34
|
|
41
35
|
until next_token.type == :RBRACE
|
42
|
-
if tokens[tokens.index(next_token)..-1].first(2).collect(&:type) == %i[NEWLINE RBRACE]
|
43
|
-
break
|
44
|
-
end
|
36
|
+
break if tokens[tokens.index(next_token)..-1].first(2).collect(&:type) == %i[NEWLINE RBRACE]
|
45
37
|
|
46
|
-
if tokens[tokens.index(next_token)..-1].first(3).collect(&:type) == %i[NEWLINE INDENT RBRACE]
|
47
|
-
break
|
48
|
-
end
|
38
|
+
break if tokens[tokens.index(next_token)..-1].first(3).collect(&:type) == %i[NEWLINE INDENT RBRACE]
|
49
39
|
|
50
40
|
remove_token(next_token)
|
51
41
|
next_token = next_token.next_token
|
@@ -11,12 +11,8 @@ PuppetLint.new_check(:manifest_whitespace_closing_bracket_before) do
|
|
11
11
|
|
12
12
|
next unless %i[NEWLINE INDENT WHITESPACE].include?(prev_token.type)
|
13
13
|
|
14
|
-
if prev_token.type == :INDENT
|
15
|
-
|
16
|
-
end
|
17
|
-
if prev_token.type == :NEWLINE
|
18
|
-
next if tokens.index(prev_code_token) == tokens.index(bracket_token) - 2
|
19
|
-
end
|
14
|
+
next if prev_token.type == :INDENT && (tokens.index(prev_code_token) == tokens.index(bracket_token) - 3)
|
15
|
+
next if prev_token.type == :NEWLINE && (tokens.index(prev_code_token) == tokens.index(bracket_token) - 2)
|
20
16
|
|
21
17
|
notify(
|
22
18
|
:error,
|
@@ -37,9 +33,7 @@ PuppetLint.new_check(:manifest_whitespace_closing_bracket_before) do
|
|
37
33
|
|
38
34
|
next_token = token.next_token
|
39
35
|
until next_token.type == :RBRACK
|
40
|
-
if next_token.type == :INDENT && next_token.next_token.type == :RBRACK
|
41
|
-
break
|
42
|
-
end
|
36
|
+
break if next_token.type == :INDENT && next_token.next_token.type == :RBRACK
|
43
37
|
|
44
38
|
remove_token(next_token)
|
45
39
|
next_token = next_token.next_token
|
@@ -7,11 +7,17 @@ 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
|
-
|
11
|
-
|
10
|
+
|
11
|
+
next if %i[COMMENT COLON].include?(prev_code_token.type)
|
12
|
+
|
13
|
+
if %i[LPAREN LBRACK LBRACE].include?(prev_code_token.type)
|
14
|
+
next if tokens.index(prev_code_token) == tokens.index(brace_token) - 1
|
15
|
+
next if tokens[tokens.index(prev_code_token)..tokens.index(brace_token)].collect(&:type).include?(:NEWLINE)
|
16
|
+
|
17
|
+
else
|
18
|
+
next unless tokens.index(prev_code_token) != tokens.index(brace_token) - 2 ||
|
19
|
+
!is_single_space(prev_token)
|
12
20
|
end
|
13
|
-
next unless tokens.index(prev_code_token) != tokens.index(brace_token) - 2 ||
|
14
|
-
!is_single_space(prev_token)
|
15
21
|
|
16
22
|
notify(
|
17
23
|
:error,
|
@@ -29,7 +35,8 @@ PuppetLint.new_check(:manifest_whitespace_opening_brace_before) do
|
|
29
35
|
prev_code_token = prev_non_space_token(token)
|
30
36
|
|
31
37
|
while prev_code_token != prev_token
|
32
|
-
|
38
|
+
if !%i[LPAREN LBRACK LBRACE].include?(prev_code_token.type) &&
|
39
|
+
%i[WHITESPACE INDENT NEWLINE].include?(prev_token.type)
|
33
40
|
raise PuppetLint::NoFix
|
34
41
|
end
|
35
42
|
|
@@ -37,7 +44,7 @@ PuppetLint.new_check(:manifest_whitespace_opening_brace_before) do
|
|
37
44
|
prev_token = prev_token.prev_token
|
38
45
|
end
|
39
46
|
|
40
|
-
add_token(tokens.index(token), new_single_space)
|
47
|
+
add_token(tokens.index(token), new_single_space) unless %i[LPAREN LBRACK LBRACE].include?(prev_code_token.type)
|
41
48
|
end
|
42
49
|
end
|
43
50
|
|
@@ -47,7 +54,7 @@ PuppetLint.new_check(:manifest_whitespace_opening_brace_after) do
|
|
47
54
|
next_token = brace_token.next_token
|
48
55
|
|
49
56
|
next unless next_token && !is_single_space(next_token)
|
50
|
-
next if %i[RBRACE].include?(next_token.type)
|
57
|
+
next if %i[RBRACE LBRACK LBRACE].include?(next_token.type)
|
51
58
|
|
52
59
|
if next_token.type == :NEWLINE
|
53
60
|
next_token = next_token.next_token
|
@@ -7,14 +7,10 @@ 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
|
-
if %i[LBRACK LBRACE COMMA SEMIC COMMENT].include?(prev_code_token.type)
|
11
|
-
next
|
12
|
-
end
|
10
|
+
next if %i[LBRACK LBRACE COMMA SEMIC COMMENT NAME].include?(prev_code_token.type)
|
13
11
|
next unless %i[WHITESPACE NEWLINE INDENT].include?(prev_token.type)
|
14
12
|
|
15
|
-
if %i[INDENT NEWLINE].include?(prev_token.type) && %i[RBRACK RBRACE].include?(prev_code_token.type)
|
16
|
-
next
|
17
|
-
end
|
13
|
+
next if %i[INDENT NEWLINE].include?(prev_token.type) && %i[RBRACK RBRACE].include?(prev_code_token.type)
|
18
14
|
next unless tokens.index(prev_code_token) != tokens.index(bracket_token) - 2 ||
|
19
15
|
!is_single_space(prev_token)
|
20
16
|
|
@@ -34,9 +30,7 @@ PuppetLint.new_check(:manifest_whitespace_opening_bracket_before) do
|
|
34
30
|
prev_code_token = prev_non_space_token(token)
|
35
31
|
|
36
32
|
while prev_code_token != prev_token
|
37
|
-
unless %i[WHITESPACE INDENT NEWLINE].include?(prev_token.type)
|
38
|
-
raise PuppetLint::NoFix
|
39
|
-
end
|
33
|
+
raise PuppetLint::NoFix unless %i[WHITESPACE INDENT NEWLINE].include?(prev_token.type)
|
40
34
|
|
41
35
|
remove_token(prev_token)
|
42
36
|
prev_token = prev_token.prev_token
|
@@ -3,7 +3,9 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe 'manifest_whitespace_class_name_single_space_before' do
|
6
|
-
let(:single_space_msg) {
|
6
|
+
let(:single_space_msg) {
|
7
|
+
'there should be a single space between the class or defined resource statement and the name'
|
8
|
+
}
|
7
9
|
|
8
10
|
context 'with two spaces' do
|
9
11
|
let(:code) do
|
@@ -402,7 +402,9 @@ describe 'manifest_whitespace_closing_brace_before' do
|
|
402
402
|
end
|
403
403
|
|
404
404
|
describe 'manifest_whitespace_closing_brace_after' do
|
405
|
-
let(:closing_brace_msg)
|
405
|
+
let(:closing_brace_msg) do
|
406
|
+
'there should be either a bracket, punctuation mark, closing quote or a newline after a closing brace, or whitespace and none of the aforementioned'
|
407
|
+
end
|
406
408
|
|
407
409
|
context 'with iterator' do
|
408
410
|
let(:code) do
|
@@ -417,6 +419,18 @@ describe 'manifest_whitespace_closing_brace_after' do
|
|
417
419
|
end
|
418
420
|
end
|
419
421
|
|
422
|
+
context 'inline with a function after' do
|
423
|
+
let(:code) do
|
424
|
+
<<~EOF
|
425
|
+
Hash({ $key => $return_value } )
|
426
|
+
EOF
|
427
|
+
end
|
428
|
+
|
429
|
+
it 'should detect 1 problem' do
|
430
|
+
expect(problems).to have(1).problem
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
420
434
|
context 'with spaces' do
|
421
435
|
let(:code) do
|
422
436
|
<<~EOF
|
@@ -153,7 +153,9 @@ 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) {
|
156
|
+
let(:closing_bracket_msg) {
|
157
|
+
'there should be either a bracket, punctuation mark, closing quote or a newline after a closing bracket, or whitespace and none of the aforementioned'
|
158
|
+
}
|
157
159
|
|
158
160
|
context 'with many brackets' do
|
159
161
|
let(:code) do
|
@@ -28,8 +28,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
28
28
|
context 'with 1 empty line at the end of a manifest' do
|
29
29
|
let(:code) do
|
30
30
|
<<~EOF
|
31
|
-
|
32
|
-
|
31
|
+
class example {
|
32
|
+
}
|
33
33
|
|
34
34
|
EOF
|
35
35
|
end
|
@@ -46,8 +46,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
46
46
|
context 'with 3 empty lines at the end of a manifest' do
|
47
47
|
let(:code) do
|
48
48
|
<<~EOF
|
49
|
-
|
50
|
-
|
49
|
+
class example {
|
50
|
+
}
|
51
51
|
|
52
52
|
|
53
53
|
|
@@ -78,8 +78,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
78
78
|
context 'with 1 empty line at the end of a manifest' do
|
79
79
|
let(:code) do
|
80
80
|
<<~EOF
|
81
|
-
|
82
|
-
|
81
|
+
class example {
|
82
|
+
}
|
83
83
|
|
84
84
|
EOF
|
85
85
|
end
|
@@ -95,8 +95,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
95
95
|
it 'should add the final newline' do
|
96
96
|
expect(manifest).to eq(
|
97
97
|
<<~EOF
|
98
|
-
|
99
|
-
|
98
|
+
class example {
|
99
|
+
}
|
100
100
|
EOF
|
101
101
|
)
|
102
102
|
end
|
@@ -105,8 +105,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
105
105
|
context 'with 3 empty lines at the end of a manifest' do
|
106
106
|
let(:code) do
|
107
107
|
<<~EOF
|
108
|
-
|
109
|
-
|
108
|
+
class example {
|
109
|
+
}
|
110
110
|
|
111
111
|
|
112
112
|
|
@@ -126,8 +126,8 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
|
|
126
126
|
it 'should add the final newline' do
|
127
127
|
expect(manifest).to eq(
|
128
128
|
<<~EOF
|
129
|
-
|
130
|
-
|
129
|
+
class example {
|
130
|
+
}
|
131
131
|
EOF
|
132
132
|
)
|
133
133
|
end
|
@@ -19,6 +19,59 @@ describe 'manifest_whitespace_opening_brace_before' do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
context 'inside, inline with function' do
|
23
|
+
let(:code) do
|
24
|
+
<<~EOF
|
25
|
+
$sssd_config = {
|
26
|
+
▏ 'sssd' => merge($config, {
|
27
|
+
▏ ▏ ▏ 'domains' => $domains,
|
28
|
+
▏ ▏ ▏ 'services' => 'nss,pam',
|
29
|
+
▏ }),
|
30
|
+
}
|
31
|
+
EOF
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should detect no problems' do
|
35
|
+
expect(problems).to be_empty
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'inside interpolation' do
|
40
|
+
let(:code) do
|
41
|
+
<<~EOF
|
42
|
+
my_define { "foo-${myvar}": }
|
43
|
+
EOF
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should detect no problems' do
|
47
|
+
expect(problems).to be_empty
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'inline with a function before' do
|
52
|
+
let(:code) do
|
53
|
+
<<~EOF
|
54
|
+
Hash( { $key => $return_value })
|
55
|
+
EOF
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should detect 1 problem' do
|
59
|
+
expect(problems).to have(1).problem
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'inline with a function' do
|
64
|
+
let(:code) do
|
65
|
+
<<~EOF
|
66
|
+
Hash({ $key => $return_value })
|
67
|
+
EOF
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should detect no problems' do
|
71
|
+
expect(problems).to be_empty
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
22
75
|
context 'inside a function' do
|
23
76
|
let(:code) do
|
24
77
|
<<~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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jo Vandeginste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|