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 cb3a376
Show file tree
Hide file tree
Showing 3 changed files with 37 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_check_private_params = true
```

### Selective rake task

The usual puppet-lint rake task checks all manifests, which isn't always
Expand Down
4 changes: 3 additions & 1 deletion lib/puppet-lint/plugins/check_parameter_documentation.rb
Original file line number Diff line number Diff line change
@@ -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]] }
Expand Down Expand Up @@ -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, {
Expand Down
29 changes: 25 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,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
Expand Down

0 comments on commit cb3a376

Please sign in to comment.