| 1 | package App::Midgen::Role::InDistribution; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use constant {TWO => 2, TRUE => 1, FALSE => 0,}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Types::Standard qw( Bool ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | requires qw( ppi_document debug ); | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 2 | our $VERSION = '0.34'; | |||||||||||||||||||||||||||
| 10 | 2 | $VERSION = eval $VERSION; ## no critic | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | ######## | ||||||||||||||||||||||||||||
| 14 | # is this a perl file | ||||||||||||||||||||||||||||
| 15 | # more files found than File-Find-Rule-Perl (!psgi) | ||||||||||||||||||||||||||||
| 16 | ######## | ||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub is_perlfile { | ||||||||||||||||||||||||||
|
Subroutine
is_perlfile: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 19 | 0 | my $filename = $_; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | for (qw(pm t psgi pl)) { | |||||||||||||||||||||||||||
| 22 | 0 | ▶ | if ($filename =~ m/[.]$_$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | print "looking for requires in (.$_)-> $filename\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | if $self->verbose >= TWO; | ||||||||||||||||||||||||||||
| 25 | 0 | return TRUE; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ($filename =~ m/[.]\w{2,4}$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | print "rejecting $filename\n" if $self->verbose >= TWO; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 0 | return FALSE; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | else { | ||||||||||||||||||||||||||||
| 33 | 0 | return $self->_confirm_perlfile($filename); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | ######## | ||||||||||||||||||||||||||||
| 38 | # confirm if this a perl file | ||||||||||||||||||||||||||||
| 39 | ####### | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub _confirm_perlfile { | ||||||||||||||||||||||||||
|
Subroutine
_confirm_perlfile: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||
| 41 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 42 | 0 | my $filename = shift; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # ignore dirs - bug found by farabi, azawawi++ | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | return FALSE if -d $filename; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | $self->_set_ppi_document(PPI::Document->new($filename)); | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | my $ppi_tc = $self->ppi_document->find('PPI::Token::Comment'); | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | my $a_pl_file = 0; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($ppi_tc) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # check first token-comment for a she-bang | ||||||||||||||||||||||||||||
| 56 | 0 | ▶ | $a_pl_file = 1 if $ppi_tc->[0]->content =~ m/^#!.*perl.*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ($self->ppi_document->find('PPI::Statement::Package') || $a_pl_file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->ppi_document->find("PPI::Statement::Package") or $a_pl_file
MC/DC0%0/2
$self->ppi_document->find("PPI::Statement::Package") or $a_pl_file
$self->ppi_document->find("PPI::Statement::Package")
$a_pl_file
Truth table0%0/3
A or B
A= $self->ppi_document->find("PPI::Statement::Package")B= $a_pl_file
| |||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($self->verbose >= TWO) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | ▶ | print "looking for requires in (package) -> " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | if $self->ppi_document->find('PPI::Statement::Package'); | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | print "looking for requires in (shebang) -> " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | if $ppi_tc->[0]->content =~ /perl/; | ||||||||||||||||||||||||||||
| 67 | 0 | print "$filename\n"; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 0 | return TRUE; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | else { | ||||||||||||||||||||||||||||
| 72 | 0 | return FALSE; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 2 | ▶ | no Moo::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 2 | 1; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||||||||||