| 1 | package Test::PureASCII; | ||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | 1 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Test::Builder; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||
| 11 | 1 | my $test = Test::Builder->new; | |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||
| 13 | 1 | our @TESTED; | |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | sub import { | ||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||
| 16 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 17 | 1 | my $caller = caller; | |||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||
| 19 | 1 | for my $func ( qw( file_is_pure_ascii all_perl_files_are_pure_ascii all_files_are_pure_ascii) ) { | |||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 21 | 3 | *{$caller."::".$func} = \&$func; | |||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | 1 | $test->exported_to($caller); | |||||||||||||||||||||||||||||||||
| 25 | 1 | $test->plan(@_); | |||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | sub _skip_file_p { | ||||||||||||||||||||||||||||||||
|
Subroutine
_skip_file_p: called CC=8 SCAR=33.4
| |||||||||||||||||||||||||||||||||||
| 29 | 1 | my %opts; | |||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | %opts = %{shift @_} if ref $_[0] eq 'HASH'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | if (defined(my $skip = $opts{skip})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 32 | 0 | my $file = shift; | |||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | for my $s (ref $skip eq 'ARRAY' ? @$skip : $skip) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | if (ref $s eq 'Regexp') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | return 1 if $file =~ $s; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||
| 37 | else { | ||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return 1 if $file eq $s; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||
| 42 | 1 | return 0; | |||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub _make_error { | ||||||||||||||||||||||||||||||||
|
Subroutine
_make_error: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||
| 46 | 0 | my ($bad, $error, $ln, $file) = @_; | |||||||||||||||||||||||||||||||||
| 47 | 0 | my @chars = map sprintf("0x%02x", ord $_), split //, $bad; | |||||||||||||||||||||||||||||||||
| 48 | 0 | my $chars = join(', ', @chars); | |||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $s = @chars > 1 ? ' sequence' : ''; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 50 | 0 | ' ' . sprintf($error, $s, $chars) . " at line $ln in $file"; | |||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | sub file_is_pure_ascii { | ||||||||||||||||||||||||||||||||
|
Subroutine
file_is_pure_ascii: called CC=27 SCAR=44.2
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 54 | 1 | my %opts; | |||||||||||||||||||||||||||||||||
| 55 | 1 | ▶ | %opts = %{shift @_} if ref $_[0] eq 'HASH'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 56 | 1 | my $skip_data = $opts{skip_data}; | |||||||||||||||||||||||||||||||||
| 57 | 1 | my $forbid_control = $opts{forbid_control}; | |||||||||||||||||||||||||||||||||
| 58 | 1 | my $forbid_cr = $opts{forbid_cr}; | |||||||||||||||||||||||||||||||||
| 59 | 1 | my $forbid_tab = $opts{forbid_tab}; | |||||||||||||||||||||||||||||||||
| 60 | 1 | my $require_crlf = $opts{require_crlf}; | |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||
| 62 | 1 | my $file = shift; | |||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||
| 64 | 1 | ▶ | _skip_file_p(\%opts, $file) and return 1; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | my $name = @_ ? shift : "Pure ASCII test for $file"; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||
| 68 | 1 | push @TESTED, $file; | |||||||||||||||||||||||||||||||||
| 69 | # $test->diag("FILE: $file"); | ||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | 1 | my $fh; | |||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | unless (open $fh, '<', $file) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 73 | 0 | $test->ok(0, $name); | |||||||||||||||||||||||||||||||||
| 74 | 0 | $test->diag(" unable to open '$file': $!"); | |||||||||||||||||||||||||||||||||
| 75 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||
| 77 | 1 | binmode $fh, ':bytes'; | |||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||
| 79 | 1 | my $failed = 0; | |||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 81 | # $test->diag("line $.: $_"); | ||||||||||||||||||||||||||||||||||
| 82 | 365 | ▶ | next if /\bpa_test_ignore\b/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 83 | 364 | ▶ | last if /\bpa_test_end\b/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 84 | 363 | ▶ | if (my ($lines) = /pa_test_skip_lines\(\d+\)/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 85 | 0 | <$fh> for 1..$lines; | |||||||||||||||||||||||||||||||||
| 86 | 0 | next; | |||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||
| 89 | 363 | my @errors; | |||||||||||||||||||||||||||||||||
| 90 | 363 | ▶ | /([^\x00-\x7f]+)/ and | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 91 | push @errors, _make_error($1, "non ASCII character%s %s", | ||||||||||||||||||||||||||||||||||
| 92 | $., $file); | ||||||||||||||||||||||||||||||||||
| 93 | 363 | ▶ | $forbid_control and /([\x00-\x08\x0b-\x1F])/ and | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$forbid_control and /([\x00-\x08\x0b-\x1F])/
MC/DC0%0/2
$forbid_control and /([\x00-\x08\x0b-\x1F])/
$forbid_control
/([\x00-\x08\x0b-\x1F])/
Truth table33%1/3
A and B
A= $forbid_controlB= /([\x00-\x08\x0b-\x1F])/
| |||||||||||||||||||||||||||||||||||
| 94 | push @errors, _make_error($1, "forbidden control character%s %s", | ||||||||||||||||||||||||||||||||||
| 95 | $., $file); | ||||||||||||||||||||||||||||||||||
| 96 | 363 | ▶ | $forbid_tab and /([\x09])/ and | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$forbid_tab and /([\x09])/
MC/DC0%0/2
$forbid_tab and /([\x09])/
$forbid_tab
/([\x09])/
Truth table33%1/3
A and B
A= $forbid_tabB= /([\x09])/
| |||||||||||||||||||||||||||||||||||
| 97 | push @errors, _make_error($1, "forbidden tab character%s %s", | ||||||||||||||||||||||||||||||||||
| 98 | $., $file); | ||||||||||||||||||||||||||||||||||
| 99 | 363 | ▶ | $forbid_cr and /([\x0d])/ and | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$forbid_cr and /([\x0d])/
MC/DC0%0/2
$forbid_cr and /([\x0d])/
$forbid_cr
/([\x0d])/
Truth table33%1/3
A and B
A= $forbid_crB= /([\x0d])/
| |||||||||||||||||||||||||||||||||||
| 100 | push @errors, _make_error($1, "forbidden CR character%s %s", | ||||||||||||||||||||||||||||||||||
| 101 | $., $file); | ||||||||||||||||||||||||||||||||||
| 102 | 363 | ▶ | $require_crlf and /(\x0d(?!\x0a)|(?<!\x0d)\x0a)/ and | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$require_crlf and /(\x0d(?!\x0a)|(?<!\x0d)\x0a)/
MC/DC0%0/2
$require_crlf and /(\x0d(?!\x0a)|(?<!\x0d)\x0a)/
$require_crlf
/(\x0d(?!\x0a)|(?<!\x0d)\x0a)/
Truth table33%1/3
A and B
A= $require_crlfB= /(\x0d(?!\x0a)|(?<!\x0d)\x0a)/
| |||||||||||||||||||||||||||||||||||
| 103 | push @errors, _make_error($a, "forbidden end of line character%s %s", | ||||||||||||||||||||||||||||||||||
| 104 | $., $file); | ||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||
| 106 | 363 | ▶ | if (@errors) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | $test->ok(0, $name) unless $failed; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 108 | 0 | $test->diag($_) for @errors; | |||||||||||||||||||||||||||||||||
| 109 | 0 | $failed = 1; | |||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||
| 112 | 363 | ▶ | last if ($skip_data and /^__DATA__$/); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$skip_data and /^__DATA__$/
MC/DC0%0/2
$skip_data and /^__DATA__$/
$skip_data
/^__DATA__$/
Truth table33%1/3
A and B
A= $skip_dataB= /^__DATA__$/
| |||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | unless (close $fh) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | $test->ok(0, $name) unless $failed; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 116 | 0 | $test->diag(" unable to read from '$file': $!"); | |||||||||||||||||||||||||||||||||
| 117 | 0 | return 0; | |||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | $failed ? 0 : $test->ok(1, $name); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||
| 122 | 1 | ▶ | sub all_perl_files_are_pure_ascii { | ||||||||||||||||||||||||||||||||
|
Subroutine
all_perl_files_are_pure_ascii: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 123 | 1 | my %opts; | |||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | %opts = %{shift @_} if ref $_[0] eq 'HASH'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||
| 126 | 1 | my @files = all_perl_files(\%opts, @_); | |||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||
| 128 | 1 | $test->plan( tests => scalar @files ); | |||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||
| 130 | 1 | my $ok = 1; | |||||||||||||||||||||||||||||||||
| 131 | 1 | foreach my $file (@files) { | |||||||||||||||||||||||||||||||||
| 132 | 1 | ▶ | file_is_pure_ascii(\%opts, $file) or undef $ok; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||
| 134 | 1 | return $ok; | |||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub all_files_are_pure_ascii { | ||||||||||||||||||||||||||||||||
|
Subroutine
all_files_are_pure_ascii: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 138 | 0 | my %opts; | |||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | %opts = %{shift @_} if ref $_[0] eq 'HASH'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||
| 141 | 0 | my @files = all_files(\%opts, @_); | |||||||||||||||||||||||||||||||||
| 142 | 0 | $test->plan( tests => scalar @files ); | |||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||
| 144 | 0 | my $ok = 1; | |||||||||||||||||||||||||||||||||
| 145 | 0 | foreach my $file (@files) { | |||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | file_is_pure_ascii(\%opts, $file) or undef $ok; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||
| 148 | 0 | return $ok; | |||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | sub all_perl_files { | ||||||||||||||||||||||||||||||||
|
Subroutine
all_perl_files: called CC=12 SCAR=25.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 152 | 1 | my %opts; | |||||||||||||||||||||||||||||||||
| 153 | 1 | ▶ | %opts = %{shift @_} if ref $_[0] eq 'HASH'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | my @queue = @_ ? @_ : starting_points(); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 156 | 1 | my @perl = (); | |||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | while ( @queue ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 159 | 23 | my $file = shift @queue; | |||||||||||||||||||||||||||||||||
| 160 | 23 | ▶ | if ( -d $file ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 161 | 14 | ▶ | opendir my $dh, $file or next; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 162 | 14 | my @newfiles = readdir $dh; | |||||||||||||||||||||||||||||||||
| 163 | 14 | closedir $dh; | |||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||
| 165 | 14 | @newfiles = File::Spec->no_upwards( @newfiles ); | |||||||||||||||||||||||||||||||||
| 166 | 14 | ▶ | @newfiles = grep { $_ ne "CVS" and $_ ne ".svn" and !/~$/ } @newfiles; | ||||||||||||||||||||||||||||||||
|
Condition33%2/6
$_ ne 'CVS' && $_ ne '.svn' && !/~$/
$_ ne "CVS" and $_ ne ".svn"
MC/DC0%0/3
$_ ne 'CVS' && $_ ne '.svn' && !/~$/
$_ ne "CVS"
$_ ne ".svn"
!/~$/
Truth table25%1/4
A and B && not(C)
A= $_ ne "CVS"B= $_ ne ".svn"C= !/~$/
| |||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||
| 168 | 14 | foreach my $newfile (@newfiles) { | |||||||||||||||||||||||||||||||||
| 169 | 22 | my $filename = File::Spec->catfile( $file, $newfile ); | |||||||||||||||||||||||||||||||||
| 170 | 22 | ▶ | if ( -f $filename ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 171 | 9 | push @queue, $filename; | |||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||
| 173 | else { | ||||||||||||||||||||||||||||||||||
| 174 | 13 | push @queue, File::Spec->catdir( $file, $newfile ); | |||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||
| 178 | 23 | ▶ | if ( -f $file ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 179 | 9 | ▶ | push @perl, $file if is_perl( $file ); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||
| 182 | 1 | return @perl; | |||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | sub all_files { | ||||||||||||||||||||||||||||||||
|
Subroutine
all_files: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 186 | 0 | my %opts; | |||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | %opts = %{shift @_} if ref $_[0] eq 'HASH'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | my @queue = @_ ? @_ : '.'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 190 | 0 | my @all = (); | |||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | while ( @queue ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 193 | 0 | my $file = shift @queue; | |||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( -d $file ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | opendir my $dh, $file or next; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 196 | 0 | my @newfiles = readdir $dh; | |||||||||||||||||||||||||||||||||
| 197 | 0 | closedir $dh; | |||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||
| 199 | 0 | @newfiles = File::Spec->no_upwards( @newfiles ); | |||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | @newfiles = grep { $_ ne "CVS" and $_ ne ".svn" and !/~$/ } @newfiles; | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$_ ne 'CVS' && $_ ne '.svn' && !/~$/
$_ ne "CVS" and $_ ne ".svn"
MC/DC0%0/3
$_ ne 'CVS' && $_ ne '.svn' && !/~$/
$_ ne "CVS"
$_ ne ".svn"
!/~$/
Truth table0%0/4
A and B && not(C)
A= $_ ne "CVS"B= $_ ne ".svn"C= !/~$/
| |||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||
| 202 | 0 | foreach my $newfile (@newfiles) { | |||||||||||||||||||||||||||||||||
| 203 | 0 | my $filename = File::Spec->catfile( $file, $newfile ); | |||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | if ( -f $filename ) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 205 | 0 | push @queue, $filename; | |||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||
| 207 | else { | ||||||||||||||||||||||||||||||||||
| 208 | 0 | push @queue, File::Spec->catdir( $file, $newfile ); | |||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | push @all, $file if -f $file | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||
| 214 | 0 | return @all; | |||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||
| 217 | 1 | ▶ | sub starting_points { | ||||||||||||||||||||||||||||||||
|
Subroutine
starting_points: called CC=2 SCAR=9.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 218 | 1 | ▶ | return 'blib' if -e 'blib'; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 219 | 0 | return 'lib'; | |||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||
| 222 | 9 | ▶ | sub is_perl { | ||||||||||||||||||||||||||||||||
|
Subroutine
is_perl: called CC=7 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 223 | 9 | my $file = shift; | |||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||
| 225 | 9 | ▶ | return 1 if $file =~ /\.PL$/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 226 | 9 | ▶ | return 1 if $file =~ /\.p(l|m|od)$/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 227 | 8 | ▶ | return 1 if $file =~ /\.t$/; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||
| 229 | 8 | ▶ | open my $fh, $file or return; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 230 | 8 | my $first = <$fh>; | |||||||||||||||||||||||||||||||||
| 231 | 8 | close $fh; | |||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||
| 233 | 8 | ▶ | return 1 if defined $first && ($first =~ /^#!.*perl/); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $first and $first =~ /^#!.*perl/
MC/DC0%0/2
defined $first and $first =~ /^#!.*perl/
defined $first
$first =~ /^#!.*perl/
Truth table33%1/3
A and B
A= defined $firstB= $first =~ /^#!.*perl/
| |||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||
| 235 | 8 | return; | |||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||
| 239 | 1 | 1; | |||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||
| 241 | __END__ | ||||||||||||||||||||||||||||||||||