puppet-lint-manifest_whitespace-check 0.1.9 → 0.1.14

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: deec283a984c69934edd2522701fd6e840fb15e5ebbaf5d836366e59a6f7d894
4
- data.tar.gz: e4b9559d3d6f82ef25f362b1bcbf8d7e8268e2f54089398dfb22519f6529b289
3
+ metadata.gz: 5f942c3097eac960a4830626b7950525074c9c39ab1ff401d04e1256ebda861e
4
+ data.tar.gz: 9aa3c04aa40c1c0f5349044208b717c3c387de7321286c23b53bc3b31169d8c0
5
5
  SHA512:
6
- metadata.gz: 4a49d305962a6ea8168b6deb0f3ec7baf47276d7c6aa56c3869f16f73ed3ade68c3ff63acea7a5ebdef71cab5388b67b5d5cfc898d2f2f2daaa3bb9d7867a4a2
7
- data.tar.gz: 10217466afcdf5fcd832eb08a54d1031c1f88d417783bc77da4a035ee3dfa5cfacc020ee87bac0b030abe59d80f080f596ffa0c803cddaf73aa0f312a3ac7d1d
6
+ metadata.gz: adb52463b3cc9dee9f8291cf1ef24eb2ecb4e804ac381f7151d7d633bfe2d7c223d385da5ea21b0ceb75921d3d2241ce28a83672554edc74cfdb0b8ff11b1cb1
7
+ data.tar.gz: 3770c9176be5522c65f47d833a34e9430529b327980f0f237d2fa01dc2ddc3dbec0bb8f130110c1711d013e9db50d392c281bed38f351c53aec47e8a3e059977
@@ -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 bracket or a single newline before a closing brace',
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 RBRACE RBRACK NEWLINE INDENT].include?(next_token.prev_token.type)
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
@@ -73,7 +73,7 @@ PuppetLint.new_check(:manifest_whitespace_closing_brace_after) do
73
73
 
74
74
  notify(
75
75
  :error,
76
- message: 'there should be either a bracket, comma, colon, closing quote or a newline after a closing brace, or whitespace and none of the aforementioned',
76
+ message: 'there should be either a bracket, punctuation mark, closing quote or a newline after a closing brace, or whitespace and none of the aforementioned',
77
77
  line: next_token.line,
78
78
  column: next_token.column,
79
79
  token: next_token,
@@ -63,7 +63,7 @@ PuppetLint.new_check(:manifest_whitespace_closing_bracket_after) do
63
63
 
64
64
  notify(
65
65
  :error,
66
- message: 'there should be either a bracket, comma, colon, closing quote or a newline after a closing bracket, or whitespace and none of the aforementioned',
66
+ message: 'there should be either a bracket, punctuation mark, closing quote or a newline after a closing bracket, or whitespace and none of the aforementioned',
67
67
  line: next_token.line,
68
68
  column: next_token.column,
69
69
  token: next_token,
@@ -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[LBRACK LBRACE RBRACE].include?(next_token.type)
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
@@ -9,6 +9,9 @@ PuppetLint.new_check(:manifest_whitespace_opening_bracket_before) do
9
9
  next unless prev_token && prev_code_token
10
10
  next if %i[LBRACK LBRACE COMMA SEMIC].include?(prev_code_token.type)
11
11
  next unless %i[WHITESPACE NEWLINE INDENT].include?(prev_token.type)
12
+ if prev_token.type == :NEWLINE && %i[RBRACK RBRACE].include?(prev_code_token.type)
13
+ next
14
+ end
12
15
  next unless tokens.index(prev_code_token) != tokens.index(bracket_token) - 2 ||
13
16
  !is_single_space(prev_token)
14
17
 
@@ -9,7 +9,7 @@ def new_single_space
9
9
  end
10
10
 
11
11
  def after_bracket_tokens
12
- %i[RBRACE RBRACK RPAREN SEMIC COMMA COLON NEWLINE DQMID DQPOST LBRACK]
12
+ %i[RBRACK RPAREN SEMIC COMMA COLON DOT NEWLINE DQMID DQPOST LBRACK]
13
13
  end
14
14
 
15
15
  def prev_non_space_token(token)
@@ -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 bracket or a single newline before a closing brace' }
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
@@ -17,6 +47,22 @@ describe 'manifest_whitespace_closing_brace_before' do
17
47
  end
18
48
  end
19
49
 
50
+ context 'with iterator' do
51
+ let(:code) do
52
+ <<~EOF
53
+ ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
54
+ }
55
+
56
+ ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
57
+ }
58
+ EOF
59
+ end
60
+
61
+ it 'should detect no problems' do
62
+ expect(problems).to have(0).problem
63
+ end
64
+ end
65
+
20
66
  context 'with comment only' do
21
67
  let(:code) do
22
68
  <<~EOF
@@ -356,7 +402,20 @@ describe 'manifest_whitespace_closing_brace_before' do
356
402
  end
357
403
 
358
404
  describe 'manifest_whitespace_closing_brace_after' do
359
- let(:closing_brace_msg) { 'there should be either a bracket, comma, colon, closing quote or a newline after a closing brace, or whitespace and none of the aforementioned' }
405
+ let(:closing_brace_msg) { 'there should be either a bracket, punctuation mark, closing quote or a newline after a closing brace, or whitespace and none of the aforementioned' }
406
+
407
+ context 'with iterator' do
408
+ let(:code) do
409
+ <<~EOF
410
+ ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
411
+ }
412
+ EOF
413
+ end
414
+
415
+ it 'should detect no problems' do
416
+ expect(problems).to have(0).problem
417
+ end
418
+ end
360
419
 
361
420
  context 'with spaces' do
362
421
  let(:code) do
@@ -153,7 +153,35 @@ 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) { 'there should be either a bracket, comma, colon, closing quote or a newline after a closing bracket, or whitespace and none of the aforementioned' }
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
+
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
+
170
+ context 'with iterator' do
171
+ let(:code) do
172
+ <<~EOF
173
+ ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
174
+ }
175
+
176
+ ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
177
+ }
178
+ EOF
179
+ end
180
+
181
+ it 'should detect no problems' do
182
+ expect(problems).to have(0).problem
183
+ end
184
+ end
157
185
 
158
186
  context 'with spaces' do
159
187
  let(:code) do
@@ -203,12 +231,12 @@ describe 'manifest_whitespace_closing_bracket_after' do
203
231
  end
204
232
 
205
233
  context 'with fix disabled' do
206
- it 'should detect 3 problems' do
207
- expect(problems).to have(3).problem
234
+ it 'should detect 2 problems' do
235
+ expect(problems).to have(2).problem
208
236
  end
209
237
 
210
238
  it 'should create a error' do
211
- expect(problems).to contain_error(closing_bracket_msg).on_line(9).in_column(32)
239
+ expect(problems).to contain_error(closing_bracket_msg).on_line(23).in_column(22)
212
240
  end
213
241
  end
214
242
 
@@ -236,7 +264,7 @@ describe 'manifest_whitespace_closing_bracket_after' do
236
264
  class example (
237
265
  String $content,
238
266
  ) {
239
- $value = { 'key' => ['value']}
267
+ $value = { 'key' => ['value'] }
240
268
  $value2 = [
241
269
  {
242
270
  'key' => 'value1',
@@ -5,6 +5,22 @@ require 'spec_helper'
5
5
  describe 'manifest_whitespace_opening_bracket_before' do
6
6
  let(:opening_bracket_msg) { 'there should be a single space before an opening bracket' }
7
7
 
8
+ context 'with iterator' do
9
+ let(:code) do
10
+ <<~EOF
11
+ ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
12
+ }
13
+
14
+ ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
15
+ }
16
+ EOF
17
+ end
18
+
19
+ it 'should detect no problems' do
20
+ expect(problems).to have(0).problem
21
+ end
22
+ end
23
+
8
24
  context 'with no spaces' do
9
25
  let(:code) do
10
26
  <<~EOF
@@ -228,6 +244,22 @@ end
228
244
  describe 'manifest_whitespace_opening_bracket_after' do
229
245
  let(:opening_bracket_msg) { 'there should be no whitespace or a single newline after an opening bracket' }
230
246
 
247
+ context 'with iterator' do
248
+ let(:code) do
249
+ <<~EOF
250
+ ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
251
+ }
252
+
253
+ ['ib0', 'ib1', 'ib2', 'ib3', 'pub', 'oob', '0', '184'].each |String $name| {
254
+ }
255
+ EOF
256
+ end
257
+
258
+ it 'should detect no problems' do
259
+ expect(problems).to have(0).problem
260
+ end
261
+ end
262
+
231
263
  context 'with a single space' do
232
264
  let(:code) do
233
265
  <<~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.1.9
4
+ version: 0.1.14
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-25 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint