puppet-lint-param-docs 1.1.0 → 1.2.0
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: ac9245ad58468d4c5d12ad908c1be44b419fbd6e
|
4
|
+
data.tar.gz: cebcc59f5a6d1600ba3ef2820f79d96309a8ff6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e3d0109f4e5223651116dbe771034ee026584b1a4d4c411bd2e16087f152326510f68bd1880e8e022f217bd54663d4ab107ed7446276bc833ce98e34b0df2e6
|
7
|
+
data.tar.gz: 4407de443fdff750b3b4049e5561d367f201e5a0d348baafdeeec10a416d42f6a68cf4d570893641d83865232edb8d76abb932794a77389ccef53b70c294c357
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# puppet-lint parameter documentation check
|
2
2
|
|
3
|
-
Adds a new puppet-lint check to verify all class
|
4
|
-
documented.
|
3
|
+
Adds a new puppet-lint check to verify all class and defined type parameters
|
4
|
+
have been documented.
|
5
5
|
|
6
6
|
Particularly useful with [kafo](https://github.com/theforeman/kafo), as its
|
7
7
|
default behaviour is to throw an error when a parameter is undocumented.
|
@@ -23,9 +23,10 @@ This plugin provides a new check to `puppet-lint`.
|
|
23
23
|
|
24
24
|
**--fix support: No**
|
25
25
|
|
26
|
-
This check will raise a warning for any class
|
27
|
-
RDoc description.
|
26
|
+
This check will raise a warning for any class or defined type parameters that
|
27
|
+
don't have an RDoc description.
|
28
28
|
|
29
29
|
```
|
30
30
|
WARNING: missing documentation for class parameter foo::bar
|
31
|
+
WARNING: missing documentation for defined type parameter foo::baz
|
31
32
|
```
|
@@ -1,11 +1,11 @@
|
|
1
1
|
PuppetLint.new_check(:parameter_documentation) do
|
2
2
|
def check
|
3
|
-
class_indexes.each do |
|
4
|
-
next if
|
3
|
+
class_indexes.concat(defined_type_indexes).each do |idx|
|
4
|
+
next if idx[:param_tokens].nil?
|
5
5
|
|
6
6
|
doc_params = []
|
7
|
-
tokens[0..
|
8
|
-
next if [:CLASS, :NEWLINE, :WHITESPACE, :INDENT].include?(dtok.type)
|
7
|
+
tokens[0..idx[:start]].reverse_each do |dtok|
|
8
|
+
next if [:CLASS, :DEFINE, :NEWLINE, :WHITESPACE, :INDENT].include?(dtok.type)
|
9
9
|
if [:COMMENT, :MLCOMMENT, :SLASH_COMMENT].include?(dtok.type)
|
10
10
|
if dtok.value =~ /\A\s*\[\*([a-zA-Z0-9_]+)\*\]/ or
|
11
11
|
dtok.value =~ /\A\s*\$([a-zA-Z0-9_]+)::/
|
@@ -17,7 +17,7 @@ PuppetLint.new_check(:parameter_documentation) do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
params = []
|
20
|
-
e =
|
20
|
+
e = idx[:param_tokens].each
|
21
21
|
begin
|
22
22
|
while (ptok = e.next)
|
23
23
|
if ptok.type == :VARIABLE
|
@@ -33,8 +33,9 @@ PuppetLint.new_check(:parameter_documentation) do
|
|
33
33
|
|
34
34
|
params.each do |p|
|
35
35
|
next if doc_params.include? p.value
|
36
|
+
idx_type = idx[:type] == :CLASS ? "class" : "defined type"
|
36
37
|
notify :warning, {
|
37
|
-
:message => "missing documentation for
|
38
|
+
:message => "missing documentation for #{idx_type} parameter #{idx[:name_token].value}::#{p.value}",
|
38
39
|
:line => p.line,
|
39
40
|
:column => p.column,
|
40
41
|
}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'parameter_documentation' do
|
4
|
-
let(:
|
4
|
+
let(:class_msg) { 'missing documentation for class parameter example::%s' }
|
5
|
+
let(:define_msg) { 'missing documentation for defined type parameter example::%s' }
|
5
6
|
|
6
7
|
context 'class missing any documentation' do
|
7
8
|
let(:code) { 'class example($foo) { }' }
|
@@ -11,7 +12,19 @@ describe 'parameter_documentation' do
|
|
11
12
|
end
|
12
13
|
|
13
14
|
it 'should create a warning' do
|
14
|
-
expect(problems).to contain_warning(
|
15
|
+
expect(problems).to contain_warning(class_msg % :foo).on_line(1).in_column(15)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'define missing any documentation' do
|
20
|
+
let(:code) { 'define example($foo) { }' }
|
21
|
+
|
22
|
+
it 'should detect a single problem' do
|
23
|
+
expect(problems).to have(1).problem
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should create a warning' do
|
27
|
+
expect(problems).to contain_warning(define_msg% :foo).on_line(1).in_column(16)
|
15
28
|
end
|
16
29
|
end
|
17
30
|
|
@@ -23,7 +36,19 @@ describe 'parameter_documentation' do
|
|
23
36
|
end
|
24
37
|
|
25
38
|
it 'should create a warning' do
|
26
|
-
expect(problems).to contain_warning(
|
39
|
+
expect(problems).to contain_warning(class_msg % :foo).on_line(1).in_column(15)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'define with param defaults' do
|
44
|
+
let(:code) { 'define example($foo = $example::params::foo) { }' }
|
45
|
+
|
46
|
+
it 'should detect a single problem' do
|
47
|
+
expect(problems).to have(1).problem
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should create a warning' do
|
51
|
+
expect(problems).to contain_warning(define_msg % :foo).on_line(1).in_column(16)
|
27
52
|
end
|
28
53
|
end
|
29
54
|
|
@@ -44,6 +69,23 @@ class foreman (
|
|
44
69
|
end
|
45
70
|
end
|
46
71
|
|
72
|
+
context 'define with many param defaults' do
|
73
|
+
let(:code) do
|
74
|
+
<<-EOS
|
75
|
+
define foreman (
|
76
|
+
$foreman_url = $foreman::params::foreman_url,
|
77
|
+
$unattended = $foreman::params::unattended,
|
78
|
+
$authentication = $foreman::params::authentication,
|
79
|
+
$passenger = $foreman::params::passenger,
|
80
|
+
) {}
|
81
|
+
EOS
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should detect four problems' do
|
85
|
+
expect(problems).to have(4).problems
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
47
89
|
context 'class missing documentation ($bar::) for a parameter' do
|
48
90
|
let(:code) do
|
49
91
|
<<-EOS.gsub(/^\s+/, '')
|
@@ -62,7 +104,29 @@ class foreman (
|
|
62
104
|
end
|
63
105
|
|
64
106
|
it 'should create a warning' do
|
65
|
-
expect(problems).to contain_warning(
|
107
|
+
expect(problems).to contain_warning(class_msg % :foo).on_line(7).in_column(15)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'define missing documentation ($bar::) for a parameter' do
|
112
|
+
let(:code) do
|
113
|
+
<<-EOS.gsub(/^\s+/, '')
|
114
|
+
# Example define
|
115
|
+
#
|
116
|
+
# === Parameters:
|
117
|
+
#
|
118
|
+
# $bar:: example
|
119
|
+
#
|
120
|
+
define example($foo, $bar) { }
|
121
|
+
EOS
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should detect a single problem' do
|
125
|
+
expect(problems).to have(1).problem
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should create a warning' do
|
129
|
+
expect(problems).to contain_warning(define_msg % :foo).on_line(7).in_column(16)
|
66
130
|
end
|
67
131
|
end
|
68
132
|
|
@@ -84,7 +148,29 @@ class foreman (
|
|
84
148
|
end
|
85
149
|
|
86
150
|
it 'should create a warning' do
|
87
|
-
expect(problems).to contain_warning(
|
151
|
+
expect(problems).to contain_warning(class_msg % :foo).on_line(7).in_column(15)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'define missing documentation ([*bar*]) for a parameter' do
|
156
|
+
let(:code) do
|
157
|
+
<<-EOS.gsub(/^\s+/, '')
|
158
|
+
# Example define
|
159
|
+
#
|
160
|
+
# === Parameters:
|
161
|
+
#
|
162
|
+
# [*bar*] example
|
163
|
+
#
|
164
|
+
define example($foo, $bar) { }
|
165
|
+
EOS
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should detect a single problem' do
|
169
|
+
expect(problems).to have(1).problem
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'should create a warning' do
|
173
|
+
expect(problems).to contain_warning(define_msg % :foo).on_line(7).in_column(16)
|
88
174
|
end
|
89
175
|
end
|
90
176
|
|
@@ -106,8 +192,31 @@ class foreman (
|
|
106
192
|
end
|
107
193
|
|
108
194
|
it 'should create two warnings' do
|
109
|
-
expect(problems).to contain_warning(
|
110
|
-
expect(problems).to contain_warning(
|
195
|
+
expect(problems).to contain_warning(class_msg % :foo).on_line(7).in_column(15)
|
196
|
+
expect(problems).to contain_warning(class_msg % :baz).on_line(7).in_column(27)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
context 'define missing documentation ($bar::) for a second parameter' do
|
201
|
+
let(:code) do
|
202
|
+
<<-EOS.gsub(/^\s+/, '')
|
203
|
+
# Example define
|
204
|
+
#
|
205
|
+
# === Parameters:
|
206
|
+
#
|
207
|
+
# $bar:: example
|
208
|
+
#
|
209
|
+
define example($foo, $bar, $baz) { }
|
210
|
+
EOS
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should detect two problem' do
|
214
|
+
expect(problems).to have(2).problems
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'should create two warnings' do
|
218
|
+
expect(problems).to contain_warning(define_msg % :foo).on_line(7).in_column(16)
|
219
|
+
expect(problems).to contain_warning(define_msg % :baz).on_line(7).in_column(28)
|
111
220
|
end
|
112
221
|
end
|
113
222
|
|
@@ -129,8 +238,31 @@ class foreman (
|
|
129
238
|
end
|
130
239
|
|
131
240
|
it 'should create two warnings' do
|
132
|
-
expect(problems).to contain_warning(
|
133
|
-
expect(problems).to contain_warning(
|
241
|
+
expect(problems).to contain_warning(class_msg % :foo).on_line(7).in_column(15)
|
242
|
+
expect(problems).to contain_warning(class_msg % :baz).on_line(7).in_column(27)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
context 'define missing documentation ([*bar*]) for a second parameter' do
|
247
|
+
let(:code) do
|
248
|
+
<<-EOS.gsub(/^\s+/, '')
|
249
|
+
# Example define
|
250
|
+
#
|
251
|
+
# === Parameters:
|
252
|
+
#
|
253
|
+
# [*bar*] example
|
254
|
+
#
|
255
|
+
define example($foo, $bar, $baz) { }
|
256
|
+
EOS
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'should detect two problem' do
|
260
|
+
expect(problems).to have(2).problems
|
261
|
+
end
|
262
|
+
|
263
|
+
it 'should create two warnings' do
|
264
|
+
expect(problems).to contain_warning(define_msg % :foo).on_line(7).in_column(16)
|
265
|
+
expect(problems).to contain_warning(define_msg % :baz).on_line(7).in_column(28)
|
134
266
|
end
|
135
267
|
end
|
136
268
|
|
@@ -152,6 +284,24 @@ class foreman (
|
|
152
284
|
end
|
153
285
|
end
|
154
286
|
|
287
|
+
context 'define with all parameters documented ($foo::)' do
|
288
|
+
let(:code) do
|
289
|
+
<<-EOS
|
290
|
+
# Example define
|
291
|
+
#
|
292
|
+
# === Parameters:
|
293
|
+
#
|
294
|
+
# $foo:: example
|
295
|
+
#
|
296
|
+
define example($foo) { }
|
297
|
+
EOS
|
298
|
+
end
|
299
|
+
|
300
|
+
it 'should not detect any problems' do
|
301
|
+
expect(problems).to have(0).problems
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
155
305
|
context 'class with all parameters documented ([*foo*])' do
|
156
306
|
let(:code) do
|
157
307
|
<<-EOS
|
@@ -170,6 +320,24 @@ class foreman (
|
|
170
320
|
end
|
171
321
|
end
|
172
322
|
|
323
|
+
context 'define with all parameters documented ([*foo*])' do
|
324
|
+
let(:code) do
|
325
|
+
<<-EOS
|
326
|
+
# Example define
|
327
|
+
#
|
328
|
+
# === Parameters:
|
329
|
+
#
|
330
|
+
# [*foo*] example
|
331
|
+
#
|
332
|
+
define example($foo) { }
|
333
|
+
EOS
|
334
|
+
end
|
335
|
+
|
336
|
+
it 'should not detect any problems' do
|
337
|
+
expect(problems).to have(0).problems
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
173
341
|
context 'class without parameters' do
|
174
342
|
let(:code) { 'class example { }' }
|
175
343
|
|
@@ -178,6 +346,14 @@ class foreman (
|
|
178
346
|
end
|
179
347
|
end
|
180
348
|
|
349
|
+
context 'define without parameters' do
|
350
|
+
let(:code) { 'define example { }' }
|
351
|
+
|
352
|
+
it 'should not detect any problems' do
|
353
|
+
expect(problems).to have(0).problems
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
181
357
|
context 'class without parameters and a function call' do
|
182
358
|
let(:code) { 'class example { a($foo::bar) }' }
|
183
359
|
|
@@ -185,4 +361,12 @@ class foreman (
|
|
185
361
|
expect(problems).to have(0).problems
|
186
362
|
end
|
187
363
|
end
|
364
|
+
|
365
|
+
context 'define without parameters and a function call' do
|
366
|
+
let(:code) { 'define example { a($foo::bar) }' }
|
367
|
+
|
368
|
+
it 'should not detect any problems' do
|
369
|
+
expect(problems).to have(0).problems
|
370
|
+
end
|
371
|
+
end
|
188
372
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint-param-docs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominic Cleal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet-lint
|
@@ -81,8 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: |2
|
84
|
-
A new check for puppet-lint that validates all
|
85
|
-
documented.
|
84
|
+
A new check for puppet-lint that validates all parameters are documented.
|
86
85
|
email: dcleal@redhat.com
|
87
86
|
executables: []
|
88
87
|
extensions: []
|
@@ -113,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
112
|
version: '0'
|
114
113
|
requirements: []
|
115
114
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.4.4
|
117
116
|
signing_key:
|
118
117
|
specification_version: 4
|
119
118
|
summary: puppet-lint check to validate all parameters are documented
|