| 1 | 2 | ▶ | use v5.38; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use builtin qw( true false ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | no warnings qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | experimental::class | ||||||||||||||||||||||||||||
| 6 | experimental::builtin | ||||||||||||||||||||||||||||
| 7 | experimental::for_list | ||||||||||||||||||||||||||||
| 8 | 2 | ); | |||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Module::Load (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Getopt::Long (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | class CPANSEC::Admin::Command { | |||||||||||||||||||||||||||
| 13 | 2 | field %dispatcher; | |||||||||||||||||||||||||||
| 14 | 2 | field $config :param = {}; | |||||||||||||||||||||||||||
| 15 | 2 | field $verbosity = 1; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 0 | ▶ | method dispatcher { %dispatcher } | ||||||||||||||||||||||||||
|
Subroutine
dispatcher: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 18 | 0 | ▶ | method config { $config } | ||||||||||||||||||||||||||
|
Subroutine
config: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | method load ($name) { | ||||||||||||||||||||||||||
|
Subroutine
load: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 21 | 0 | my $pkg = 'CPANSEC::Admin::Command::' . $name; | |||||||||||||||||||||||||||
| 22 | 0 | Module::Load::load($pkg); | |||||||||||||||||||||||||||
| 23 | 0 | my $obj = $pkg->new; | |||||||||||||||||||||||||||
| 24 | 0 | $dispatcher{ $obj->name } = $obj; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | method run (@args) { | ||||||||||||||||||||||||||
|
Subroutine
run: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 28 | 0 | my $quiet; | |||||||||||||||||||||||||||
| 29 | my $show_version; | ||||||||||||||||||||||||||||
| 30 | 0 | my $getopt = Getopt::Long::Parser->new( config => ['pass_through'] ); | |||||||||||||||||||||||||||
| 31 | 0 | $getopt->getoptionsfromarray(\@args, 'quiet' => \$quiet, 'version' => \$show_version ); | |||||||||||||||||||||||||||
| 32 | 0 | ▶ | if ($show_version) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | 0 | say "cpansec-admin $CPANSEC::Admin::VERSION ($0)"; | |||||||||||||||||||||||||||
| 34 | 0 | return true; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 0 | my ($cmd_name, @cmd_args) = @args; | |||||||||||||||||||||||||||
| 37 | 0 | ▶ | return false unless defined $cmd_name && exists $dispatcher{$cmd_name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $cmd_name and exists $dispatcher{$cmd_name}
MC/DC0%0/2
defined $cmd_name and exists $dispatcher{$cmd_name}
defined $cmd_name
exists $dispatcher{$cmd_name}
Truth table0%0/3
A and B
A= defined $cmd_nameB= exists $dispatcher{$cmd_name}
| |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $verbosity = 0 if $quiet; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 0 | $dispatcher{$cmd_name}->command($self, @cmd_args); | |||||||||||||||||||||||||||
| 40 | 0 | return true; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 2 | ▶ | method get_options ($args, $opts) { | ||||||||||||||||||||||||||
|
Subroutine
get_options: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 44 | 2 | my (%parsed, %defaults, %output); | |||||||||||||||||||||||||||
| 45 | 2 | %defaults = (%$config); | |||||||||||||||||||||||||||
| 46 | 2 | foreach my ($k, $v) (%$opts) { | |||||||||||||||||||||||||||
| 47 | 6 | my $parsed_k = $k =~ s/\-/_/gr; | |||||||||||||||||||||||||||
| 48 | 6 | $parsed_k =~ s/\=.\z//; | |||||||||||||||||||||||||||
| 49 | 6 | $parsed{$k} = \$output{$parsed_k}; | |||||||||||||||||||||||||||
| 50 | 6 | ▶ | $defaults{$parsed_k} = $opts->{$k} if $opts->{$k}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | 2 | Getopt::Long::Parser->new->getoptionsfromarray($args, %parsed); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 2 | foreach my $k (keys %defaults) { | |||||||||||||||||||||||||||
| 55 | 5 | ▶ | if (!defined $output{$k}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 4 | my $default_value = $defaults{$k}; | |||||||||||||||||||||||||||
| 57 | 4 | foreach my $to_replace ($default_value =~ /\{(.+?)\}/g) { | |||||||||||||||||||||||||||
| 58 | 1 | ▶ | my $replacement = $output{$to_replace} // $defaults{$to_replace}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$output{$to_replace} // $defaults{$to_replace}
MC/DC0%0/2
$output{$to_replace} // $defaults{$to_replace}
$output{$to_replace}
$defaults{$to_replace}
Truth table33%1/3
A // B
A= $output{$to_replace}B= $defaults{$to_replace}
| |||||||||||||||||||||||||||||
| 59 | 1 | ▶ | if ($replacement) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 1 | $default_value =~ s/\{$to_replace\}/$replacement/ge; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | 4 | $output{$k} = $default_value; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 2 | return %output; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | method info ($msg) { say '[+] ' . $msg if $verbosity > 0 } | ||||||||||||||||||||||||||
|
Subroutine
info: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||