(PDOC-56) Fix type warning for defined types
Puppet defined types would print the string representation of the ruby object, and not representation you would see in puppet. This is the difference between `Puppet::Pops::Types::PStringType` and `String`.
This commit is contained in:
parent
5dd65d3b5e
commit
3151e4e1b1
|
@ -118,7 +118,7 @@ class TemplateHelper
|
||||||
function.keys.each do |key|
|
function.keys.each do |key|
|
||||||
if function[key].class == String
|
if function[key].class == String
|
||||||
begin
|
begin
|
||||||
instantiated = type_parser.parse function[key].gsub(/'/, '').gsub(/"/, "")
|
instantiated = type_parser.parse function[key]
|
||||||
rescue Puppet::ParseError
|
rescue Puppet::ParseError
|
||||||
# Likely the result of a malformed type
|
# Likely the result of a malformed type
|
||||||
next
|
next
|
||||||
|
@ -132,15 +132,15 @@ class TemplateHelper
|
||||||
param_instantiated = type_parser.parse type
|
param_instantiated = type_parser.parse type
|
||||||
if not type_calculator.assignable? instantiated, param_instantiated
|
if not type_calculator.assignable? instantiated, param_instantiated
|
||||||
actual_types = object.type_info.map do |sig|
|
actual_types = object.type_info.map do |sig|
|
||||||
sig[key]
|
sig[key].to_s if sig[key]
|
||||||
end
|
end.compact
|
||||||
# Get the locations where the object can be found. We only care about
|
# Get the locations where the object can be found. We only care about
|
||||||
# the first one.
|
# the first one.
|
||||||
locations = object.files
|
locations = object.files
|
||||||
warning = <<-EOS
|
warning = <<-EOS
|
||||||
[warn]: @param tag types do not match the code. The #{param[:name]}
|
[warn]: @param tag types do not match the code. The #{param[:name]}
|
||||||
parameter is declared as types #{param[:types]} in the docstring,
|
parameter is declared as types #{param[:types]} in the docstring,
|
||||||
but the code specifies the types #{actual_types.inspect}
|
but the code specifies the types #{actual_types}
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
# If the locations aren't in the shape we expect then report that
|
# If the locations aren't in the shape we expect then report that
|
||||||
|
|
|
@ -79,7 +79,7 @@ Puppet Types: 0 ( 0 undocumented)
|
||||||
Puppet Providers: 0 ( 0 undocumented)
|
Puppet Providers: 0 ( 0 undocumented)
|
||||||
100.00% documented
|
100.00% documented
|
||||||
output
|
output
|
||||||
expected_stderr = "[warn]: @param tag types do not match the code. The ident\n parameter is declared as types [\"Float\"] in the docstring,\n but the code specifies the types [Puppet::Pops::Types::PStringType]\n in the file manifests/init.pp near line 2.\n"
|
expected_stderr = "[warn]: @param tag types do not match the code. The ident\n parameter is declared as types [\"Float\"] in the docstring,\n but the code specifies the types [\"String\"]\n in the file manifests/init.pp near line 2.\n"
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
expect {
|
expect {
|
||||||
|
|
Loading…
Reference in New Issue