puppet-lint-manifest_whitespace-check 0.2.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/puppet-lint/plugins/check_manifest_whitespace_closing_brace.rb +2 -6
- data/lib/puppet-lint/plugins/check_manifest_whitespace_opening_bracket.rb +2 -1
- data/spec/puppet-lint/plugins/manifest_whitespace_arrow_spaces_spec.rb +45 -45
- data/spec/puppet-lint/plugins/manifest_whitespace_class_header_spec.rb +63 -63
- data/spec/puppet-lint/plugins/manifest_whitespace_class_inherits_spec.rb +9 -9
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_brace_spec.rb +53 -53
- data/spec/puppet-lint/plugins/manifest_whitespace_closing_bracket_spec.rb +67 -67
- data/spec/puppet-lint/plugins/manifest_whitespace_double_newline_end_of_file_spec.rb +27 -27
- data/spec/puppet-lint/plugins/manifest_whitespace_double_newline_spec.rb +9 -9
- data/spec/puppet-lint/plugins/manifest_whitespace_missing_newline_end_of_file_spec.rb +20 -5
- data/spec/puppet-lint/plugins/manifest_whitespace_newline_begin_of_file_spec.rb +25 -25
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_brace_spec.rb +126 -100
- data/spec/puppet-lint/plugins/manifest_whitespace_opening_bracket_spec.rb +80 -68
- data/spec/spec_helper.rb +2 -0
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7a82b75562b3f216e849bb8b6600982ccfd262bb0eb7fe97a1669510187c061
|
4
|
+
data.tar.gz: 1b00868a696b0dfeee05148f58d413244c579e50d35fcb47f05f3d68b5c18117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2c308c27fb7b90390fddd309c125cd72036af8d24ae43ae871a8de1f0d97bfc9126099c0a30fdf052bc8fedb6da4c5800dbd6ca35d418d59e826578d7a540d6
|
7
|
+
data.tar.gz: 7fda90bd22b2c51a73f6782874ba8ff2009532a54a233424537a6a5fe2cc234edc4e05ffc9038148ed225d3e0232f47ee69793bdad4ce5a3216ee755d30213c4
|
@@ -9,9 +9,7 @@ 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
|
-
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
|
14
|
-
end
|
12
|
+
next if !%i[LBRACE].include?(prev_code_token.type) && (is_single_space(prev_token) && tokens.index(prev_code_token) == tokens.index(brace_token) - 2)
|
15
13
|
|
16
14
|
next if prev_token.type == :INDENT && (tokens.index(prev_code_token) == tokens.index(brace_token) - 3)
|
17
15
|
|
@@ -41,9 +39,7 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_before) do
|
|
41
39
|
next_token = next_token.next_token
|
42
40
|
end
|
43
41
|
|
44
|
-
if next_token.type == :RBRACE && !%i[LBRACE NEWLINE INDENT].include?(next_token.prev_token.type)
|
45
|
-
add_token(tokens.index(next_token), new_single_space)
|
46
|
-
end
|
42
|
+
add_token(tokens.index(next_token), new_single_space) if next_token.type == :RBRACE && !%i[LBRACE NEWLINE INDENT].include?(next_token.prev_token.type)
|
47
43
|
end
|
48
44
|
end
|
49
45
|
|
@@ -25,8 +25,9 @@ PuppetLint.new_check(:manifest_whitespace_opening_bracket_before) do
|
|
25
25
|
|
26
26
|
if prev_code_token.type == :LBRACE
|
27
27
|
ppct = prev_non_space_token(prev_code_token)
|
28
|
+
next unless ppct
|
28
29
|
|
29
|
-
if
|
30
|
+
if %i[NAME PIPE].include?(ppct.type)
|
30
31
|
next if %i[INDENT NEWLINE].include?(prev_token.type)
|
31
32
|
next if tokens.index(prev_code_token) == tokens.index(bracket_token) - 2 && is_single_space(prev_token)
|
32
33
|
end
|
@@ -7,19 +7,19 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
7
7
|
|
8
8
|
context 'with two spaces' do
|
9
9
|
let(:code) do
|
10
|
-
<<~
|
10
|
+
<<~CODE
|
11
11
|
class { 'example2':
|
12
12
|
param1 => 'value1',
|
13
13
|
}
|
14
|
-
|
14
|
+
CODE
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'with fix disabled' do
|
18
|
-
it '
|
18
|
+
it 'detects a single problem' do
|
19
19
|
expect(problems).to have(1).problem
|
20
20
|
end
|
21
21
|
|
22
|
-
it '
|
22
|
+
it 'creates a error' do
|
23
23
|
expect(problems).to contain_error(single_space_msg).on_line(2).in_column(12)
|
24
24
|
end
|
25
25
|
end
|
@@ -33,21 +33,21 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
33
33
|
PuppetLint.configuration.fix = false
|
34
34
|
end
|
35
35
|
|
36
|
-
it '
|
36
|
+
it 'detects a single problem' do
|
37
37
|
expect(problems).to have(1).problem
|
38
38
|
end
|
39
39
|
|
40
|
-
it '
|
40
|
+
it 'fixes the manifest' do
|
41
41
|
expect(problems).to contain_fixed(single_space_msg)
|
42
42
|
end
|
43
43
|
|
44
|
-
it '
|
44
|
+
it 'fixes the space' do
|
45
45
|
expect(manifest).to eq(
|
46
|
-
<<~
|
46
|
+
<<~CODE,
|
47
47
|
class { 'example2':
|
48
48
|
param1 => 'value1',
|
49
49
|
}
|
50
|
-
|
50
|
+
CODE
|
51
51
|
)
|
52
52
|
end
|
53
53
|
end
|
@@ -55,19 +55,19 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
55
55
|
|
56
56
|
context 'with no spaces' do
|
57
57
|
let(:code) do
|
58
|
-
<<~
|
58
|
+
<<~CODE
|
59
59
|
class { 'example2':
|
60
60
|
param1 =>'value1',
|
61
61
|
}
|
62
|
-
|
62
|
+
CODE
|
63
63
|
end
|
64
64
|
|
65
65
|
context 'with fix disabled' do
|
66
|
-
it '
|
66
|
+
it 'detects a single problem' do
|
67
67
|
expect(problems).to have(1).problem
|
68
68
|
end
|
69
69
|
|
70
|
-
it '
|
70
|
+
it 'creates a error' do
|
71
71
|
expect(problems).to contain_error(single_space_msg).on_line(2).in_column(12)
|
72
72
|
end
|
73
73
|
end
|
@@ -81,21 +81,21 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
81
81
|
PuppetLint.configuration.fix = false
|
82
82
|
end
|
83
83
|
|
84
|
-
it '
|
84
|
+
it 'detects a single problem' do
|
85
85
|
expect(problems).to have(1).problem
|
86
86
|
end
|
87
87
|
|
88
|
-
it '
|
88
|
+
it 'fixes the manifest' do
|
89
89
|
expect(problems).to contain_fixed(single_space_msg)
|
90
90
|
end
|
91
91
|
|
92
|
-
it '
|
92
|
+
it 'fixes the space' do
|
93
93
|
expect(manifest).to eq(
|
94
|
-
<<~
|
94
|
+
<<~CODE,
|
95
95
|
class { 'example2':
|
96
96
|
param1 => 'value1',
|
97
97
|
}
|
98
|
-
|
98
|
+
CODE
|
99
99
|
)
|
100
100
|
end
|
101
101
|
end
|
@@ -103,19 +103,19 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
103
103
|
|
104
104
|
context 'with string as space' do
|
105
105
|
let(:code) do
|
106
|
-
<<~
|
106
|
+
<<~CODE
|
107
107
|
class { 'example2':
|
108
108
|
param1 =>' ',
|
109
109
|
}
|
110
|
-
|
110
|
+
CODE
|
111
111
|
end
|
112
112
|
|
113
113
|
context 'with fix disabled' do
|
114
|
-
it '
|
114
|
+
it 'detects a single problem' do
|
115
115
|
expect(problems).to have(1).problem
|
116
116
|
end
|
117
117
|
|
118
|
-
it '
|
118
|
+
it 'creates a error' do
|
119
119
|
expect(problems).to contain_error(single_space_msg).on_line(2).in_column(12)
|
120
120
|
end
|
121
121
|
end
|
@@ -129,21 +129,21 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
129
129
|
PuppetLint.configuration.fix = false
|
130
130
|
end
|
131
131
|
|
132
|
-
it '
|
132
|
+
it 'detects a single problem' do
|
133
133
|
expect(problems).to have(1).problem
|
134
134
|
end
|
135
135
|
|
136
|
-
it '
|
136
|
+
it 'fixes the manifest' do
|
137
137
|
expect(problems).to contain_fixed(single_space_msg)
|
138
138
|
end
|
139
139
|
|
140
|
-
it '
|
140
|
+
it 'fixes the space' do
|
141
141
|
expect(manifest).to eq(
|
142
|
-
<<~
|
142
|
+
<<~CODE,
|
143
143
|
class { 'example2':
|
144
144
|
param1 => ' ',
|
145
145
|
}
|
146
|
-
|
146
|
+
CODE
|
147
147
|
)
|
148
148
|
end
|
149
149
|
end
|
@@ -151,22 +151,22 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
151
151
|
|
152
152
|
context 'many resources' do
|
153
153
|
let(:code) do
|
154
|
-
<<~
|
154
|
+
<<~CODE
|
155
155
|
class { 'example2':
|
156
156
|
param1 =>'value1',
|
157
157
|
param2 => 'value2',
|
158
158
|
param3 => 'value3',
|
159
159
|
param4 => 'value4',
|
160
160
|
}
|
161
|
-
|
161
|
+
CODE
|
162
162
|
end
|
163
163
|
|
164
164
|
context 'with fix disabled' do
|
165
|
-
it '
|
165
|
+
it 'detects a single problem' do
|
166
166
|
expect(problems).to have(3).problems
|
167
167
|
end
|
168
168
|
|
169
|
-
it '
|
169
|
+
it 'creates a error' do
|
170
170
|
expect(problems).to contain_error(single_space_msg).on_line(2).in_column(12)
|
171
171
|
expect(problems).to contain_error(single_space_msg).on_line(4).in_column(12)
|
172
172
|
expect(problems).to contain_error(single_space_msg).on_line(5).in_column(12)
|
@@ -182,24 +182,24 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
182
182
|
PuppetLint.configuration.fix = false
|
183
183
|
end
|
184
184
|
|
185
|
-
it '
|
185
|
+
it 'detects a single problem' do
|
186
186
|
expect(problems).to have(3).problem
|
187
187
|
end
|
188
188
|
|
189
|
-
it '
|
189
|
+
it 'fixes the manifest' do
|
190
190
|
expect(problems).to contain_fixed(single_space_msg)
|
191
191
|
end
|
192
192
|
|
193
|
-
it '
|
193
|
+
it 'fixes the space' do
|
194
194
|
expect(manifest).to eq(
|
195
|
-
<<~
|
195
|
+
<<~CODE,
|
196
196
|
class { 'example2':
|
197
197
|
param1 => 'value1',
|
198
198
|
param2 => 'value2',
|
199
199
|
param3 => 'value3',
|
200
200
|
param4 => 'value4',
|
201
201
|
}
|
202
|
-
|
202
|
+
CODE
|
203
203
|
)
|
204
204
|
end
|
205
205
|
end
|
@@ -208,40 +208,40 @@ describe 'manifest_whitespace_arrows_single_space_after' do
|
|
208
208
|
context 'valid cases' do
|
209
209
|
context 'correct arrow' do
|
210
210
|
let(:code) do
|
211
|
-
<<~
|
211
|
+
<<~CODE
|
212
212
|
class { 'example2':
|
213
213
|
param1 => 'value1',
|
214
214
|
}
|
215
|
-
|
215
|
+
CODE
|
216
216
|
end
|
217
217
|
|
218
|
-
it '
|
218
|
+
it 'detects a no problem' do
|
219
219
|
expect(problems).to be_empty
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
223
|
context 'in a string' do
|
224
224
|
let(:code) do
|
225
|
-
<<~
|
225
|
+
<<~CODE
|
226
226
|
"param1 => 'value1'",
|
227
|
-
|
227
|
+
CODE
|
228
228
|
end
|
229
229
|
|
230
|
-
it '
|
230
|
+
it 'detects a no problem' do
|
231
231
|
expect(problems).to be_empty
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
235
235
|
context 'in a heredoc' do
|
236
236
|
let(:code) do
|
237
|
-
<<~
|
237
|
+
<<~CODE
|
238
238
|
$data = @("DATA"/L)
|
239
239
|
param1 => 'value1',
|
240
240
|
| DATA
|
241
|
-
|
241
|
+
CODE
|
242
242
|
end
|
243
243
|
|
244
|
-
it '
|
244
|
+
it 'detects a no problem' do
|
245
245
|
expect(problems).to be_empty
|
246
246
|
end
|
247
247
|
end
|