puppet-lint-manifest_whitespace-check 0.1.16 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af72a48c82a227107871c1e7b83a3bec2a101aab3cef89bbd3d6ce426122334d
4
- data.tar.gz: c7bc25b60155836000ec44971dd88832fafd413cac0e89107c49be5e86e804c1
3
+ metadata.gz: 242cfac889870bbdd8d1346f1adafb8348b868945e9cfbe9adebebf6c4468c59
4
+ data.tar.gz: 0fd2197f54e3f911e077d3315458a0e2c44e69230570757cf26a7fc26db0d89e
5
5
  SHA512:
6
- metadata.gz: 24961bb90cab1231db45ad634bf31444a276645d371401168956a436dd977e23166b19d5b1880e96d8ebfc64c3c53da68c4a65e92643a421094fae5a693ec2f0
7
- data.tar.gz: c57d69810e67d335b597cb8257d627a07ac6c31fde14e37f64b8c05e4bb83fc750ca9e87699689211f299268ca287e89d76835259667d6b0876c3ed94f40b04e
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: next_token.line,
47
- column: next_token.column,
48
- token: next_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
- while token != next_code_token
58
- remove_token(token)
59
- token = token.next_token
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)
@@ -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(14)
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(24)
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(14)
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(14)
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(14)
375
+ expect(problems).to contain_error(single_space_msg).on_line(6).in_column(7)
376
376
  end
377
377
  end
378
378
 
@@ -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
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.16
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-26 00:00:00.000000000 Z
11
+ date: 2020-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint