| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package Devel::FIXME; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use fields qw/text line file package script time/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use 5.008_000; # needs open to work on scalar ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Scalar::Util qw/reftype/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use List::Util qw/first/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Carp qw/carp croak/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | our @EXPORT_OK = qw/FIXME SHOUT DROP CONT/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | our %EXPORT_TAGS = ( "constants" => \@EXPORT_OK ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | our $VERSION = 0.02; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # some constants for rules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | sub CONT () { 0 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | sub SHOUT () { 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | sub DROP () { 2 }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | our $REPAIR_INC = undef; # do not "repair" @INC by default | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | my %lock; # to prevent recursion | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | our %rets; # return value cache | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | our $cur; # the current file, used in an eval | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | our $err; # the current error, for rethrowal | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 4 | our $inited; # whether the code ref was installed in @INC, and all | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 4 | ▶ | { my $anon = ''; open my $fh, "<", \$anon or die $!; close $fh; } # otherwise perlio require stuff breaks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 7 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 7 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 7 | ▶ | unless($inited){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | $pkg->readfile($_) for ($0, sort grep { $_ ne __FILE__ } (values %INC)); # readfile on everything loaded, but not us (we don't want to match our own docs) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | $pkg->install_inc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 7 | $inited = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | our $carprec = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | ▶ | sub install_inc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_inc: called CC=1 SCAR=1.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 6 | ▶ | unshift @INC, sub { # YUCK! but tying %INC didn't work, and source filters are applied per caller. XS for source filter purposes is yucki/er/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=12 SCAR=35.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | ▶ | return undef if $lock{$file}; # if we're already processing the file, then we're in the eval several lines down. return. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 3 | local $lock{$file} = 1; # set this lock that prevents recursion | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | ▶ | unless (ref $INC[0] and $INC[0] == $self){ # if this happens, some stuff won't be filtered. It shouldn't happen often though. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $INC[0] and $INC[0] == $self
MC/DC0%0/2
ref $INC[0] and $INC[0] == $self
ref $INC[0]
$INC[0] == $self
Truth table33%1/3
A and B
A= ref $INC[0]B= $INC[0] == $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | local @INC = grep { !ref or $_ != $self } @INC; # make sure we don't recurse when carp loads it's various innards, it causes a mess | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
!ref($_) || $_ != $self
MC/DC0%0/2
!ref($_) || $_ != $self
!ref($_)
$_ != $self
Truth table0%0/3
not(A) || B
A= !ref($_)B= $_ != $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | carp "FIXME's magic sub is no longer first in \@INC" . ($REPAIR_INC ? ", repairing" : ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($REPAIR_INC){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | while ($i < @INC) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | ref $INC[$i] or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ($INC[$i] == $self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | unshift @INC, splice(@INC, $i, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } continue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # create some perl code that gives back the return value of the original package, and thus looks like you're really requiring the same thing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | my $buffer = "\${ delete \$Devel::FIXME::rets{q{$file}} };"; # return what the last module returned. I don't know why it doesn't work without refs | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # really load the file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | local $cur = $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 3 | my $ret = eval 'require $Devel::FIXME::cur'; # require always evaluates the return from an evalfile in scalar context, so we don't need to worry about list | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | ($err = "$@\n") =~ s/\nCompilation failed in require at \(eval \d+\)(?:\[.*?\])? line 1\.\n//s; # trim off the eval's appendix to the error | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 3 | ▶ | $buffer = 'die $Devel::FIXME::err' if $@; # rethrow this way, so that base.pm shuts up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # save the return value so that the original require can have it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 3 | $rets{$file} = \$ret; # see above for why it's a ref | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # look for FIXME comments in the file that was really required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 3 | ▶ | $pkg->readfile($INC{$file}) if ($INC{$file}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # return a filehandle containing source code that simply returns the value the real file did | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 3 | open my $fh, "<", \$buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 264167 | ▶ | sub regex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
regex: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 264167 | qr/#\s*(?:FIXME|XXX)\s+(.*)$/; # match a FIXME or an XXX, in a comment, with some lax whitespace rules, and suck in anything afterwords as the text | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 480 | ▶ | sub readfile { # FIXME refactor to something classier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readfile: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 480 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 480 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 480 | ▶ | return unless -f $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 479 | ▶ | open my $src, "<", $file or die "couldn't open $file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 478 | local $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 478 | ▶ | while(<$src>){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 264167 | ▶ | $pkg->FIXME( # if the line matches the fixme, generate a fixme | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | text => "$1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | line => $., # the current line number for <$src> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | file => $file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ) if $_ =~ $pkg->regex; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 264167 | ▶ | } continue { last if eof $src }; # is this a platform bug on OSX? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 478 | close $src; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 50 | ▶ | sub eval { # evaluates all the rules on a fixme object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eval: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 50 | my __PACKAGE__ $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 50 | ▶ | foreach my $rule ($self->can("rules") ? $self->rules : ()){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 42 | my $action = &$rule($self); # run the rule as a class method, and get back a return value | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 42 | ▶ | if ($action == SHOUT){ # if the rule said to shout, we shout and stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | return $self->shout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } elsif ($action == DROP){ # if the rule says to drop, we stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 38 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } # otherwise we keep looping through the rules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 10 | $self->shout; # and shout if there are no more rules left. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | ▶ | sub shout { # generate a pretty string and send it to STDERR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shout: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | my __PACKAGE__ $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | warn("# FIXME: $self->{text} at $self->{file} line $self->{line}.\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 62 | ▶ | sub new { # an object per FIXME statement | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=23.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 62 | my $pkg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 62 | my %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 62 | ▶ | if (@_ == 1){ # if we only have one arg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 20 | ▶ | if (ref $_[0] and reftype($_[0]) eq 'HASH'){ # and it's a hash ref, then we take the hashref to be our args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_[0] and builtin::reftype($_[0]) eq "HASH"
MC/DC50%1/2
ref $_[0] and builtin::reftype($_[0]) eq "HASH"
ref $_[0]
builtin::reftype($_[0]) eq "HASH"
Truth table66%2/3
A and B
A= ref $_[0]B= builtin::reftype($_[0]) eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 10 | %args = %{ $_[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } else { # if it's one arg and not a hashref, then it's our text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 10 | %args = ( text => $_[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } elsif (@_ % 2 == 0){ # if there's an even number of arguments, they are key value pairs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 41 | %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } else { # if the argument list is anything else we complain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | croak "Invalid arguments"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 61 | my __PACKAGE__ $self = $pkg->fields::new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 61 | %$self = %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # fill in some defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 61 | ▶ | $self->{package} ||= (caller(1))[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"package"} ||= (&CORE::GLOBAL::caller(1))[0]
MC/DC0%0/2
$self->{"package"} ||= (&CORE::GLOBAL::caller(1))[0]
$self->{"package"}
(&CORE::GLOBAL::caller(1))[0]
Truth table66%2/3
A ||= B
A= $self->{"package"}B= (&CORE::GLOBAL::caller(1))[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 61 | ▶ | $self->{file} ||= (caller(1))[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"file"} ||= (&CORE::GLOBAL::caller(1))[1]
MC/DC0%0/2
$self->{"file"} ||= (&CORE::GLOBAL::caller(1))[1]
$self->{"file"}
(&CORE::GLOBAL::caller(1))[1]
Truth table66%2/3
A ||= B
A= $self->{"file"}B= (&CORE::GLOBAL::caller(1))[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 61 | ▶ | $self->{line} ||= (caller(1))[2]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"line"} ||= (&CORE::GLOBAL::caller(1))[2]
MC/DC0%0/2
$self->{"line"} ||= (&CORE::GLOBAL::caller(1))[2]
$self->{"line"}
(&CORE::GLOBAL::caller(1))[2]
Truth table66%2/3
A ||= B
A= $self->{"line"}B= (&CORE::GLOBAL::caller(1))[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # these are mainly for rules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 61 | ▶ | $self->{script} ||= $0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"script"} ||= $0
MC/DC0%0/2
$self->{"script"} ||= $0
$self->{"script"}
$0
Truth table66%2/3
A ||= B
A= $self->{"script"}B= $0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 61 | ▶ | $self->{time} ||= localtime; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{"time"} ||= localtime
MC/DC0%0/2
$self->{"time"} ||= localtime
$self->{"time"}
localtime
Truth table66%2/3
A ||= B
A= $self->{"time"}B= localtime
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 61 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 10 | ▶ | sub import { # export \&FIXME to our caller, /and/ generate a message if there is one to generate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 10 | my $pkg = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 10 | ▶ | $pkg->init unless @_ > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 10 | ▶ | if (@_ == 1 or @_ > 2 or (@_ == 2 and first { $_[1] eq $_ or $_[1] eq "&$_" } @EXPORT_OK, map { ":$_" } keys %EXPORT_TAGS)){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 2 branches
Condition88%8/9
@_ == 1 or @_ > 2 or @_ == 2 and &first(sub {
$_[1] eq $_ or $_[1] eq "&$_";
}
, @Devel::FIXME::EXPORT_OK, map({":$_";} keys %Devel::FIXME::EXPORT_TAGS))
@_ == 1 or @_ > 2
@_ == 2 and &first(sub {
$_[1] eq $_ or $_[1] eq "&$_";
}
, @Devel::FIXME::EXPORT_OK, map({":$_";} keys %Devel::FIXME::EXPORT_TAGS))
MC/DC75%3/4
@_ == 1 or @_ > 2 or @_ == 2 and &first(sub {
$_[1] eq $_ or $_[1] eq "&$_";
}
, @Devel::FIXME::EXPORT_OK, map({":$_";} keys %Devel::FIXME::EXPORT_TAGS))
@_ == 1
@_ > 2
@_ == 2
&first(sub {
$_[1] eq $_ or $_[1] eq "&$_";
}
, @Devel::FIXME::EXPORT_OK, map({":$_";} keys %Devel::FIXME::EXPORT_TAGS))
Truth table80%4/5
A or B or C and D
A= @_ == 1B= @_ > 2C= @_ == 2D= &first(sub {
$_[1] eq $_ or $_[1] eq "&$_";
}
, @Devel::FIXME::EXPORT_OK, map({":$_";} keys %Devel::FIXME::EXPORT_TAGS))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 8 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 8 | local $Exporter::ExportLevel = $Exporter::ExportLevel + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 8 | $pkg->Exporter::import(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | $pkg->init; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | goto \&FIXME; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 50 | ▶ | sub FIXME { # generate a method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FIXME: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 50 | my $pkg = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 50 | ▶ | $pkg = shift if UNIVERSAL::can($_[0],"isa") and $_[0]->isa(__PACKAGE__); # it's a method or function, we don't care | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
UNIVERSAL::can($_[0], "isa") and $_[0]->isa(__PACKAGE__)
MC/DC50%1/2
UNIVERSAL::can($_[0], "isa") and $_[0]->isa(__PACKAGE__)
UNIVERSAL::can($_[0], "isa")
$_[0]->isa(__PACKAGE__)
Truth table66%2/3
A and B
A= UNIVERSAL::can($_[0], "isa")B= $_[0]->isa(__PACKAGE__)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 50 | $pkg->new(@_)->eval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 4 | *msg = \&FIXME; # booya. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 4 | __PACKAGE__ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||