puppet-lint-manifest_whitespace-check 0.2.7 → 0.2.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f296fd04d6453e0737d586c3c64bcd76c1d92cbf906a4789c1b9a6797d032d82
4
- data.tar.gz: f8c3e2ce53f3654bb1746e5132b049111ba3d1cfabc11174fb121c312ff403ab
3
+ metadata.gz: 3fc583d9842a6466e61e1f6f2f9403f8fc5cb8e0958fafa9f5bd5f5fc80696ca
4
+ data.tar.gz: d4ab05139da0cc924d211d1f1b48fe78126bf44d554f8fa43ec01c13d1025daf
5
5
  SHA512:
6
- metadata.gz: f4a888c0b801d677132b618d21719ab02e93a446f5e473c3dc1a2bdc70c539396155e50ea312e8fa5de21affd8e3b1ead8521a884aa697978cedd30c820206d3
7
- data.tar.gz: 6b7183ef9094d3f0c42ee80e34fd6f7d54a571a510431291d9025aa5b896bb0f98fbed5d262c0ab0fd53949b13c279baa7988af0159658fd8230b6dbe77f665d
6
+ metadata.gz: ed6e8917d9cb0cb98fc3f4d1be0ff82c15f7328b8dbd0fda51a156eb6ca9546dbb5af389321da9a3b16308fdc3870280c5dd48457344b90d09fb3ce177938e17
7
+ data.tar.gz: f9fe4bf529999d65acf13efaa4cea04410714cf6f122e2986b82c3eca6c9ad28dc8369b2cf937547e3e464a6bccf5544e90500b0e1528e16aad57ec6a111e929
@@ -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 ppct && ppct.type == :NAME
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
- <<~EOF
10
+ <<~CODE
11
11
  class { 'example2':
12
12
  param1 => 'value1',
13
13
  }
14
- EOF
14
+ CODE
15
15
  end
16
16
 
17
17
  context 'with fix disabled' do
18
- it 'should detect a single problem' do
18
+ it 'detects a single problem' do
19
19
  expect(problems).to have(1).problem
20
20
  end
21
21
 
22
- it 'should create a error' do
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 'should detect a single problem' do
36
+ it 'detects a single problem' do
37
37
  expect(problems).to have(1).problem
38
38
  end
39
39
 
40
- it 'should fix the manifest' do
40
+ it 'fixes the manifest' do
41
41
  expect(problems).to contain_fixed(single_space_msg)
42
42
  end
43
43
 
44
- it 'should fix the space' do
44
+ it 'fixes the space' do
45
45
  expect(manifest).to eq(
46
- <<~EOF,
46
+ <<~CODE,
47
47
  class { 'example2':
48
48
  param1 => 'value1',
49
49
  }
50
- EOF
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
- <<~EOF
58
+ <<~CODE
59
59
  class { 'example2':
60
60
  param1 =>'value1',
61
61
  }
62
- EOF
62
+ CODE
63
63
  end
64
64
 
65
65
  context 'with fix disabled' do
66
- it 'should detect a single problem' do
66
+ it 'detects a single problem' do
67
67
  expect(problems).to have(1).problem
68
68
  end
69
69
 
70
- it 'should create a error' do
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 'should detect a single problem' do
84
+ it 'detects a single problem' do
85
85
  expect(problems).to have(1).problem
86
86
  end
87
87
 
88
- it 'should fix the manifest' do
88
+ it 'fixes the manifest' do
89
89
  expect(problems).to contain_fixed(single_space_msg)
90
90
  end
91
91
 
92
- it 'should fix the space' do
92
+ it 'fixes the space' do
93
93
  expect(manifest).to eq(
94
- <<~EOF,
94
+ <<~CODE,
95
95
  class { 'example2':
96
96
  param1 => 'value1',
97
97
  }
98
- EOF
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
- <<~EOF
106
+ <<~CODE
107
107
  class { 'example2':
108
108
  param1 =>' ',
109
109
  }
110
- EOF
110
+ CODE
111
111
  end
112
112
 
113
113
  context 'with fix disabled' do
114
- it 'should detect a single problem' do
114
+ it 'detects a single problem' do
115
115
  expect(problems).to have(1).problem
116
116
  end
117
117
 
118
- it 'should create a error' do
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 'should detect a single problem' do
132
+ it 'detects a single problem' do
133
133
  expect(problems).to have(1).problem
134
134
  end
135
135
 
136
- it 'should fix the manifest' do
136
+ it 'fixes the manifest' do
137
137
  expect(problems).to contain_fixed(single_space_msg)
138
138
  end
139
139
 
140
- it 'should fix the space' do
140
+ it 'fixes the space' do
141
141
  expect(manifest).to eq(
142
- <<~EOF,
142
+ <<~CODE,
143
143
  class { 'example2':
144
144
  param1 => ' ',
145
145
  }
146
- EOF
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
- <<~EOF
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
- EOF
161
+ CODE
162
162
  end
163
163
 
164
164
  context 'with fix disabled' do
165
- it 'should detect a single problem' do
165
+ it 'detects a single problem' do
166
166
  expect(problems).to have(3).problems
167
167
  end
168
168
 
169
- it 'should create a error' do
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 'should detect a single problem' do
185
+ it 'detects a single problem' do
186
186
  expect(problems).to have(3).problem
187
187
  end
188
188
 
189
- it 'should fix the manifest' do
189
+ it 'fixes the manifest' do
190
190
  expect(problems).to contain_fixed(single_space_msg)
191
191
  end
192
192
 
193
- it 'should fix the space' do
193
+ it 'fixes the space' do
194
194
  expect(manifest).to eq(
195
- <<~EOF,
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
- EOF
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
- <<~EOF
211
+ <<~CODE
212
212
  class { 'example2':
213
213
  param1 => 'value1',
214
214
  }
215
- EOF
215
+ CODE
216
216
  end
217
217
 
218
- it 'should detect a no problem' do
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
- <<~EOF
225
+ <<~CODE
226
226
  "param1 => 'value1'",
227
- EOF
227
+ CODE
228
228
  end
229
229
 
230
- it 'should detect a no problem' do
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
- <<~EOF
237
+ <<~CODE
238
238
  $data = @("DATA"/L)
239
239
  param1 => 'value1',
240
240
  | DATA
241
- EOF
241
+ CODE
242
242
  end
243
243
 
244
- it 'should detect a no problem' do
244
+ it 'detects a no problem' do
245
245
  expect(problems).to be_empty
246
246
  end
247
247
  end