Skip to content

Commit

Permalink
Add an option to override ignore private apis
Browse files Browse the repository at this point in the history
  • Loading branch information
vStone committed Feb 16, 2021
1 parent f4faeeb commit 89a8f96
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_ignore_private_api = false
```

### Selective rake task

The usual puppet-lint rake task checks all manifests, which isn't always
Expand Down
5 changes: 4 additions & 1 deletion lib/puppet-lint/plugins/check_parameter_documentation.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
PuppetLint.new_check(:parameter_documentation) do
def check

ignore_private = PuppetLint.configuration.docs_ignore_private_api.nil? ? true : PuppetLint.configuration.docs_ignore_private_api

class_indexes.concat(defined_type_indexes).each do |idx|
doc_params = {}
doc_params_duplicates = Hash.new { |hash, key| hash[key] = [doc_params[key]] }
Expand Down Expand Up @@ -50,7 +53,7 @@ def check
}
end

unless is_private
unless ignore_private and is_private
params.each do |p|
next if doc_params.has_key? p.value
notify :warning, {
Expand Down
33 changes: 29 additions & 4 deletions spec/puppet-lint/plugins/check_parameter_documentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,38 @@ class example($foo, $bar) { }
EOS
end

it 'should detect no single problems' do
expect(problems).to have(0).problems
context 'ignore 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 'ignore private_api disabled' do
before do
PuppetLint.configuration.docs_ignore_private_api = false
end

after do
PuppetLint.configuration.docs_ignore_private_api = true
end

it do
expect(PuppetLint.configuration.docs_ignore_private_api).to be(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
Expand Down

0 comments on commit 89a8f96

Please sign in to comment.