NAME

Test::CPAN::Health::Config - Read per-project configuration for cpan-health

SYNOPSIS

use Test::CPAN::Health::Config;

my $cfg = Test::CPAN::Health::Config->new(path => '/path/to/dist');

# Returns the merged configuration (file values override defaults)
my %opts = $cfg->as_hash;

# Individual accessors
print $cfg->min_score;                     # integer or undef
print join(', ', @{ $cfg->skip });         # arrayref
print join(', ', @{ $cfg->ignore_abandoned }); # arrayref

DESCRIPTION

Reads an optional .cpan-health.ini (or cpan-health.conf) file from a distribution's root directory. The file uses a simple key = value format; comma-separated values are supported for list options.

If no configuration file is found, all accessors return undef (scalars) or [] (lists), and the caller falls back to its own defaults.

Supported options:

no_network       = 0|1
no_cover         = 0|1
min_score        = 0..100
severity         = 1..5
skip             = check_id1, check_id2, ...
ignore_abandoned = Module::Name1, Module::Name2, ...

LIMITATIONS

  • Sections ([section]) are not supported; all keys live at the top level.

  • Unknown keys produce a carp warning and are ignored.

  • Only the first matching config file in the preference order is read.

new

PURPOSE

Construct a Config object, locating and parsing any config file found under the given distribution path.

API SPECIFICATION

INPUT

path  string  required  Absolute path to the distribution root

OUTPUT

Blessed Config object.

MESSAGES

Code  | Severity | Message                         | Resolution
------+----------+---------------------------------+--------------
CFG01 | WARNING  | Unknown config key '<key>'      | Remove the key
CFG02 | WARNING  | Config parse error in <file>    | Fix the file syntax

FORMAL SPECIFICATION

Pre:  path is a readable directory
Post: self._data contains merged key/value from file (or empty if no file)

SIDE EFFECTS

Reads at most one file from disk.

USAGE EXAMPLE

my $cfg = Test::CPAN::Health::Config->new(path => $dist->path);
my $min = $cfg->min_score // 0;

as_hash

PURPOSE

Return all parsed configuration options as a flat hash. Suitable for merging with CLI-supplied options.

API SPECIFICATION

INPUT

None.

OUTPUT

Hash with keys: no_network, no_cover, min_score, severity, skip (arrayref), ignore_abandoned (arrayref). Only keys that were explicitly set in the config file are present.

MESSAGES

(none)

FORMAL SPECIFICATION

Post: result is a hashref subset of (SCALAR_KEYS union LIST_KEYS)

SIDE EFFECTS

None.

USAGE EXAMPLE

my %cfg = $config->as_hash;
my $effective_min = $cfg{min_score} // $cli_min_score // 0;

file

Returns the path of the config file that was loaded, or undef if none was found.

no_network

Returns the no_network setting or undef.

no_cover

Returns the no_cover setting or undef.

min_score

Returns the min_score setting or undef.

severity

Returns the severity setting or undef.

skip

Returns the skip arrayref or [].

ignore_abandoned

Returns the ignore_abandoned arrayref or [].

AUTHOR

Nigel Horne, <njh at nigelhorne.com>

LICENSE AND COPYRIGHT

Copyright (C) 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.