VERSION

Version 0.34

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

  • $schema

    A hashref with an optional output key containing return metadata. The output hashref 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 keys implicit_undef, empty_list, and exception_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. All scores are clamped to [0, 100] after adjustments.

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 },
    },
}

1 POD Error

The following errors were encountered while parsing the POD:

Around line 89:

Non-ASCII character seen before =encoding in '—'. Assuming UTF-8