blib/lib/CPAN/Exception/RecursiveDependency.pm

filter: Statementstmt 32.3% 44 / 136 Branchbran 16.6% 8 / 48 Conditioncond 13.8% 5 / 36 MC/DCmcdc 0.0% 0 / 20 Subroutinesub 58.3% 7 / 12 Podpod 0.0% 0 / 6 totaltotal 24.8% 64 / 258 CC 41 SCAR 52.9
CC
41
Cov
26%
new
257.9
new
257.9
as_string
2.5
CRAP 198.8
« blib/lib/CPAN/Plugin/Specfile.pm ↑ Summary blib/lib/CPAN/Mirrors.pm »
1 # -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*-
2 # vim: ts=4 sts=4 sw=4:
3 package CPAN::Exception::RecursiveDependency;
4 26 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 26 ▶use overload '""' => "as_string";
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 26 ▶use vars qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
8 $VERSION
9 26 );
10 26 $VERSION = "5.5001";
11  
12 {
13 package CPAN::Exception::RecursiveDependency::na;
14 26 ▶ use overload '""' => "as_string";
Subroutine BEGIN: called CC=1 SCAR=0.0
15 26 ▶ sub new { bless {}, shift };
Subroutine new: called CC=1 SCAR=0.0
16 0 ▶ sub as_string { "N/A" };
Subroutine as_string: not called CC=1 SCAR=6.9
17 }
18  
19 26 my $NA = CPAN::Exception::RecursiveDependency::na->new;
20  
21 # a module sees its distribution (no version)
22 # a distribution sees its prereqs (which are module names) (usually with versions)
23 # a bundle sees its module names and/or its distributions (no version)
24  
25 2 ▶sub new {
Subroutine new: called CC=20 SCAR=55.5
Pod undocumented
26 0 ▶ my($class) = shift;
Subroutine new: not called CC=20 SCAR=55.5
Pod undocumented
27 0 my($deps_arg) = shift;
28 0 my (@deps,%seen,$loop_starts_with);
29 0 DCHAIN: for my $dep (@$deps_arg) {
30 0 push @deps, {name => $dep, display_as => $dep};
31 0 ▶ if ($seen{$dep}++) {
Branch: 2 branches
BranchTrueFalseTotal
if ($seen{$dep}++) 1 6 7
if ($seen{$dep}++) 0 0 0
32 0 $loop_starts_with = $dep;
33 0 last DCHAIN;
34 }
35 }
36 0 my $in_loop = 0;
37 0 my %mark;
38 0 DWALK: for my $i (0..$#deps) {
39 0 my $x = $deps[$i]{name};
40 0 ▶ $in_loop ||= $loop_starts_with && $x eq $loop_starts_with;
Condition41%5/12
$in_loop ||= $loop_starts_with && $x eq $loop_starts_with
l!l&&r!l&&!r
313
$loop_starts_with && $x eq $loop_starts_with
!ll&&!rl&&r
301
$in_loop ||= $loop_starts_with && $x eq $loop_starts_with
l!l&&r!l&&!r
000
$loop_starts_with && $x eq $loop_starts_with
!ll&&!rl&&r
000
MC/DC0%0/3
$in_loop ||= $loop_starts_with && $x eq $loop_starts_with
$in_loop $loop_starts_with $x eq $loop_starts_with
MC/DC0%0/3
$in_loop ||= $loop_starts_with && $x eq $loop_starts_with
$in_loop $loop_starts_with $x eq $loop_starts_with
Truth table0%0/4
A ||= B && C
A= $in_loopB= $loop_starts_withC= $x eq $loop_starts_with
ABCresult
1XX1
0111
00X0
0100
Truth table0%0/4
A ||= B && C
A= $in_loopB= $loop_starts_withC= $x eq $loop_starts_with
ABCresult
1XX1
0111
00X0
0100
41 0 ▶ my $xo = CPAN::Shell->expandany($x) or next;
Branch: 2 branches
BranchTrueFalseTotal
my $xo = "CPAN::Shell"->expandany($x) or next 0 7 7
my $xo = "CPAN::Shell"->expandany($x) or next 0 0 0
42 0 ▶ if ($xo->isa("CPAN::Module")) {
Branch: 4 branches
BranchTrueFalseTotal
if ($xo->isa('CPAN::Module')) { } 0 0 0
elsif ($xo->isa('CPAN::Distribution')) { } 0 0 0
if ($xo->isa('CPAN::Module')) { } 0 0 0
elsif ($xo->isa('CPAN::Distribution')) { } 0 0 0
43 0 ▶ my $have = $xo->inst_version || $NA;
Condition0%0/6
$xo->inst_version || $NA
l!l&&r!l&&!r
000
$xo->inst_version || $NA
l!l&&r!l&&!r
000
MC/DC0%0/2
$xo->inst_version || $NA
$xo->inst_version $NA
MC/DC0%0/2
$xo->inst_version || $NA
$xo->inst_version $NA
Truth table0%0/3
A || B
A= $xo->inst_versionB= $NA
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $xo->inst_versionB= $NA
ABresult
1X1
011
000
44 0 my($want,$d,$want_type);
45 0 ▶ if ($i>0 and $d = $deps[$i-1]{name}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($i > 0 and $d = $deps[$i - 1]{'name'}) { } 0 0 0
if ($i > 0 and $d = $deps[$i - 1]{'name'}) { } 0 0 0
Condition0%0/6
$i > 0 and $d = $deps[$i - 1]{"name"}
!ll&&!rl&&r
000
$i > 0 and $d = $deps[$i - 1]{"name"}
!ll&&!rl&&r
000
MC/DC0%0/2
$i > 0 and $d = $deps[$i - 1]{"name"}
$i > 0 $d = $deps[$i - 1]{"name"}
MC/DC0%0/2
$i > 0 and $d = $deps[$i - 1]{"name"}
$i > 0 $d = $deps[$i - 1]{"name"}
Truth table0%0/3
A and B
A= $i > 0B= $d = $deps[$i - 1]{"name"}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $i > 0B= $d = $deps[$i - 1]{"name"}
ABresult
0X0
100
111
46 0 my $do = CPAN::Shell->expandany($d);
47 0 $want = $do->{prereq_pm}{requires}{$x};
48 0 ▶ if (defined $want) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $want) { } 0 0 0
if (defined $want) { } 0 0 0
49 0 $want_type = "requires: ";
50 } else {
51 0 $want = $do->{prereq_pm}{build_requires}{$x};
52 0 ▶ if (defined $want) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $want) { } 0 0 0
if (defined $want) { } 0 0 0
53 0 $want_type = "build_requires: ";
54 } else {
55 0 $want_type = "unknown status";
56 0 $want = "???";
57 }
58 }
59 } else {
60 0 $want = $xo->cpan_version;
61 0 $want_type = "want: ";
62 }
63 0 $deps[$i]{have} = $have;
64 0 $deps[$i]{want_type} = $want_type;
65 0 $deps[$i]{want} = $want;
66 0 $deps[$i]{display_as} = "$x (have: $have; $want_type$want)";
67 0 ▶ if ((! ref $have || !$have->isa('CPAN::Exception::RecursiveDependency::na'))
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $have && $have->isa("CPAN::Exception::RecursiveDependency::na") and "CPAN::Version"->vge($have, $want)) 0 0 0
if (not ref $have && $have->isa("CPAN::Exception::RecursiveDependency::na") and "CPAN::Version"->vge($have, $want)) 0 0 0
Condition0%0/12
not ref $have && $have->isa("CPAN::Exception::RecursiveDependency::na") and "CPAN::Version"->vge($have, $want)
!ll&&!rl&&r
000
ref $have && $have->isa('CPAN::Exception::RecursiveDependency::na')
!ll&&!rl&&r
000
not ref $have && $have->isa("CPAN::Exception::RecursiveDependency::na") and "CPAN::Version"->vge($have, $want)
!ll&&!rl&&r
000
ref $have && $have->isa('CPAN::Exception::RecursiveDependency::na')
!ll&&!rl&&r
000
MC/DC0%0/3
not ref $have && $have->isa("CPAN::Exception::RecursiveDependency::na") and "CPAN::Version"->vge($have, $want)
ref $have $have->isa('CPAN::Exception::RecursiveDependency::na') "CPAN::Version"->vge($have, $want)
MC/DC0%0/3
not ref $have && $have->isa("CPAN::Exception::RecursiveDependency::na") and "CPAN::Version"->vge($have, $want)
ref $have $have->isa('CPAN::Exception::RecursiveDependency::na') "CPAN::Version"->vge($have, $want)
Truth table0%0/5
not(A && B) and C
A= ref $haveB= $have->isa('CPAN::Exception::RecursiveDependency::na')C= "CPAN::Version"->vge($have, $want)
ABCresult
11X0
0X00
1000
0X11
1011
Truth table0%0/5
not(A && B) and C
A= ref $haveB= $have->isa('CPAN::Exception::RecursiveDependency::na')C= "CPAN::Version"->vge($have, $want)
ABCresult
11X0
0X00
1000
0X11
1011
68 && CPAN::Version->vge($have, $want)) {
69 # https://rt.cpan.org/Ticket/Display.html?id=115340
70 0 undef $loop_starts_with;
71 0 last DWALK;
72 }
73 } elsif ($xo->isa("CPAN::Distribution")) {
74 0 my $pretty = $deps[$i]{display_as} = $xo->pretty_id;
75 0 my $mark_as;
76 0 ▶ if ($in_loop) {
Branch: 2 branches
BranchTrueFalseTotal
if ($in_loop) { } 0 0 0
if ($in_loop) { } 0 0 0
77 0 $mark_as = CPAN::Distrostatus->new("NO cannot resolve circular dependency");
78 } else {
79 0 $mark_as = CPAN::Distrostatus->new("NO one dependency ($loop_starts_with) is a circular dependency");
80 }
81 0 $mark{$pretty} = { xo => $xo, mark_as => $mark_as };
82 }
83 }
84 0 ▶ if ($loop_starts_with) {
Branch: 2 branches
BranchTrueFalseTotal
if ($loop_starts_with) 1 1 2
if ($loop_starts_with) 0 0 0
85 0 ▶ while (my($k,$v) = each %mark) {
Branch: 2 branches
BranchTrueFalseTotal
if (() = each %mark) 0 1 1
if (() = each %mark) 0 0 0
86 0 my $xo = $v->{xo};
87 0 $xo->{make} = $v->{mark_as};
88 0 $xo->store_persistent_state; # otherwise I will not reach
89 # all involved parties for
90 # the next session
91 }
92 }
93 0 bless { deps => \@deps, loop_starts_with => $loop_starts_with }, $class;
94 }
95  
96 0 ▶sub is_resolvable {
Subroutine is_resolvable: not called CC=1 SCAR=6.9
Pod undocumented
97 0 ▶ ! defined shift->{loop_starts_with};
Subroutine is_resolvable: not called CC=1 SCAR=6.9
Pod undocumented
98 }
99  
100 2 ▶sub as_string {
Subroutine as_string: called CC=2 SCAR=9.2
Pod undocumented
101 0 ▶ my($self) = shift;
Subroutine as_string: not called CC=2 SCAR=9.2
Pod undocumented
102 0 my $deps = $self->{deps};
103 0 my $loop_starts_with = $self->{loop_starts_with};
104 0 ▶ unless ($loop_starts_with) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($loop_starts_with) 1 1 2
unless ($loop_starts_with) 0 0 0
105 0 return "--not a recursive/circular dependency--";
106 }
107 0 my $ret = "\nRecursive dependency detected:\n ";
108 0 $ret .= join("\n => ", map {$_->{display_as}} @$deps);
109 0 $ret .= ".\nCannot resolve.\n";
110 0 $ret;
111 }
112  
113 26 1;
« blib/lib/CPAN/Plugin/Specfile.pm ↑ Summary blib/lib/CPAN/Mirrors.pm »