| 1 | package Module::ScanDeps::Static; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use CLI::Simple::Utils qw(slurp); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use CLI::Simple::Constants qw(:booleans :chars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use English qw( -no_match_vars ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | ▶ | use IO::Scalar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 6 | ▶ | use List::Util qw( max none ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | ▶ | use version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | ▶ | use parent qw( CLI::Simple); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | ▶ | use Readonly; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | Readonly::Scalar my $DEFAULT_MIN_CORE_VERSION => $PERL_VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 | our $VERSION = '1.9.5'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 6 | ▶ | caller or exit __PACKAGE__->main(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | ▶ | sub make_path_from_module { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_path_from_module: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | my ( $self, $module ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 5 | my $file = join $SLASH, split /$DOUBLE_COLON/xsm, $module; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 5 | return "$file.pm"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | ▶ | sub get_module_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_module_version: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 5 | my ( $self, $module_w_version, @include_path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 5 | ▶ | if ( !@include_path ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 5 | @include_path = @INC; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 5 | my ( $module, $version ) = split /\s+/xsm, $module_w_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 5 | my %module_version = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | module => $module, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | version => $version, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | path => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 5 | ▶ | return \%module_version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | if $version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 5 | $module_version{'file'} = $self->make_path_from_module($module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 5 | foreach my $prefix (@include_path) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 40 | my $path = $prefix . $SLASH . $module_version{'file'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 40 | ▶ | next if !-e $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | $module_version{'path'} = $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | $module_version{'version'} = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | require ExtUtils::MM; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | my $v = ExtUtils::MM->parse_version($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | ▶ | return $v eq 'undef' ? 0 : $v || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$v or 0
MC/DC0%0/1
$v or 0
$v
Truth table50%1/2
A
A= $v
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 5 | return \%module_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub min_core_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
min_core_version: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $min_core_version = $self->get_min_core_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | $min_core_version = $min_core_version =~ /^v/xsm ? $min_core_version : "v$min_core_version"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | return version->parse($min_core_version)->numify; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 6 | Readonly::Hash our %PRAGMA => map { ( $_ => 1 ) } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | strict warnings vars lib feature utf8 bytes integer diagnostics | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | sort subs re mro locale open less filetest attributes autouse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 94 | ▶ | sub is_pragma { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_pragma: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 94 | my ( $self, $module_w_version ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 94 | my ($module) = split /\s/xsm, $module_w_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 94 | ▶ | return $PRAGMA{$module} ? $TRUE : $FALSE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub is_core { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_core: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my ( $self, $module_w_version ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my ( $module, $version ) = split /\s/xsm, $module_w_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $core = $FALSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | require Module::CoreList; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $first_release = Module::CoreList->first_release($module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $removed_version = Module::CoreList->removed_from($module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $min_core_version = $self->min_core_version(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # consider a module core if its first release was less than some | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # version of Perl. This is done because CPAN testers don't seem to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # test modules against Perls that are older than 5.8.9 - however, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # some modules like JSON::PP did not appear until after 5.10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # any removed module must be considered non-core | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ( !$removed_version && $first_release ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $removed_version and $first_release
MC/DC0%0/2
not $removed_version and $first_release
not $removed_version
$first_release
Truth table0%0/3
not(A) and B
A= not $removed_versionB= $first_release
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $core = $first_release <= $min_core_version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return $core; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 188 | ▶ | sub parse_line { ## no critic (Subroutines::ProhibitExcessComplexity) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_line: called CC=97 SCAR=70.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 188 | my ( $self, $line ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 188 | ▶ | return $line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | if $line =~ /\A\s*\#/xsm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 179 | my $fh = $self->get_handle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # track this file's own package declarations, for optional | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # self-exclusion filtering later (see --filter). Reused across a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # whole --file-list batch, not reset per file, so a package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # declared in one file correctly excludes a sibling file's use of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # it too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 179 | ▶ | if ( $line =~ /^\s*package\s+([\w:]+)/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 11 | $self->get_packages->{$1} = $TRUE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # skip the "= <<" block | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 179 | ▶ | if ( $line =~ /\A\s*(?:my\s*)?\$(?:.*)\s*=\s*<<\s*(["'`])(.+?)\1/xsm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$line =~ /\A\s*(?:my\s*)?\$(?:.*)\s*=\s*<<\s*(["'`])(.+?)\1/msx or $line =~ /\A\s*(?:my\s*)?\$(.*)\s*=\s*<<(\w+)\s*;/msx
MC/DC0%0/2
$line =~ /\A\s*(?:my\s*)?\$(?:.*)\s*=\s*<<\s*(["'`])(.+?)\1/msx or $line =~ /\A\s*(?:my\s*)?\$(.*)\s*=\s*<<(\w+)\s*;/msx
$line =~ /\A\s*(?:my\s*)?\$(?:.*)\s*=\s*<<\s*(["'`])(.+?)\1/msx
$line =~ /\A\s*(?:my\s*)?\$(.*)\s*=\s*<<(\w+)\s*;/msx
Truth table33%1/3
A or B
A= $line =~ /\A\s*(?:my\s*)?\$(?:.*)\s*=\s*<<\s*(["'`])(.+?)\1/msxB= $line =~ /\A\s*(?:my\s*)?\$(.*)\s*=\s*<<(\w+)\s*;/msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | || $line =~ /\A\s*(?:my\s*)?\$(.*)\s*=\s*<<(\w+)\s*;/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $tag = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | while ( $line = <$fh> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | last if $line eq $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $line = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | return if !$line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # skip q{} quoted sections - just hope we don't have curly brackets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # within the quote, nor an escaped hash mark that isn't a comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # marker, such as occurs right here. Draw the line somewhere. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 179 | ▶ | if ( $line =~ /\A.*\Wq[qxwr]?\s*([{([#|\/])[^})\]#|\/]*$/xsm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$line =~ m(\A.*\Wq[qxwr]?\s*([{([#|/])[^})\]#|/]*$)msx and not $line =~ /\A\s*(?:require|use)\s/msx
MC/DC0%0/2
$line =~ m(\A.*\Wq[qxwr]?\s*([{([#|/])[^})\]#|/]*$)msx and not $line =~ /\A\s*(?:require|use)\s/msx
$line =~ m(\A.*\Wq[qxwr]?\s*([{([#|/])[^})\]#|/]*$)msx
not $line =~ /\A\s*(?:require|use)\s/msx
Truth table33%1/3
A and not(B)
A= $line =~ m(\A.*\Wq[qxwr]?\s*([{([#|/])[^})\]#|/]*$)msxB= not $line =~ /\A\s*(?:require|use)\s/msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | && $line !~ /\A\s*(?:require|use)\s/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $tag = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $tag =~ tr/{\(\[\#|\//})]#|\//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $tag = quotemeta $tag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | while ( $line = <$fh> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | last if $line =~ /$tag/xsm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | return if !$line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # skip the documentation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # we should not need to have item in this if statement (it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # properly belongs in the over/back section) but people do not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # read the perldoc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 179 | ▶ | if ( $line =~ /\A=(head[\d]|pod|for|item)/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | while ( $line = <$fh> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | last if $line =~ /\A^=cut/xsm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | return if !$line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 179 | ▶ | if ( $line =~ /\A=over/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | while ( $line = <$fh> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | last if /\A=back/xsm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | return if !$line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # skip the data section | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 179 | ▶ | return if $line =~ /\A__(DATA|END)__/xsm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 179 | my $modver_re = qr/[.\d]+/xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # The (require|use) match further down in this subroutine will match lines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # within a multi-line print or return statements. So, let's skip over such | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # statements whose content should not be loading modules anyway. -BEF- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 179 | ▶ | if ( $line =~ /print(?:\s+|\s+\S+\s+)\<\<\s*(["'`])(.+?)\1/xsm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$line =~ /print(?:\s+|\s+\S+\s+)\<\<\s*(["'`])(.+?)\1/msx or $line =~ /print(\s+|\s+\S+\s+)\<\<(\w+)/msx or $line =~ /return(\s+)\<\<(\w+)/msx
$line =~ /print(?:\s+|\s+\S+\s+)\<\<\s*(["'`])(.+?)\1/msx or $line =~ /print(\s+|\s+\S+\s+)\<\<(\w+)/msx
MC/DC0%0/3
$line =~ /print(?:\s+|\s+\S+\s+)\<\<\s*(["'`])(.+?)\1/msx or $line =~ /print(\s+|\s+\S+\s+)\<\<(\w+)/msx or $line =~ /return(\s+)\<\<(\w+)/msx
$line =~ /print(?:\s+|\s+\S+\s+)\<\<\s*(["'`])(.+?)\1/msx
$line =~ /print(\s+|\s+\S+\s+)\<\<(\w+)/msx
$line =~ /return(\s+)\<\<(\w+)/msx
Truth table25%1/4
A or B or C
A= $line =~ /print(?:\s+|\s+\S+\s+)\<\<\s*(["'`])(.+?)\1/msxB= $line =~ /print(\s+|\s+\S+\s+)\<\<(\w+)/msxC= $line =~ /return(\s+)\<\<(\w+)/msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | || $line =~ /print(\s+|\s+\S+\s+)\<\<(\w+)/xsm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | || $line =~ /return(\s+)\<\<(\w+)/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | my $tag = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | while ( $line = <$fh> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | last if $line eq $tag; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $line = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | return if !$line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # Skip multiline print and assign statements | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 179 | ▶ | if ( $line =~ /\$\S+\s*=\s*(")([^"\\]|(\\.))*\z/xsm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$line =~ /\$\S+\s*=\s*(")([^"\\]|(\\.))*\z/msx or $line =~ /\$\S+\s*=\s*(')([^'\\]|(\\.))*\z/msx or $line =~ /print\s+(")([^"\\]|(\\.))*\z/msx or $line =~ /print\s+(')([^'\\]|(\\.))*\z/msx
$line =~ /\$\S+\s*=\s*(")([^"\\]|(\\.))*\z/msx or $line =~ /\$\S+\s*=\s*(')([^'\\]|(\\.))*\z/msx or $line =~ /print\s+(")([^"\\]|(\\.))*\z/msx
$line =~ /\$\S+\s*=\s*(")([^"\\]|(\\.))*\z/msx or $line =~ /\$\S+\s*=\s*(')([^'\\]|(\\.))*\z/msx
MC/DC0%0/4
$line =~ /\$\S+\s*=\s*(")([^"\\]|(\\.))*\z/msx or $line =~ /\$\S+\s*=\s*(')([^'\\]|(\\.))*\z/msx or $line =~ /print\s+(")([^"\\]|(\\.))*\z/msx or $line =~ /print\s+(')([^'\\]|(\\.))*\z/msx
$line =~ /\$\S+\s*=\s*(")([^"\\]|(\\.))*\z/msx
$line =~ /\$\S+\s*=\s*(')([^'\\]|(\\.))*\z/msx
$line =~ /print\s+(")([^"\\]|(\\.))*\z/msx
$line =~ /print\s+(')([^'\\]|(\\.))*\z/msx
Truth table20%1/5
A or B or C or D
A= $line =~ /\$\S+\s*=\s*(")([^"\\]|(\\.))*\z/msxB= $line =~ /\$\S+\s*=\s*(')([^'\\]|(\\.))*\z/msxC= $line =~ /print\s+(")([^"\\]|(\\.))*\z/msxD= $line =~ /print\s+(')([^'\\]|(\\.))*\z/msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | || $line =~ /\$\S+\s*=\s*(')([^'\\]|(\\.))*\z/xsm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | || $line =~ /print\s+(")([^"\\]|(\\.))*\z/xsm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | || $line =~ /print\s+(')([^'\\]|(\\.))*\z/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $quote = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | while ( $line = <$fh> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | last if $line =~ /\A([^\\$quote]|(\\.))*$quote/xsm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $line = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | return if !$line; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # Role::Tiny::With / Moo::with-style role composition: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # use Role::Tiny::With; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # with 'Foo'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # with 'Foo', 'Bar'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | # with qw(Foo Bar); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # 'with' is not a use/require statement so it never enters the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # require|use branch below. Anchor on 'with' as the leading token | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # (whitespace immediately after) so we don't match "without", a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # hash key 'with => ...', or prose in comments/POD. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # Moose's 'extends' plays the same structural role for base-class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | # declaration (extends 'Foo'; extends 'Foo', 'Bar';) and gets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # identical treatment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 179 | ▶ | if ( $line =~ /\A\s*(with|extends)\b\s*(.*?)\s*;?\s*\z/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 5 | my $args = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # with('Foo') / with ('Foo', 'Bar') -- strip an enclosing call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | # paren, but only when it isn't the paren belonging to qw(...). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 5 | ▶ | if ( $args =~ /\A[(](.*)[)]\z/xsm && $args !~ /\Aqw\b/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args =~ /\A[(](.*)[)]\z/msx and not $args =~ /\Aqw\b/msx
MC/DC0%0/2
$args =~ /\A[(](.*)[)]\z/msx and not $args =~ /\Aqw\b/msx
$args =~ /\A[(](.*)[)]\z/msx
not $args =~ /\Aqw\b/msx
Truth table33%1/3
A and not(B)
A= $args =~ /\A[(](.*)[)]\z/msxB= not $args =~ /\Aqw\b/msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $args = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 5 | ▶ | if ( $args =~ /\Aqw\s*[{(\/'"]\s*([^)}\/'"]+)\s*[)}\/'"]/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | foreach ( split $SPACE, $1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $self->add_require( $_, undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | elsif ( $args =~ /\A(["'])[\w:]+\1(\s*,\s*(["'])[\w:]+\3)*\z/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 5 | ▶ | while ( $args =~ /(["'])([\w:]+)\1/gxsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 5 | $self->add_require( $2, undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 5 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # doesn't look like a role/base list after all (e.g. "with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # following caveats" in a comment/doc line that slipped through) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # -- fall through to normal processing below. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # could be in an eval - if we catch an exception it must not be a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # hard requirement, so route these to suggests instead of require. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # (recommends is reserved for a non-eval conditional/indented | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # require -- see recommend_require below. eval-wrapped is a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # stronger signal: the author has explicitly written failure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # handling around it, so it's the softer of the two.) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | # eval { require Term::ReadLine } or die $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | # eval "require Term::Rendezvous;" or die $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # eval { require Carp } if defined $^S; # If error/warning during compilation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 174 | my $add_dep = $self->can('add_require'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # whole-line comments never contain real code, but our eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | # detection below isn't anchored to the start of the line (unlike | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # the main require/use pattern, which is, and so already correctly | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # ignores comment lines) -- so a documentation comment showing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | # example usage, like the ones directly above this code, would | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # otherwise get parsed as if it were live code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 174 | my $is_comment_line = $line =~ /\A\s*\#/xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # eval { ... } -- whether it closes on the same line or spans | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # several, track brace depth starting from the eval's OWN opening | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # brace and stop at ITS matching close, rather than counting every | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # brace on the line indiscriminately. That distinction matters: a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # line like `eval { require Foo; } or do { ... }` has a *balanced* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # eval block followed by an unrelated brace from `or do {}` -- a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # naive whole-line brace count sees net +1 and wrongly assumes the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # eval is still open, sweeping unrelated code (or, worse, a string's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # contents, e.g. a die message containing the word "use") into what | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | # it thinks is still eval body text. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 174 | ▶ | if ( !$is_comment_line && $line =~ /\beval\s*([{])/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $is_comment_line and $line =~ /\beval\s*([{])/msx
MC/DC50%1/2
not $is_comment_line and $line =~ /\beval\s*([{])/msx
not $is_comment_line
$line =~ /\beval\s*([{])/msx
Truth table66%2/3
not(A) and B
A= not $is_comment_lineB= $line =~ /\beval\s*([{])/msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 25 | my $body_start = $+[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 25 | my $depth = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 25 | my $pos = $body_start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 25 | my $whole_text = $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 25 | FIND_CLOSE: while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 75 | ▶ | while ( $pos < length $whole_text ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 1410 | my $c = substr $whole_text, $pos, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 1410 | ▶ | if ( $c eq '{' ) { $depth++; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | elsif ( $c eq '}' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 30 | $depth--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 30 | ▶ | last FIND_CLOSE if !$depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 1385 | $pos++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 50 | my $next = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 50 | ▶ | last FIND_CLOSE if !defined $next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 50 | $whole_text .= $next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 25 | ▶ | if ( !$depth ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 25 | my $eval_close = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 25 | my $body = substr $whole_text, $body_start, $eval_close - $body_start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 25 | $body =~ s/^\s*\#.*$//mg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # find where the WHOLE STATEMENT ends -- the next ';' that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # occurs while not nested inside any (further) brace. This one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # scan correctly handles a bare `eval {...};`, a trailing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # `or die ...;`, and a trailing `or do { ... };` alike, without | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # needing to recognize 'or'/'do' as keywords at all: each of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # those shapes' own terminating ';' is simply the first one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # that occurs at brace depth 0, counting fresh from right after | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # the eval's own close. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 25 | my $stmt_depth = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 25 | $pos = $eval_close + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 25 | my $stmt_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 25 | FIND_SEMI: while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 25 | ▶ | while ( $pos < length $whole_text ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 75 | my $c = substr $whole_text, $pos, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | if ( $c eq '{' ) { $stmt_depth++; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | elsif ( $c eq '}' ) { $stmt_depth--; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | ▶ | elsif ( $c eq ';' && !$stmt_depth ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$c eq ";" and not $stmt_depth
MC/DC50%1/2
$c eq ";" and not $stmt_depth
$c eq ";"
not $stmt_depth
Truth table66%2/3
A and not(B)
A= $c eq ";"B= not $stmt_depth
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 25 | $stmt_end = $pos + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 25 | last FIND_SEMI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 50 | $pos++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $next = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | last FIND_SEMI if !defined $next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $whole_text .= $next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # default classification for an eval with no annotation -- off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | # (suggests) unless the caller has set eval_recommends to shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # the project-wide default the other way. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 25 | ▶ | my $tier = $self->get_eval_recommends ? 'recommends' : 'suggests'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # an explicit ## scandeps: annotation, immediately after the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # semicolon that ends the whole statement, always wins over the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # default -- this is the one point where a human's stated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # intent overrides inference from code structure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 25 | ▶ | if ( defined $stmt_end ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 25 | my $newline_pos = index $whole_text, "\n", $stmt_end; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 25 | ▶ | my $rest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | = $newline_pos >= 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | ? substr( $whole_text, $stmt_end, $newline_pos - $stmt_end ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | : substr( $whole_text, $stmt_end ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 25 | ▶ | if ( $rest =~ /\A\s*\#\#\s*scandeps:\s*(requires|recommends|suggests)\b/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 5 | $tier = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 25 | ▶ | my $adder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | = $tier eq 'requires' ? 'add_require' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | : $tier eq 'recommends' ? 'add_recommends' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | : 'add_suggests'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 25 | ▶ | while ( $body =~ /\b(?:require|use)\s+([\w:]+)(?:\s+([\d.]+))?/gxsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 25 | $self->$adder( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 25 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 149 | ▶ | if ( !$is_comment_line && $line =~ /\beval\s*(?<q>["'])(?<body>(?:[^\\]|\\.)*?)\k<q>/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $is_comment_line and $line =~ /\beval\s*(?<q>["'])(?<body>(?:[^\\]|\\.)*?)\k<q>/msx
MC/DC0%0/2
not $is_comment_line and $line =~ /\beval\s*(?<q>["'])(?<body>(?:[^\\]|\\.)*?)\k<q>/msx
not $is_comment_line
$line =~ /\beval\s*(?<q>["'])(?<body>(?:[^\\]|\\.)*?)\k<q>/msx
Truth table33%1/3
not(A) and B
A= not $is_comment_lineB= $line =~ /\beval\s*(?<q>["'])(?<body>(?:[^\\]|\\.)*?)\k<q>/msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my $body = $+{body}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | if ( $body =~ /\b(?:require|use)\s+/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $line = $body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $add_dep = $self->can('add_suggests'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | ## no critic (ProhibitComplexRegexes, RequireBracesForMultiline) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 149 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | ( $line =~ /\A(\s*) # we hope the inclusion starts the line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | (require|use)\s+(?![{]) # do not want 'do {' loops | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # quotes around name are always legal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | ['"]?([\w:.\/]+?)['"]?[\t; ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # the syntax for 'use' allows version requirements | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # the latter part is for "use base qw(Foo)" and friends special case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | \s*($modver_re|(qw\s*[{(\/'"]\s*|['"])[^})\/"'\$]*?\s*[})\/"'])?/xsm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # \s*($modver_re|(qw\s*[(\/'"]\s*|['"])[^)\/"'\$]*?\s*[)\/"'])? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 62 | my ( $whitespace, $statement, $module, $version ) = ( $1, $2, $3, $4 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 62 | ▶ | $version //= $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$version //= $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$version //= $Module::ScanDeps::Static::EMPTY
$version
$Module::ScanDeps::Static::EMPTY
Truth table66%2/3
A //= B
A= $versionB= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | #print {*STDERR} "$whitespace, $statement, $module, $version\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # fix misidentification of version when use parent qw{ Foo }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | # Pragmatism dictates that I just identify the misidentification | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | # instead of trying to make the regexp above even more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # complicated... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 62 | ▶ | if ( $statement eq 'use' && $module =~ /(parent|base)/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$statement eq "use" and $module =~ /(parent|base)/msx
MC/DC0%0/2
$statement eq "use" and $module =~ /(parent|base)/msx
$statement eq "use"
$module =~ /(parent|base)/msx
Truth table66%2/3
A and B
A= $statement eq "use"B= $module =~ /(parent|base)/msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | if ( $version =~ /\A\s*qw?\s*['"{(\/]\s*([^'")}\/]+)\s*['")}\/]/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | $module = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | $version = $EMPTY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | elsif ( $version =~ /\A\s*['"]([^"']+)['"]\s*\z/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $module = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $version = $EMPTY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | #print {*STDERR} "$whitespace, $statement, $module, $version\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # we only consider require statements that are flushed against | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | # the left edge to be hard requirements by default. any other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | # require statements give too many false positives, as they are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # usually inside of an if statement as a fallback module or a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # rarely used option. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | # recommend_require, when set, takes priority over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # include_require for this decision: a non-left-flushed require | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | # is always routed to recommends rather than being treated as a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | # hard requirement or dropped outright, regardless of whether | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # include_require is on or off. This is a strict backward | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # compatibility addition -- with recommend_require left at its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | # default (off), every case below behaves exactly as it did | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | # before this option existed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # this whole block is skipped when eval-detection above already | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # claimed this line ($add_dep is add_suggests) -- the rewritten | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # eval body carries leading whitespace from inside the braces, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # which would otherwise look like an indented require and get | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # reclassified as recommends, silently overriding the more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # specific suggests tier eval-detection already assigned. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 62 | ▶ | if ( $statement eq 'require' && $add_dep != $self->can('add_suggests') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$statement eq "require" and $add_dep != $self->can("add_suggests")
MC/DC50%1/2
$statement eq "require" and $add_dep != $self->can("add_suggests")
$statement eq "require"
$add_dep != $self->can("add_suggests")
Truth table66%2/3
A and B
A= $statement eq "require"B= $add_dep != $self->can("add_suggests")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 17 | ▶ | if ( $whitespace ne $EMPTY ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 5 | ▶ | if ( $self->get_recommend_require ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 1 | $add_dep = $self->can('add_recommends'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | elsif ( !$self->get_include_require ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | # else: include_require on, recommend_require off -- falls | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | # through unchanged, treated as a hard requirement. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | ▶ | elsif ( $self->get_include_require && $line =~ /\$/xsm ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->get_include_require and $line =~ /\$/msx
MC/DC0%0/2
$self->get_include_require and $line =~ /\$/msx
$self->get_include_require
$line =~ /\$/msx
Truth table33%1/3
A and B
A= $self->get_include_requireB= $line =~ /\$/msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | return $line; # eval? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | # if there is some interpolation of variables just skip this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # dependency, we do not want | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | # do "$ENV{LOGDIR}/$rcfile"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 62 | ▶ | return $line if $module =~ /\$/xsm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # skip if the phrase was "use of" -- shows up in gimp-perl, et al. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 62 | ▶ | return $line if $module eq 'of'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | # if the module ends in a comma we probably caught some | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | # documentation of the form 'check stuff,\n do stuff, clean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # stuff.' there are several of these in the perl distribution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 62 | ▶ | return $line if $module =~ /[,>]\z/xsm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # if the module name starts in a dot it is not a module name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | # Is this necessary? Please give me an example if you turn this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # back on. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | # ($module =~ m/^\./) && next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | # if the module starts with /, it is an absolute path to a file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 62 | ▶ | if ( $module =~ /\A\//xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $add_dep->( $self, $module ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # sometimes people do use POSIX qw(foo), or use POSIX(qw(foo)) etc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # we can strip qw.*$, as well as (.*$: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 62 | $module =~ s/qw.*\z//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 62 | $module =~ s/[(].*\z//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # some perl programmers write 'require URI/URL;' when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | # they mean 'require URI::URL;' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 62 | ▶ | if ( $module !~ /[.]pl$/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # if the module ends with .pm, strip it to leave only basename. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 62 | $module =~ s/[.]pm\z//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 62 | $module =~ s/\//::/xsgm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # trim off trailing parentheses if any. Sometimes people pass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # the module an empty list. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 62 | $module =~ s/[(]\s*[)]$//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 62 | ▶ | if ( $module =~ /\A(v?[\d._]+)\z/xsm ) { # v now captured, not stripped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $ver = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my $normalized = eval { version->parse($ver)->numify }; # -> 5.024000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | $self->get_perlreq->{'perl'} = $normalized // $ver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$normalized // $ver
MC/DC0%0/2
$normalized // $ver
$normalized
$ver
Truth table0%0/3
A // B
A= $normalizedB= $ver
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # ph files do not use the package name inside the file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | # perlmodlib documentation says: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | # the .ph files made by h2ph will probably end up as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | # extension modules made by h2xs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | # so do not expend much effort on these. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | # there is no easy way to find out if a file named systeminfo.ph | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | # will be included with the name sys/systeminfo.ph so only use the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | # basename of *.ph files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 62 | ▶ | return $line if $module =~ /[.]ph\z/xsm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | # use base|parent qw(Foo) dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 62 | ▶ | if ( $statement eq 'use' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$statement eq "use" and $module eq "base" || $module eq "parent"
$module eq "base" or $module eq "parent"
MC/DC0%0/3
$statement eq "use" and $module eq "base" || $module eq "parent"
$statement eq "use"
$module eq "base"
$module eq "parent"
Truth table50%2/4
A and B or C
A= $statement eq "use"B= $module eq "base"C= $module eq "parent"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | && ( $module eq 'base' || $module eq 'parent' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $add_dep->( $self, $module, $version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | #print {*STDERR} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | # "statement: $statement module: $module, version: $version\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | if ( $version =~ /\Aqw\s*[{(\/'"]\s*([^)}\/"']+?)\s*[})\/"']/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | foreach ( split $SPACE, $1 ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $add_dep->( $self, $line, undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | elsif ( $version =~ /(["'])([^"']+)\1/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | $add_dep->( $self, $2, undef ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 62 | ▶ | if ( $version && $version !~ /\A$modver_re\z/oxsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$version and not $version =~ /\A$modver_re\z/mosx
MC/DC100%2/2
$version and not $version =~ /\A$modver_re\z/mosx
$version
not $version =~ /\A$modver_re\z/mosx
Truth table100%3/3
A and not(B)
A= $versionB= not $version =~ /\A$modver_re\z/mosx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 10 | $version = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | #print {*STDERR} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | # "statement: $statement module: $module, version: $version\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 62 | my @module_list = split /\s+/xsm, $module; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 62 | ▶ | if ( @module_list > 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | for (@module_list) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | $add_dep->( $self, $_, $EMPTY ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 62 | $add_dep->( $self, $module, $version ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 149 | return $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 13 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=11 SCAR=33.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 13 | my ( $self, $script ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 13 | ▶ | if ( my $file = $self->get_path ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | chomp $file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | open my $fh, '<', $file ## no critic (InputOutput::RequireBriefOpen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | or croak "could not open file '$file' for reading: $OS_ERROR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | $self->set_handle($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 13 | ▶ | if ( !$self->get_handle && $script ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
not $self->get_handle and $script
MC/DC0%0/2
not $self->get_handle and $script
not $self->get_handle
$script
Truth table33%1/3
not(A) and B
A= not $self->get_handleB= $script
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | $self->set_handle( IO::Scalar->new($script) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | elsif ( !$self->get_handle ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | open my $fh, '<', \*STDIN ## no critic (InputOutput::RequireBriefOpen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | or croak 'could not open STDIN'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | $self->set_handle($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 13 | my $fh = $self->get_handle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 13 | ▶ | while ( my $line = <$fh> ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 188 | ▶ | last if !$self->parse_line($line); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | # only close the file if we opened... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 13 | ▶ | if ( $self->get_path ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | close $fh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | or croak 'could not close file ' . $self->get_path . "$OS_ERROR\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 13 | my @sorted_dependencies = sort keys %{ $self->get_require }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 13 | return @sorted_dependencies; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | # To be honest, I'm really not sure what the code below should do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # other than simply put the version number in the hash. I can only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | # surmise that if the original script was running in the context of a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | # list of perl scripts in a project AND one script specified an older | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | # version of a module, then that version is replace with the newer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | # version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | # In our implementation here, the typical use case (I think) will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | # for an instance of Module::ScanDeps::Static to parse one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | # script. However, it is possible for the instance to scan multiple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | # files by calling "parse()" iteratively, accumulating the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | # dependencies along the way. In that case this method's actions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | # appear to be relevant. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | # Thinking through the above use case and the way it is being | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | # implemented might indicate a "bug", or at least a design flaw. Take | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | # the case where two Perl scripts (presumably in the same project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | # considering that this utility was written for packaging RPMs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | # require different versions of the same module. Rare, and odd, but | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | # possible - although one might wonder why the author of these scripts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | # didn't resolve any conflicts between the modules so that he could | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | # use one version of said module. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | # In any event this method enforces a single version of the module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | # (the highest) as the answer to the question what version of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | # __fill_in_the_blank__ module do I require? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | # The original method did not attempt to find the version of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | # module on the system where this script was being executed. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | # implementation does try to do that if you've sent the "add_version" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | # option to a true value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 71 | ▶ | sub add_require { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_require: called CC=10 SCAR=25.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 71 | my ( $self, $module, $newver ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 71 | ▶ | $newver //= $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$newver //= $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$newver //= $Module::ScanDeps::Static::EMPTY
$newver
$Module::ScanDeps::Static::EMPTY
Truth table66%2/3
A //= B
A= $newverB= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 71 | $module =~ s/\A\s*//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 71 | $module =~ s/\s*\z//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 71 | ▶ | return $self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | if $self->is_pragma($module); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | # strongest tier wins: a hard requirement supersedes any softer listing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 41 | delete $self->get_recommends->{$module}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 41 | delete $self->get_suggests->{$module}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 41 | my $require = $self->get_require; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 41 | my $oldver = $require->{$module}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 41 | ▶ | if ($oldver) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | if ( $newver && version->new($oldver) < $newver ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$newver and "version"->new($oldver) < $newver
MC/DC0%0/2
$newver and "version"->new($oldver) < $newver
$newver
"version"->new($oldver) < $newver
Truth table0%0/3
A and B
A= $newverB= "version"->new($oldver) < $newver
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | $require->{$module} = $newver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | elsif ( !$newver ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 39 | my $m = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 39 | ▶ | if ( $self->get_add_version ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 5 | $m = $self->get_module_version($module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 39 | ▶ | $require->{$module} = $m->{'version'} // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$m->{"version"} // $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$m->{"version"} // $Module::ScanDeps::Static::EMPTY
$m->{"version"}
$Module::ScanDeps::Static::EMPTY
Truth table66%2/3
A // B
A= $m->{"version"}B= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 2 | ▶ | $require->{$module} = $newver // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$newver // $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$newver // $Module::ScanDeps::Static::EMPTY
$newver
$Module::ScanDeps::Static::EMPTY
Truth table33%1/3
A // B
A= $newverB= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 41 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 1 | ▶ | sub add_recommends { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_recommends: called CC=11 SCAR=32.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 1 | my ( $self, $module, $newver ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 1 | ▶ | $newver //= $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$newver //= $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$newver //= $Module::ScanDeps::Static::EMPTY
$newver
$Module::ScanDeps::Static::EMPTY
Truth table33%1/3
A //= B
A= $newverB= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 1 | $module =~ s/\A\s*//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 1 | $module =~ s/\s*\z//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 1 | ▶ | return $self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | if $self->is_pragma($module); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | # a stronger tier wins: do not downgrade an existing hard requirement | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | return $self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 1 | ▶ | if exists $self->get_require->{$module}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 1 | delete $self->get_suggests->{$module}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 1 | my $recommends = $self->get_recommends; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 1 | my $oldver = $recommends->{$module}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 1 | ▶ | if ($oldver) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | ▶ | if ( $newver && version->new($oldver) < $newver ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$newver and "version"->new($oldver) < $newver
MC/DC0%0/2
$newver and "version"->new($oldver) < $newver
$newver
"version"->new($oldver) < $newver
Truth table0%0/3
A and B
A= $newverB= "version"->new($oldver) < $newver
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | $recommends->{$module} = $newver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | elsif ( !$newver ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 1 | my $m = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 1 | ▶ | if ( $self->get_add_version ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | $m = $self->get_module_version($module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1 | ▶ | $recommends->{$module} = $m->{'version'} // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$m->{"version"} // $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$m->{"version"} // $Module::ScanDeps::Static::EMPTY
$m->{"version"}
$Module::ScanDeps::Static::EMPTY
Truth table33%1/3
A // B
A= $m->{"version"}B= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | $recommends->{$module} = $newver // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$newver // $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$newver // $Module::ScanDeps::Static::EMPTY
$newver
$Module::ScanDeps::Static::EMPTY
Truth table0%0/3
A // B
A= $newverB= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 20 | ▶ | sub add_suggests { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_suggests: called CC=12 SCAR=34.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 20 | my ( $self, $module, $newver ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 20 | ▶ | $newver //= $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$newver //= $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$newver //= $Module::ScanDeps::Static::EMPTY
$newver
$Module::ScanDeps::Static::EMPTY
Truth table33%1/3
A //= B
A= $newverB= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 20 | $module =~ s/\A\s*//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 20 | $module =~ s/\s*\z//xsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 20 | ▶ | return $self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | if $self->is_pragma($module); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | # a stronger tier wins: do not add if already required or recommended | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | return $self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | if exists $self->get_require->{$module} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 20 | ▶ | || exists $self->get_recommends->{$module}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->get_require->{$module} or exists $self->get_recommends->{$module}
MC/DC0%0/2
exists $self->get_require->{$module} or exists $self->get_recommends->{$module}
exists $self->get_require->{$module}
exists $self->get_recommends->{$module}
Truth table33%1/3
A or B
A= exists $self->get_require->{$module}B= exists $self->get_recommends->{$module}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 20 | my $suggests = $self->get_suggests; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 20 | my $oldver = $suggests->{$module}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 20 | ▶ | if ($oldver) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | if ( $newver && version->new($oldver) < $newver ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$newver and "version"->new($oldver) < $newver
MC/DC0%0/2
$newver and "version"->new($oldver) < $newver
$newver
"version"->new($oldver) < $newver
Truth table0%0/3
A and B
A= $newverB= "version"->new($oldver) < $newver
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | $suggests->{$module} = $newver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | elsif ( !$newver ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 20 | my $m = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 20 | ▶ | if ( $self->get_add_version ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | $m = $self->get_module_version($module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 20 | ▶ | $suggests->{$module} = $m->{'version'} // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$m->{"version"} // $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$m->{"version"} // $Module::ScanDeps::Static::EMPTY
$m->{"version"}
$Module::ScanDeps::Static::EMPTY
Truth table33%1/3
A // B
A= $m->{"version"}B= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | ▶ | $suggests->{$module} = $newver // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$newver // $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$newver // $Module::ScanDeps::Static::EMPTY
$newver
$Module::ScanDeps::Static::EMPTY
Truth table0%0/3
A // B
A= $newverB= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 20 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | sub format_json { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_json: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | # tier-selection is passed as an optional trailing hashref so the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | # existing (if unused internally) seed-list calling form -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | # format_json(@preexisting_requirements) -- keeps working unchanged. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | my %tier_options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | ▶ | if ( @args && ref $args[-1] eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@args and ref $args[-1] eq "HASH"
MC/DC0%0/2
@args and ref $args[-1] eq "HASH"
@args
ref $args[-1] eq "HASH"
Truth table0%0/3
A and B
A= @argsB= ref $args[-1] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | %tier_options = %{ pop @args }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | my @requirements = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | ▶ | my $tier = $tier_options{tier} // 'require'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$tier_options{"tier"} // "require"
MC/DC0%0/1
$tier_options{"tier"} // "require"
$tier_options{"tier"}
Truth table0%0/2
A
A= $tier_options{"tier"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | my $tier_getter = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | require => 'get_require', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | recommends => 'get_recommends', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | suggests => 'get_suggests', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | ▶ | }->{$tier} // 'get_require'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
{"require", "get_require", "recommends", "get_recommends", "suggests", "get_suggests"}->{$tier} // "get_require"
MC/DC0%0/1
{"require", "get_require", "recommends", "get_recommends", "suggests", "get_suggests"}->{$tier} // "get_require"
{"require", "get_require", "recommends", "get_recommends", "suggests", "get_suggests"}->{$tier}
Truth table0%0/2
A
A= {"require", "get_require", "recommends", "get_recommends", "suggests", "get_suggests"}->{$tier}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | my %perlreq = %{ $self->get_perlreq }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | my %requires = %{ $self->$tier_getter }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | # a minimum Perl version requirement is always foundational, not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # tier-specific -- only attach it to the require tier's output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | if ( $tier eq 'require' && exists $perlreq{'perl'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$tier eq "require" and exists $perlreq{"perl"}
MC/DC0%0/2
$tier eq "require" and exists $perlreq{"perl"}
$tier eq "require"
exists $perlreq{"perl"}
Truth table0%0/3
A and B
A= $tier eq "require"B= exists $perlreq{"perl"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | my $perl_version = $perlreq{'perl'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | if ( !$perl_version && $self->get_add_version ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $perl_version and $self->get_add_version
MC/DC0%0/2
not $perl_version and $self->get_add_version
not $perl_version
$self->get_add_version
Truth table0%0/3
not(A) and B
A= not $perl_versionB= $self->get_add_version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | $perl_version = $PERL_VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | push @requirements, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$perl_version // $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$perl_version // $Module::ScanDeps::Static::EMPTY
$perl_version
$Module::ScanDeps::Static::EMPTY
Truth table0%0/3
A // B
A= $perl_versionB= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | name => 'perl', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | version => $perl_version // $EMPTY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | foreach my $m ( sort keys %requires ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | ▶ | next if !$self->get_core && $self->is_core($m); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->get_core and $self->is_core($m)
MC/DC0%0/2
not $self->get_core and $self->is_core($m)
not $self->get_core
$self->is_core($m)
Truth table0%0/3
not(A) and B
A= not $self->get_coreB= $self->is_core($m)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | ▶ | next if $self->get_filter && exists $self->get_packages->{$m}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->get_filter and exists $self->get_packages->{$m}
MC/DC0%0/2
$self->get_filter and exists $self->get_packages->{$m}
$self->get_filter
exists $self->get_packages->{$m}
Truth table0%0/3
A and B
A= $self->get_filterB= exists $self->get_packages->{$m}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | push @requirements, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | name => $m, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | version => $requires{$m} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | my $json = JSON->new->pretty; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | ▶ | return wantarray ? @requirements : $json->encode( \@requirements ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | sub get_dependencies { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_dependencies: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | my ( $self, %options ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | ▶ | my $format = $options{format} // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$options{"format"} // $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$options{"format"} // $Module::ScanDeps::Static::EMPTY
$options{"format"}
$Module::ScanDeps::Static::EMPTY
Truth table0%0/3
A // B
A= $options{"format"}B= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | ▶ | my $tier = $options{tier} // 'require'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options{"tier"} // "require"
MC/DC0%0/1
$options{"tier"} // "require"
$options{"tier"}
Truth table0%0/2
A
A= $options{"tier"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | if ( ( $options{format} && $options{format} eq 'json' ) || $self->get_json ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
$options{"format"} and $options{"format"} eq "json" or $self->get_json
$options{"format"} and $options{"format"} eq "json"
MC/DC0%0/3
$options{"format"} and $options{"format"} eq "json" or $self->get_json
$options{"format"}
$options{"format"} eq "json"
$self->get_json
Truth table0%0/5
A and B or C
A= $options{"format"}B= $options{"format"} eq "json"C= $self->get_json
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | return scalar $self->format_json( { tier => $tier } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | ▶ | elsif ( ( $options{format} && $options{format} eq 'text' ) || $self->get_text || $self->get_raw ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$options{"format"} and $options{"format"} eq "text" or $self->get_text or $self->get_raw
$options{"format"} and $options{"format"} eq "text" or $self->get_text
$options{"format"} and $options{"format"} eq "text"
MC/DC0%0/4
$options{"format"} and $options{"format"} eq "text" or $self->get_text or $self->get_raw
$options{"format"}
$options{"format"} eq "text"
$self->get_text
$self->get_raw
Truth table0%0/7
A and B or C or D
A= $options{"format"}B= $options{"format"} eq "text"C= $self->get_textD= $self->get_raw
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | return $self->format_text( tier => $tier ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | return $self->format_json( { tier => $tier } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | sub format_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_text: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | my ( $self, %options ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | ▶ | my $tier = $options{tier} // 'require'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options{"tier"} // "require"
MC/DC0%0/1
$options{"tier"} // "require"
$options{"tier"}
Truth table0%0/2
A
A= $options{"tier"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | my @requirements = $self->format_json( { tier => $tier } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 0 | ▶ | return if !@requirements; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | my $str = $EMPTY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | my $max_len = 2 + max map { length $_->{'name'} } @requirements; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | my @output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | foreach my $module (@requirements) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | my ( $name, $version ) = @{$module}{qw{ name version }}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | my $separator = $self->get_separator; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | my $format = "%-${max_len}s%s'%s',"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | ▶ | if ( $self->get_raw ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | $separator = $SPACE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | $format = "%-${max_len}s%s%s"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | $name = "'$name'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | ▶ | $separator //= $SPACE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$separator //= $Module::ScanDeps::Static::SPACE
MC/DC0%0/2
$separator //= $Module::ScanDeps::Static::SPACE
$separator
$Module::ScanDeps::Static::SPACE
Truth table0%0/3
A //= B
A= $separatorB= $Module::ScanDeps::Static::SPACE
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | ▶ | push @output, sprintf $format, $name, $separator, $version // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$version // $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$version // $Module::ScanDeps::Static::EMPTY
$version
$Module::ScanDeps::Static::EMPTY
Truth table0%0/3
A // B
A= $versionB= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | return join "\n", @output, $EMPTY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | ▶ | sub to_rpm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_rpm: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | my @rpm_deps = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | foreach my $perlver ( sort values %{ $self->get_perlreq } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | push @rpm_deps, "perl >= $perlver"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | my %require = %{ $self->get_require }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | foreach my $module ( sort keys %require ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | next if !$self->get_core && $self->is_core($module); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->get_core and $self->is_core($module)
MC/DC0%0/2
not $self->get_core and $self->is_core($module)
not $self->get_core
$self->is_core($module)
Truth table0%0/3
not(A) and B
A= not $self->get_coreB= $self->is_core($module)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | ▶ | if ( !$require{$module} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | my $m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | ▶ | if ( $self->get_add_version ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | $m = $self->get_module_version($module); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | if ( $m->{'version'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | $require{$module} = $m->{'version'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | push @rpm_deps, "perl($module) >= $m->{'version'}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | ▶ | if ( !$m || !$m->{'version'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$m and $m->{"version"}
MC/DC0%0/2
$m and $m->{"version"}
$m
$m->{"version"}
Truth table0%0/3
A and B
A= $mB= $m->{"version"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | push @rpm_deps, "perl($module)"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | push @rpm_deps, "perl($module) >= $require{$module}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | return join "\n", @rpm_deps, $EMPTY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 36 | ▶ | sub _extra_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extra_options: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 36 | return [qw(perlreq require recommends suggests handle files packages logger)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 36 | ▶ | sub _option_specs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_option_specs: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 36 | qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | add-version|a! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | core|c! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | help|h | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | include-require|i! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | json|j | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | log-level|l=s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | min-core-version|m=s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | raw|r | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | recommend-require|R! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | eval-recommends! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | separator|s=s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | text|t | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | version|v | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | path|p=s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | file-list|L=s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | requires-file=s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | recommends-file=s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | suggests-file=s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | cpanfile-file=s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | filter|f! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 19 | ▶ | sub _default_options { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_options: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 19 | add_version => $TRUE, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | core => $TRUE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | include_require => $TRUE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | json => $FALSE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | min_core_version => '5.8.9', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | recommend_require => $FALSE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | eval_recommends => $FALSE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | separator => q{ => }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | text => $TRUE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 17 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=15 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 17 | my ( $class, $options ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | # extra_options (perlreq, require, handle, files) are accessor-only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | # fields -- CLI::Simple creates get_X/set_X for them but never | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | # populates them via GetOptions, since they aren't part of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | # option_specs at all (and in handle's case, can't be: a filehandle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | # reference isn't representable as a command-line string). Pull | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | # these out before building @argv and set them directly on the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | # constructed object instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 17 | my %is_extra = map { $_ => 1 } @{ _extra_options() }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 17 | my %extra_values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | my %cli_values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 17 | foreach my $o ( keys %{$options} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 50 | ▶ | if ( $is_extra{$o} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | 12 | $extra_values{$o} = $options->{$o}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 38 | $cli_values{$o} = $options->{$o}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | # classify each known option_spec as negatable ('!'), plain boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | # (no type suffix at all -- presence-only, no --no-X form), or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | # value-taking ('=s' etc.), so the hashref -> @ARGV translation below | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | # can represent each key correctly instead of treating them all the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | # same way. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 17 | my %spec_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 17 | foreach my $spec ( @{ _option_specs() } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 340 | my ($name) = split /[^\w-]/xsm, $spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 340 | ▶ | if ( $spec =~ /[!]\z/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 102 | $spec_type{$name} = 'negatable'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | elsif ( $spec =~ /[=:]/xsm ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 153 | $spec_type{$name} = 'value'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 85 | $spec_type{$name} = 'boolean'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 17 | my @argv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 17 | foreach my $o ( keys %cli_values ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 38 | ( my $dashed = $o ) =~ s/_/-/gxsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 38 | ▶ | my $arg_name = length $dashed == 1 ? "-$dashed" : "--$dashed"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 38 | my $type = $spec_type{$dashed}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 38 | ▶ | if ( !defined $type ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | # unrecognized key that isn't an extra_options field either -- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | # not something we know how to represent; pass through as-is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | # and let GetOptions report the error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 0 | push @argv, ( $arg_name => $cli_values{$o} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | elsif ( $type eq 'negatable' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 27 | ▶ | push @argv, $cli_values{$o} ? $arg_name : "--no-$dashed"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | elsif ( $type eq 'boolean' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | # no negated form exists for these -- omit entirely when false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | # rather than emitting a flag GetOptions won't recognize. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 2 | ▶ | push @argv, $arg_name if $cli_values{$o}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | elsif ( defined $cli_values{$o} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 9 | push @argv, ( $arg_name => $cli_values{$o} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | push @argv, $arg_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 17 | local @ARGV = @argv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | 17 | my $self = __PACKAGE__->main($TRUE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 17 | foreach my $k ( keys %extra_values ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | 12 | my $setter = "set_$k"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | 12 | $self->$setter( $extra_values{$k} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 17 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 19 | ▶ | sub main { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
main: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 19 | my ( $class, $setup ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 19 | my $cli = __PACKAGE__->SUPER::new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | commands => { scan => \&cmd_scan }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | option_specs => _option_specs(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | default_options => _default_options(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | extra_options => _extra_options(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | validate_command => $FALSE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 19 | ▶ | return $setup ? $cli : return $cli->run; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 19 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=7 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 19 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 19 | my @args = $self->get_args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 19 | ▶ | if ( !@args ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 19 | $self->command_args( $self->command() ); # set the args to the command | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 19 | $self->command('scan'); # set the command to your default | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | die "ERROR: unknown command\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | ▶ | if !$self->commands->{ $self->command }; # validate the command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 19 | my @file_list = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 19 | ▶ | if ( my $file_list = $self->get_file_list ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | my $list = slurp($file_list); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 0 | $self->set_json($FALSE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | return split /\n/xsm, $list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 19 | ▶ | return $self->get_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | if $self->get_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 13 | return $self->get_args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 19 | $self->set_files( \@file_list ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | # --filter has no context-independent right answer: for a single | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | # file there's no sibling in the batch to worry about, but for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | # --file-list, a same-batch sibling should never count as an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | # external dependency of another file in the same batch. Default it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | # accordingly, but only when the user hasn't explicitly set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | # --filter/--no-filter themselves - that always wins regardless of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | # context. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 19 | ▶ | if ( !defined $self->get_filter ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 19 | ▶ | $self->set_filter( $self->get_file_list ? $TRUE : $FALSE ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 19 | $self->set_perlreq( {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 19 | $self->set_require( {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 19 | $self->set_recommends( {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 19 | $self->set_suggests( {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 19 | $self->set_packages( {} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 19 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 0 | ▶ | sub logger { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logger: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | my ( $self, $level, $message, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | my $logger = $self->get_logger; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | ▶ | if (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | $message = sprintf $message, @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | ▶ | if ( !$logger ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | # we only support 'info' & 'debug' so this should work... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | ▶ | if !$self->get_log_level || $level ne $self->get_log_level; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->get_log_level or $level ne $self->get_log_level
MC/DC0%0/2
not $self->get_log_level or $level ne $self->get_log_level
not $self->get_log_level
$level ne $self->get_log_level
Truth table0%0/3
not(A) or B
A= not $self->get_log_levelB= $level ne $self->get_log_level
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | print {*STDERR} "$message\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | $logger->$level($message); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 0 | ▶ | sub cmd_scan { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_scan: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | foreach my $file ( @{ $self->get_files } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | $self->logger( info => 'scanning: %s', $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | $self->set_path($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | $self->parse; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 0 | $self->warn_tier_conflicts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | ▶ | if ( $self->get_json ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | print {*STDOUT} $self->get_dependencies( format => 'json' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | print {*STDOUT} $self->get_dependencies( format => 'text' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | # --file-list scans multiple files by reusing the same object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | # across the loop above (parse() never resets require/recommends/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | # suggests -- only init() does, once, at construction) -- so by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | # this point these three hashes already hold the union across every | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | # file scanned, single file or not. Each of these is independent of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | # --json/--text/--raw: always written as plain text (module => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | # version), same shape "make requires" already expects. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | $self->_write_tier_file( 'requires-file', 'require' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | $self->_write_tier_file( 'recommends-file', 'recommends' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 0 | $self->_write_tier_file( 'suggests-file', 'suggests' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | $self->_write_cpanfile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 0 | return $SUCCESS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 0 | ▶ | sub warn_tier_conflicts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
warn_tier_conflicts: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | # a module can legitimately be a hard requirement in one file and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | # eval-wrapped/conditional in another -- both facts can be true at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | # once. But the aggregate is a real contradiction worth surfacing: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | # if it's required anywhere, listing it again as merely recommended | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | # or suggested is misleading, and papering over that by silently | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | # picking a winner would hide a signal the developer should act on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | # (either the softer usage no longer needs to hedge, since the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | # module is guaranteed to be present anyway, or the hard requirement | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | # should really be conditional too). This only warns -- it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | # deliberately does not alter require/recommends/suggests, since | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | # resolving the contradiction belongs in the source, not here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | my $require = $self->get_require; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 0 | my $recommends = $self->get_recommends; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 0 | my $suggests = $self->get_suggests; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | 0 | foreach my $m ( sort keys %{$recommends} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 0 | ▶ | next if !exists $require->{$m}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 0 | warn "WARNING: '$m' is both a hard requirement and listed in recommends -- pick one\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 0 | foreach my $m ( sort keys %{$suggests} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 0 | ▶ | if ( exists $require->{$m} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 0 | warn "WARNING: '$m' is both a hard requirement and listed in suggests -- pick one\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | elsif ( exists $recommends->{$m} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 0 | warn "WARNING: '$m' is listed in both recommends and suggests -- pick one\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | 0 | ▶ | sub _write_tier_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_tier_file: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 0 | my ( $self, $option_name, $tier ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 0 | ( my $getter = $option_name ) =~ s/-/_/gxsm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 0 | $getter = "get_$getter"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | 0 | my $path = $self->$getter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 0 | ▶ | return if !$path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 0 | ▶ | my $text = $self->format_text( tier => $tier ) // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->format_text("tier", $tier) // $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$self->format_text("tier", $tier) // $Module::ScanDeps::Static::EMPTY
$self->format_text("tier", $tier)
$Module::ScanDeps::Static::EMPTY
Truth table0%0/3
A // B
A= $self->format_text("tier", $tier)B= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | 0 | ▶ | open my $fh, '>', $path ## no critic (InputOutput::RequireBriefOpen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | or croak "could not open '$path' for writing: $OS_ERROR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | 0 | print {$fh} $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 0 | ▶ | sub _write_cpanfile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_cpanfile: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | my $path = $self->get_cpanfile_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | ▶ | return if !$path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 0 | ▶ | my $text = $self->format_cpanfile // $EMPTY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->format_cpanfile // $Module::ScanDeps::Static::EMPTY
MC/DC0%0/2
$self->format_cpanfile // $Module::ScanDeps::Static::EMPTY
$self->format_cpanfile
$Module::ScanDeps::Static::EMPTY
Truth table0%0/3
A // B
A= $self->format_cpanfileB= $Module::ScanDeps::Static::EMPTY
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 0 | ▶ | open my $fh, '>', $path ## no critic (InputOutput::RequireBriefOpen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | or croak "could not open '$path' for writing: $OS_ERROR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | 0 | print {$fh} $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 0 | ▶ | sub format_cpanfile { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_cpanfile: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | # deliberately reuses format_json's per-tier filtering (core, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | # --filter, and the synthetic "perl" minimum-version entry, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | # cpanfile's own DSL represents identically to any other module | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | # requirement: requires 'perl', 'X.YZ';) rather than duplicating | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | # that logic here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | 0 | my %keyword_for_tier = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | require => 'requires', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | recommends => 'recommends', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | suggests => 'suggests', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 0 | my @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 0 | foreach my $tier (qw(require recommends suggests)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 0 | my $keyword = $keyword_for_tier{$tier}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 0 | my @requirements = $self->format_json( { tier => $tier } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 0 | foreach my $r (@requirements) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 0 | ▶ | if ( $r->{version} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | push @lines, sprintf "%s '%s', '%s';\n", $keyword, $r->{name}, $r->{version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | 0 | push @lines, sprintf "%s '%s';\n", $keyword, $r->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | return join $EMPTY, @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||