VERSION
Version 0.52
DESCRIPTION
Analyses the return metadata of a schema's output section and produces stability and consistency scores along with a list of risk flags. This is used by App::Test::Generator to assess how reliably a function's return value can be tested.
new
Construct a new ReturnMeta analyser.
my $analyser = App::Test::Generator::Analyzer::ReturnMeta->new;
Arguments
None.
Returns
A blessed hashref.
API specification
input
{}
output
{
type => OBJECT,
isa => 'App::Test::Generator::Analyzer::ReturnMeta',
}
analyze
Analyse the output section of a schema hashref and return a scoring report covering stability, consistency, and risk flags.
my $analyser = App::Test::Generator::Analyzer::ReturnMeta->new;
my $report = $analyser->analyze($schema);
printf "Stability: %d\n", $report->{stability_score};
printf "Consistency: %d\n", $report->{consistency_score};
printf "Risks: %s\n", join(', ', @{ $report->{risk_flags} });
Arguments
$schemaA hashref that may include an
outputkey containing return metadata. Theoutputhashref may include any of the following keys:_context_aware- true if the function returns differently in list vs scalar context._returns_self- true if the function returns$self.type- the declared return type string e.g.object,boolean,string._error_handling- a hashref with boolean keysimplicit_undef,empty_list, andexception_handling._error_return- the value returned on error e.g.undef.
Returns
A hashref with three keys:
stability_score- integer in [0, 100]. Higher is more stable.consistency_score- integer in [0, 100]. Higher is more consistent.risk_flags- arrayref of string risk identifiers detected during analysis.
Notes
Both scores start at 100 and are reduced by penalties for each detected risk pattern. A small bonus is applied to stability for boolean return types, but since stability_score starts at 100 and is clamped to [0, 100] after all adjustments, this bonus is a no-op unless an earlier penalty has already reduced the score below 100 - for a boolean-returning function with no other detected risk, stability_score is unaffected by $BONUS_BOOLEAN_STABILITY and remains 100.
API specification
input
{
self => { type => OBJECT, isa => 'App::Test::Generator::Analyzer::ReturnMeta' },
schema => { type => HASHREF },
}
output
{
type => HASHREF,
keys => {
stability_score => { type => SCALAR },
consistency_score => { type => SCALAR },
risk_flags => { type => ARRAYREF },
},
}