puppet-lint-param-docs 1.0.0 → 1.0.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bb4b94293827223c095b299cf276db411a10b2f
|
4
|
+
data.tar.gz: a7f61cd34c5d9488a002533c026d2dc9d2f3f7a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
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
|
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
|
-
|
49
|
-
|
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
|
|