NAME

Test::CPAN::Health::Result - Outcome of a single health check

SYNOPSIS

use Test::CPAN::Health::Result;

my $result = Test::CPAN::Health::Result->new(
    check_id => 'sem_ver',
    status   => 'pass',
    score    => 100,
    summary  => 'Version 1.2.3 follows semantic versioning',
);

print $result->status;           # 'pass'
print $result->score;            # 100
print $result->is_pass ? 'ok' : 'not ok';

DESCRIPTION

Encapsulates the outcome of one Test::CPAN::Health::Check run. Each Result carries a status (pass/warn/fail/skip/error), an optional 0-100 score used in the weighted overall calculation, a human-readable summary, an optional list of detail strings, an optional URL pointing to external evidence, and an optional raw data hashref for machine-readable reporters.

LIMITATIONS

  • score is not validated to the range 0..100 at construction time; enforcement is the caller's responsibility.

check_id

PURPOSE

Returns the stable string identifier of the check that produced this result.

API SPECIFICATION

INPUT

None.

OUTPUT

Scalar string.

MESSAGES

Code  | Severity | Message                            | Resolution
------+----------+------------------------------------+---------------------
      |          |                                    |

FORMAL SPECIFICATION

-- Z schema (placeholder) --
check_id : String
-------------------------------------------------------
check_id /= ""

SIDE EFFECTS

None.

USAGE EXAMPLE

print $result->check_id;    # 'sem_ver'

status

PURPOSE

Returns the pass/warn/fail/skip/error status string.

API SPECIFICATION

INPUT

None.

OUTPUT

One of: pass, warn, fail, skip, error.

MESSAGES

Code  | Severity | Message                            | Resolution
------+----------+------------------------------------+---------------------
      |          |                                    |

FORMAL SPECIFICATION

-- Z schema (placeholder) --
status : {pass, warn, fail, skip, error}

SIDE EFFECTS

None.

USAGE EXAMPLE

print $result->status;    # 'fail'

as_hash

PURPOSE

Serialise the Result to a plain hashref, suitable for JSON encoding or passing between processes.

API SPECIFICATION

INPUT

None.

OUTPUT

Hashref with keys: check_id, status, score, summary, details, url, data.

MESSAGES

Code  | Severity | Message                            | Resolution
------+----------+------------------------------------+---------------------
      |          |                                    |

FORMAL SPECIFICATION

-- Z schema (placeholder) --
AsHashOp
result  : Result
output  : Hashref
-------------------------------------------------------
dom(output) = {check_id, status, score, summary, details, url, data}

SIDE EFFECTS

None.

USAGE EXAMPLE

my $href = $result->as_hash;
my $json = encode_json($href);

AUTHOR

Nigel Horne, <njh at nigelhorne.com>

LICENSE AND COPYRIGHT

Copyright (C) 2025-2026 Nigel Horne.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.