CPAN/Maker/Bootstrapper/Role/Init.pm

filter: Statementstmt 42.4% 28 / 66 Branchbran 0.0% 0 / 38 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 1 totaltotal 26.6% 37 / 139 CC 25 SCAR 52.6
CC
25
Cov
24%
_init_config
342.0
init
72.0
BEGIN
1.0
CRAP 192.6
« CPAN/Maker/Bootstrapper/Role/LLM/ReleaseNotes.pm ↑ Summary CPAN/Maker/Bootstrapper/Role/ShowDefaults.pm »
1 package CPAN::Maker::Bootstrapper::Role::Init;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use CLI::Simple::Constants qw(:booleans);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use CPAN::Maker::Bootstrapper::Constants qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Cwd qw(abs_path getcwd);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use English qw(-no_match_vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use File::ShareDir qw(dist_dir);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 ########################################################################
16 0 ▶sub init {
Subroutine init: not called CC=8 SCAR=42.8
Pod undocumented
17 ########################################################################
18 0 my ($self) = @_;
19  
20 0 my ($dist) = split /[.]/xsm, 'CPAN::Maker::Bootstrapper';
21 0 $dist =~ s/::/-/xmsg;
22  
23 0 $self->set_dist_dir( dist_dir($dist) );
24  
25 0 $self->_init_config;
26  
27 0 my $basedir = $self->get_basedir;
28  
29 0 ▶ die sprintf "ERROR: basedir [%s] is not a directory\n", $basedir
Branch: 1 branch
BranchTrueFalseTotal
if $basedir and not -d $basedir 0 0 0
Condition0%0/3
$basedir and not -d $basedir
!ll&&!rl&&r
000
MC/DC0%0/2
$basedir and not -d $basedir
$basedir not -d $basedir
Truth table0%0/3
A and not(B)
A= $basedirB= not -d $basedir
ABresult
0X0
100
111
30 if $basedir && !-d $basedir;
31  
32 0 ▶ $basedir //= abs_path(getcwd);
Condition0%0/3
$basedir //= abs_path(getcwd())
l!l&&r!l&&!r
000
MC/DC0%0/2
$basedir //= abs_path(getcwd())
$basedir abs_path(getcwd())
Truth table0%0/3
A //= B
A= $basedirB= abs_path(getcwd())
ABresult
1X1
011
000
33 0 $self->set_basedir( abs_path($basedir) );
34  
35 0 ▶ my $importdir = $self->get_import // [];
Condition0%0/2
$self->get_import // []
l!l
00
MC/DC0%0/1
$self->get_import // []
$self->get_import
Truth table0%0/2
A
A= $self->get_import
Aresult
11
00
36 0 $self->set_import($importdir);
37  
38 0 ▶ $self->set_max_diff_files( $self->get_max_diff_files // $MAX_DIFF_FILES );
Condition0%0/3
$self->get_max_diff_files // $CPAN::Maker::Bootstrapper::Role::Init::MAX_DIFF_FILES
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->get_max_diff_files // $CPAN::Maker::Bootstrapper::Role::Init::MAX_DIFF_FILES
$self->get_max_diff_files $CPAN::Maker::Bootstrapper::Role::Init::MAX_DIFF_FILES
Truth table0%0/3
A // B
A= $self->get_max_diff_filesB= $CPAN::Maker::Bootstrapper::Role::Init::MAX_DIFF_FILES
ABresult
1X1
011
000
39  
40 0 ▶ if ( $self->get_color ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->get_color) 0 0 0
41 0 my $color = eval {
42 0 require Term::ANSIColor;
43 0 Term::ANSIColor->import('colored');
44 0 return $TRUE;
45 };
46  
47 0 $self->set_color($color);
48 }
49  
50 0 ▶ if ( !defined $self->get_max_tokens ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->get_max_tokens) 0 0 0
51 0 $self->set_max_tokens($MAX_TOKENS);
52 }
53  
54 0 return;
55 }
56  
57 ########################################################################
58 0 ▶sub _init_config {
Subroutine _init_config: not called CC=18 SCAR=58.3
59 ########################################################################
60 0 my ($self) = @_;
61  
62 0 require CPAN::Maker::Bootstrapper::ConfigReader;
63  
64 # Example usage:
65 0 my $reader = eval { CPAN::Maker::Bootstrapper::ConfigReader->new( $self->get_config ); };
66 0 $self->set_reader($reader);
67  
68 0 ▶ $self->set_config( $reader ? $reader->get_config_file : undef );
Branch: 1 branch
BranchTrueFalseTotal
$reader ? : 0 0 0
69  
70 0 ▶ if ( $EVAL_ERROR && $self->get_config ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CPAN::Maker::Bootstrapper::Role::Init::EVAL_ERROR and $self->get_config) 0 0 0
Condition0%0/3
$CPAN::Maker::Bootstrapper::Role::Init::EVAL_ERROR and $self->get_config
!ll&&!rl&&r
000
MC/DC0%0/2
$CPAN::Maker::Bootstrapper::Role::Init::EVAL_ERROR and $self->get_config
$CPAN::Maker::Bootstrapper::Role::Init::EVAL_ERROR $self->get_config
Truth table0%0/3
A and B
A= $CPAN::Maker::Bootstrapper::Role::Init::EVAL_ERRORB= $self->get_config
ABresult
0X0
100
111
71 0 warn "WARNING: could not load config file: $EVAL_ERROR Using defaults.\n";
72 }
73  
74 { # the one legit and allowable use of postfix if!
75 ## no critic (ProhibitPostfixControls)
76 0 ▶ $self->set_username( $reader ? $reader->user_name : q{} )
Branch: 2 branches
BranchTrueFalseTotal
unless $self->get_username 0 0 0
$reader ? : 0 0 0
77 if !$self->get_username;
78  
79 0 ▶ $self->set_email( $reader ? $reader->user_email : q{} )
Branch: 2 branches
BranchTrueFalseTotal
unless $self->get_email 0 0 0
$reader ? : 0 0 0
80 if !$self->get_email;
81  
82 0 ▶ $self->set_github_user( $reader ? $reader->user_github : q{} )
Branch: 2 branches
BranchTrueFalseTotal
unless $self->get_github_user 0 0 0
$reader ? : 0 0 0
83 if !$self->get_github_user;
84  
85 0 ▶ $self->set_resources( $reader ? $reader->cpan_maker_resources : undef )
Branch: 2 branches
BranchTrueFalseTotal
unless $self->get_resources 0 0 0
$reader ? : 0 0 0
86 if !$self->get_resources;
87  
88 0 ▶ $self->set_basedir( $reader ? $reader->cpan_maker_basedir : undef )
Branch: 2 branches
BranchTrueFalseTotal
unless $self->get_basedir 0 0 0
$reader ? : 0 0 0
89 if !$self->get_basedir;
90  
91 0 ▶ $self->set_llm_api_key_helper( $reader ? $reader->cpan_maker_llm_api_key_helper : undef )
Branch: 2 branches
BranchTrueFalseTotal
unless $self->get_llm_api_key_helper 0 0 0
$reader ? : 0 0 0
92 if !$self->get_llm_api_key_helper;
93  
94 0 ▶ $self->set_max_tokens( $reader ? $reader->cpan_maker_max_tokens : undef )
Branch: 2 branches
BranchTrueFalseTotal
unless $self->get_max_tokens 0 0 0
$reader ? : 0 0 0
95 if !$self->get_max_tokens;
96 }
97  
98 0 return;
99 }
100  
101 1 1;
102  
103 __END__
« CPAN/Maker/Bootstrapper/Role/LLM/ReleaseNotes.pm ↑ Summary CPAN/Maker/Bootstrapper/Role/ShowDefaults.pm »