Skip to content

Commit 1576168

Browse files
committed
Protect against docstring or tags being nil
Previously, a NoMethodError could occur if either `signature['docstring']` or `signature['docstring']['tags']` returned nil. Now use ruby's dig and safenav operator.
1 parent 67d3f40 commit 1576168

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/puppet_references/puppet/functions_template.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Signature <%= index+1 %>
1313

1414
<% end -%>
1515
`<%= signature['signature'] %>`
16-
<% has_parameters = signature['docstring']['tags'].detect {|tag| tag['tag_name'] == 'param' && tag['text'] != '' && tag['text'] != nil }
16+
<% has_parameters = signature.dig('docstring', 'tags')&.detect {|tag| tag['tag_name'] == 'param' && tag['text'] != '' && tag['text'] != nil } || false
1717
if has_parameters -%>
1818

1919
### Parameters

0 commit comments

Comments
 (0)