Skip to content

Commit cb3a376

Browse files
committed
Add an option to override ignore private apis
1 parent f4faeeb commit cb3a376

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ rdoc style.
8989
class example($foo) { }
9090
```
9191

92+
### Private api
93+
94+
The check will ignore missing documentation for private apis by default.
95+
To disable this behaviour and check private apis, use the following configuration:
96+
97+
```ruby
98+
PuppetLint.configuration.docs_check_private_params = true
99+
```
100+
92101
### Selective rake task
93102

94103
The usual puppet-lint rake task checks all manifests, which isn't always

lib/puppet-lint/plugins/check_parameter_documentation.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
PuppetLint.new_check(:parameter_documentation) do
22
def check
3+
check_private = PuppetLint.configuration.docs_check_private_params || false
4+
35
class_indexes.concat(defined_type_indexes).each do |idx|
46
doc_params = {}
57
doc_params_duplicates = Hash.new { |hash, key| hash[key] = [doc_params[key]] }
@@ -50,7 +52,7 @@ def check
5052
}
5153
end
5254

53-
unless is_private
55+
unless is_private and not check_private
5456
params.each do |p|
5557
next if doc_params.has_key? p.value
5658
notify :warning, {

spec/puppet-lint/plugins/check_parameter_documentation_spec.rb

+25-4
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,34 @@ class example($foo, $bar) { }
173173
EOS
174174
end
175175

176-
it 'should detect no single problems' do
177-
expect(problems).to have(0).problems
176+
context 'check private api disabled (default)' do
177+
it 'should detect no single problems' do
178+
expect(problems).to have(0).problems
179+
end
180+
181+
it 'should not create a warning' do
182+
expect(problems).not_to contain_info(class_msg % :foo)
183+
end
178184
end
179185

180-
it 'should not create a warning' do
181-
expect(problems).not_to contain_info(class_msg % :foo)
186+
context 'check private api enabled' do
187+
before do
188+
PuppetLint.configuration.docs_check_private_params = true
189+
end
190+
191+
after do
192+
PuppetLint.configuration.docs_check_private_params = false
193+
end
194+
195+
it 'should detect a single problems' do
196+
expect(problems).to have(1).problem
197+
end
198+
199+
it 'should create a warning' do
200+
expect(problems).to contain_warning(class_msg % :foo).on_line(6).in_column(15)
201+
end
182202
end
203+
183204
end
184205

185206
context 'define missing documentation (@param bar) for a parameter' do

0 commit comments

Comments
 (0)