puppet-lint-param-docs 1.0.0 → 1.0.1

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
  SHA1:
3
- metadata.gz: 5b51934ae6df0b664bc963b8366a37b7e6ec3a4f
4
- data.tar.gz: ad409a86b6778a747ea42cfa6ec1dc50172aba27
3
+ metadata.gz: 4bb4b94293827223c095b299cf276db411a10b2f
4
+ data.tar.gz: a7f61cd34c5d9488a002533c026d2dc9d2f3f7a3
5
5
  SHA512:
6
- metadata.gz: 07878556ff5e6f8a738115afa9b274561114624c29a85ccb48061f21a50531667fc7ab0e3dcc6c67167e30851a41a681dcc2344826d02d865de6d3b5ec4ce1c1
7
- data.tar.gz: c931d62386aa49bb75c57862c321d953b5e64823ebac846b48a9c088d5551a5eecd136c8fcda6dcd3a8fc64f769af8f545ccc30e3453a7cad90794bc9d41d67b
6
+ metadata.gz: f0c8fa5a5f48d0e5f2d7141b809a2ad01ab00de3eda336891955e6a0e4027579937bbd815ebf31daea5b587282b420518220167983a57c78dee53542dcb8e4d9
7
+ data.tar.gz: 4a78705dc8c8b0aab3be9ba1dff093afe117804a76a60c74db1c2352c730ffd1d0379b8c31d7d8e6f0d35202e479889537e006162b05b494915816d9e7596507
@@ -15,18 +15,18 @@ PuppetLint.new_check(:parameter_documentation) do
15
15
 
16
16
  params = []
17
17
  e = klass[:param_tokens].each
18
- e.each do |ptok|
19
- params << ptok if ptok.type == :VARIABLE
20
- # skip to the next parameter to avoid finding default values of variables
21
- begin
22
- while true
23
- ptok = e.next
24
- break if ptok == :COMMA
18
+ begin
19
+ while (ptok = e.next)
20
+ if ptok.type == :VARIABLE
21
+ params << ptok
22
+ # skip to the next parameter to avoid finding default values of variables
23
+ while true
24
+ ptok = e.next
25
+ break if ptok.type == :COMMA
26
+ end
25
27
  end
26
- rescue StopIteration
27
- break
28
28
  end
29
- end
29
+ rescue StopIteration; end
30
30
 
31
31
  params.each do |p|
32
32
  next if doc_params.include? p.value
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'parameter_documentation' do
4
- let(:msg) { 'missing documentation for class parameter example::foo' }
4
+ let(:msg) { 'missing documentation for class parameter example::%s' }
5
5
 
6
6
  context 'class missing any documentation' do
7
7
  let(:code) { 'class example($foo) { }' }
@@ -11,7 +11,7 @@ describe 'parameter_documentation' do
11
11
  end
12
12
 
13
13
  it 'should create a warning' do
14
- expect(problems).to contain_warning(msg).on_line(1).in_column(15)
14
+ expect(problems).to contain_warning(msg % :foo).on_line(1).in_column(15)
15
15
  end
16
16
  end
17
17
 
@@ -23,13 +23,30 @@ describe 'parameter_documentation' do
23
23
  end
24
24
 
25
25
  it 'should create a warning' do
26
- expect(problems).to contain_warning(msg).on_line(1).in_column(15)
26
+ expect(problems).to contain_warning(msg % :foo).on_line(1).in_column(15)
27
27
  end
28
28
  end
29
29
 
30
- context 'class missing documentation for a parameter' do
30
+ context 'class with many param defaults' do
31
31
  let(:code) do
32
32
  <<-EOS
33
+ class foreman (
34
+ $foreman_url = $foreman::params::foreman_url,
35
+ $unattended = $foreman::params::unattended,
36
+ $authentication = $foreman::params::authentication,
37
+ $passenger = $foreman::params::passenger,
38
+ ) {}
39
+ EOS
40
+ end
41
+
42
+ it 'should detect four problems' do
43
+ expect(problems).to have(4).problems
44
+ end
45
+ end
46
+
47
+ context 'class missing documentation for a parameter' do
48
+ let(:code) do
49
+ <<-EOS.gsub(/^\s+/, '')
33
50
  # Example class
34
51
  #
35
52
  # === Parameters:
@@ -45,8 +62,30 @@ describe 'parameter_documentation' do
45
62
  end
46
63
 
47
64
  it 'should create a warning' do
48
- # column looks wrong, maybe the parser's out
49
- expect(problems).to contain_warning(msg).on_line(7).in_column(21)
65
+ expect(problems).to contain_warning(msg % :foo).on_line(7).in_column(15)
66
+ end
67
+ end
68
+
69
+ context 'class missing documentation for a second parameter' do
70
+ let(:code) do
71
+ <<-EOS.gsub(/^\s+/, '')
72
+ # Example class
73
+ #
74
+ # === Parameters:
75
+ #
76
+ # $bar:: example
77
+ #
78
+ class example($foo, $bar, $baz) { }
79
+ EOS
80
+ end
81
+
82
+ it 'should detect two problem' do
83
+ expect(problems).to have(2).problems
84
+ end
85
+
86
+ it 'should create two warnings' do
87
+ expect(problems).to contain_warning(msg % :foo).on_line(7).in_column(15)
88
+ expect(problems).to contain_warning(msg % :baz).on_line(7).in_column(27)
50
89
  end
51
90
  end
52
91
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-param-docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Cleal