Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to override ignore private apis #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nil and false evaluate to the same

Suggested change
check_private = PuppetLint.configuration.docs_check_private_params || false
check_private = PuppetLint.configuration.docs_check_private_params


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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruby uses && instead of and (same for || vs or)

Suggested change
unless is_private and not check_private
unless is_private && !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