Test::Pod::Coverage and "aliased"

Ovid on 2005-11-06T20:56:53

Test::Pod::Coverage is a great module. I use it a lot. Unfortunately, I am constantly getting bit by this module not recognizing "aliased" constant subroutines as something it should ignore.

As an example of the latter, internally my Model::World module does things like this:

use aliased 'Model::World::Word::Adjective';
use aliased 'Model::World::Word::Noun';
use aliased 'Model::World::Thing';
use aliased 'Model::World::Thing::Room';

my $big_room = Room->new( {
    adjective => Adjective->new('big'),
    size      => 10_000
});

my $box = Thing->new( {
    name     => Noun->new('box'),
    location => $big_room,
    size     => ...

aliased does a great job of cutting down on typing, but Test::Pod::Coverage sees those and chokes. Right now I get around that with something like this:

my $aliased = qr/^[[:upper:]][[:alpha:]]*$/;
my @modules =  Test::Pod::Coverage::all_modules();
plan tests => scalar @modules;

foreach my $module (@modules) {
    pod_coverage_ok( $module, { trustme => [ $aliased ] } );
}

There's a risk of false positives, but since I don't ordinarily write subroutines which begin with upper case letters, I think I'm pretty safe.

Of course, I don't really force the programmer to write out all of those "aliased" statements. All the programmer really needs to do is this:

use Model::World ':all';

my $big_room = Room->new( {
    adjective => Adjective->new('big'),
    size      => 10_000
    ...