Subject: | Class::Sniff seems to detect things that aren't "real" classes/packages |
I decided today to run Class::Sniff against a loaded copy of RT.
I got a whole bunch of false positives for classes using the script
pasted below.
It found a bunch of ::SUPER packages as well as packages for every
filename required, which isn't quite right.
RT's classes all do this:
eval "require RT::Ticket_Overlay";
if ($@ && $@ !~ qr{^Can't locate RT/Ticket_Overlay.pm}) {
die $@;
};
eval "require RT::Ticket_Vendor";
if ($@ && $@ !~ qr{^Can't locate RT/Ticket_Vendor.pm}) {
die $@;
};
eval "require RT::Ticket_Local";
if ($@ && $@ !~ qr{^Can't locate RT/Ticket_Local.pm}) {
die $@;
};
nowhere is there a "package RT::Ticket_Local" statement. But
Class::Sniff still finds RT::Ticket_Local.
I'm happy to test fixes, but I'm not quite sure what they are.
#!/usr/bin/env perl
use strict;
use warnings;
use Class::Sniff;
use RT;
RT::LoadConfig;
RT::Init;
my @sniffs = Class::Sniff->new_from_namespace({
namespace => 'RT',
universal => 1,
});
my $graph = $sniffs[0]->combine_graphs( @sniffs[ 1 .. $#sniffs ] );
my $graphviz = $graph->as_graphviz();
open my $DOT, '|dot -Tpng -o graph.png' or die("Cannot open pipe to
dot: $!"
);
print $DOT $graphviz;