diff --git a/README.md b/README.md index 81cb66d..ce8478d 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,15 @@ rdoc style. class example($foo) { } ``` +### Private api + +The check will ignore missing documentation for private apis by default. +To disable this behaviour and check private apis, use the following configuration: + +```ruby +PuppetLint.configuration.docs_check_private_params = true +``` + ### Selective rake task The usual puppet-lint rake task checks all manifests, which isn't always diff --git a/lib/puppet-lint/plugins/check_parameter_documentation.rb b/lib/puppet-lint/plugins/check_parameter_documentation.rb index 052b353..6d48571 100644 --- a/lib/puppet-lint/plugins/check_parameter_documentation.rb +++ b/lib/puppet-lint/plugins/check_parameter_documentation.rb @@ -1,5 +1,7 @@ PuppetLint.new_check(:parameter_documentation) do def check + check_private = PuppetLint.configuration.docs_check_private_params || false + class_indexes.concat(defined_type_indexes).each do |idx| doc_params = {} doc_params_duplicates = Hash.new { |hash, key| hash[key] = [doc_params[key]] } @@ -50,7 +52,7 @@ def check } end - unless is_private + unless is_private and not check_private params.each do |p| next if doc_params.has_key? p.value notify :warning, { diff --git a/spec/puppet-lint/plugins/check_parameter_documentation_spec.rb b/spec/puppet-lint/plugins/check_parameter_documentation_spec.rb index 0d5eda2..ed628d4 100644 --- a/spec/puppet-lint/plugins/check_parameter_documentation_spec.rb +++ b/spec/puppet-lint/plugins/check_parameter_documentation_spec.rb @@ -173,13 +173,34 @@ class example($foo, $bar) { } EOS end - it 'should detect no single problems' do - expect(problems).to have(0).problems + context 'check private api disabled (default)' do + it 'should detect no single problems' do + expect(problems).to have(0).problems + end + + it 'should not create a warning' do + expect(problems).not_to contain_info(class_msg % :foo) + end end - it 'should not create a warning' do - expect(problems).not_to contain_info(class_msg % :foo) + context 'check private api enabled' do + before do + PuppetLint.configuration.docs_check_private_params = true + end + + after do + PuppetLint.configuration.docs_check_private_params = false + end + + it 'should detect a single problems' do + expect(problems).to have(1).problem + end + + it 'should create a warning' do + expect(problems).to contain_warning(class_msg % :foo).on_line(6).in_column(15) + end end + end context 'define missing documentation (@param bar) for a parameter' do