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

Fix return type matching for Puppet functions #159

Merged
merged 1 commit into from
Feb 25, 2018
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PuppetStrings::Yard::Handlers::Puppet::FunctionHandler < PuppetStrings::Ya
def add_return_tag(object, type=nil)
tag = object.tag(:return)
if tag
if (type && tag.types) && (type != tag.types)
if (type && tag.types.first) && (type != tag.types.first)
log.warn "Documented return type does not match return type in function definition near #{statement.file}:#{statement.line}."
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
let(:source) { 'function foo{' }

it 'should log an error' do
expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of file/).to_stdout_from_any_process
expect{ subject }.to output(/\[error\]: Failed to parse \(stdin\): Syntax error at end of/).to_stdout_from_any_process
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This slipped through since I was getting a different error message (at end of input instead of at end of file), hence a failing test.

This should cover both cases.

expect(subject.empty?).to eq(true)
end
end
Expand Down Expand Up @@ -216,6 +216,21 @@
end
end

describe 'parsing a function with a non-conflicting return tag and type in function definition', if: TEST_FUNCTION_RETURN_TYPE do
let(:source) { <<-SOURCE
# A simple foo function
# @return [String] Hi there
function foo() >> String {
notice 'hi there'
}
SOURCE
}

it 'should not output a warning if return types match' do
expect{ subject }.not_to output(/Documented return type does not match return type in function definition/).to_stdout_from_any_process
end
end

describe 'parsing a function with a conflicting return tag and type in function definition', if: TEST_FUNCTION_RETURN_TYPE do
let(:source) { <<-SOURCE
# A simple foo function.
Expand Down