puppet-lint-resource_reference_syntax 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a1588999aeae6a48e3b9a1d9ecff0d2078fc68c
4
- data.tar.gz: 5328ef32b72821db7ce423b29eb5f0d1f2fb1717
3
+ metadata.gz: 6444407fc868020ca8c63c1cc06bfeee0735f1e6
4
+ data.tar.gz: 6559535d01dfde23af4c912e969c3d8bad2421e7
5
5
  SHA512:
6
- metadata.gz: 14feff85da89a1df849a813393f38f44c90497381adc4d1ac17d604467f14a7476ec16095557fecb5836fdf464fe33e267b859d89b174f79afabb10ccda56595
7
- data.tar.gz: e60e57b9da69171a16167df1e4ae371787516f3c19457d31c2cea9f43d7fe081f188742ef293fec0df7a14cd9d4ed4ed648ed0146a642f41dbb78c37670a2ba6
6
+ metadata.gz: e25f233604d1f3870dcc7dfd3b34369e42e677d03ba153fc3e0ecbde4dff6c13a34481f137fee2a9e4687a315eb7af2e0387fb1a869c6d3af674719964a3ebc3
7
+ data.tar.gz: 65941825a27dae57fd9275c4dc0015c299a90cba98e01d922de705e512864321cddcd2b93ab0684367bf975ed2c27c68eb01df2b3b783e145fa6beeb5118b330
@@ -4,13 +4,26 @@ PuppetLint.new_check(:resource_reference_without_whitespace) do
4
4
  resource[:param_tokens].select { |param_token|
5
5
  ['require', 'subscribe', 'notify', 'before', 'consume', 'export'].include? param_token.value
6
6
  }.each do |param_token|
7
- value_token = param_token.next_code_token.next_code_token.next_token
8
- if value_token.type != :LBRACK
9
- notify :error, {
10
- :message => 'whitespce between reference type and title',
11
- :line => param_token.next_code_token.next_code_token.line,
12
- :column => param_token.next_code_token.next_code_token.column
13
- }
7
+ value_token = param_token.next_code_token
8
+ check = value_token.next_token
9
+ until check.nil?
10
+ case value_token.next_token.type
11
+ when :CLASSREF
12
+ begin
13
+ if value_token.next_token.next_token.type == :WHITESPACE
14
+ notify :error, {
15
+ :message => 'whitespce between reference type and title',
16
+ :line => param_token.next_code_token.next_code_token.line,
17
+ :column => param_token.next_code_token.next_code_token.column
18
+ }
19
+ end
20
+ value_token = value_token.next_token
21
+ check = value_token.next_token
22
+ end
23
+ else
24
+ value_token = value_token.next_token
25
+ check = value_token.next_token
26
+ end
14
27
  end
15
28
  end
16
29
  end
@@ -35,6 +35,14 @@ describe 'resource_reference_without_title_capital' do
35
35
  end
36
36
  end
37
37
 
38
+ context 'multiple proper references as array one in quotes, one as variable' do
39
+ let(:code) { "file { 'foo': ensure => file, notify => [ Title['one'], Title[$foo_var] ],}" }
40
+
41
+ it 'should detect no problem' do
42
+ expect(problems).to have(0).problem
43
+ end
44
+ end
45
+
38
46
  context 'a proper reference as variable' do
39
47
  let(:code) { "file { 'foo': ensure => file, notify => Title[$foo_var],}" }
40
48
 
@@ -2,6 +2,24 @@ require 'spec_helper'
2
2
 
3
3
  describe 'resource_reference_without_whitespace' do
4
4
 
5
+ context 'a proper reference as array' do
6
+ let(:msg) { 'whitespce between reference type and title' }
7
+ let(:code) { "file { 'foo': ensure => file, notify => [ Title['one'], Title['two'] ]}" }
8
+
9
+ it 'should detect no problem' do
10
+ expect(problems).to have(0).problem
11
+ end
12
+ end
13
+
14
+ context 'a proper reference as array one fix, one variable' do
15
+ let(:msg) { 'whitespce between reference type and title' }
16
+ let(:code) { "file { 'foo': ensure => file, notify => [ Title['one'], Title[$two] ]}" }
17
+
18
+ it 'should detect no problem' do
19
+ expect(problems).to have(0).problem
20
+ end
21
+ end
22
+
5
23
  context 'a proper reference' do
6
24
  let(:msg) { 'whitespce between reference type and title' }
7
25
  let(:code) { "file { 'foo': ensure => file, notify => Title['one'],}" }
@@ -24,4 +42,17 @@ describe 'resource_reference_without_whitespace' do
24
42
  end
25
43
  end
26
44
 
45
+ context 'a whitespace between reference and bracket inside an array' do
46
+ let(:msg) { 'whitespce between reference type and title' }
47
+ let(:code) { "file { 'foo': ensure => file, consume => [ Title ['one'], Title['two']],}" }
48
+
49
+ it 'should only detect a single problem' do
50
+ expect(problems).to have(1).problem
51
+ end
52
+
53
+ it 'should create an error' do
54
+ expect(problems).to contain_error(msg).on_line(1)
55
+ end
56
+ end
57
+
27
58
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-resource_reference_syntax
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Alfke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-31 00:00:00.000000000 Z
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint