Tangerine/hook/mooselike.pm

filter: Statementstmt 100% 46 / 46 Branchbran 80.0% 16 / 20 Conditioncond 93.3% 14 / 15 MC/DCmcdc 87.5% 7 / 8 Subroutinesub 100% 12 / 12 Podpod 100% 1 / 1 totaltotal 94.1% 96 / 102 CC 17 SCAR 23.8
CC
17
Cov
94%
run
17.2
BEGIN
1.0
BEGIN
1.0
CRAP 10.8
« Tangerine/hook/testrequires.pm ↑ Summary Tangerine/hook/inline.pm »
1 package Tangerine::hook::mooselike;
2 16 $Tangerine::hook::mooselike::VERSION = '0.23';
3 16 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use parent 'Tangerine::Hook';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 16 ▶use Tangerine::Hook;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 16 ▶use Tangerine::HookData;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 16 ▶use Tangerine::Utils qw(any none stripquotelike);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 162 ▶sub run {
Subroutine run: called CC=17 SCAR=28.4
Pod documented
12 162 my ($self, $s) = @_;
13 162 ▶ if ($self->type eq 'compile' && $s->[0] eq 'use' &&
Branch: 2 branches
BranchTrueFalseTotal
if ($self->type eq 'compile' and $s->[0] eq 'use' and scalar @$s > 1 and &any(sub { $s->[1] eq $_; } , 'Moose', 'Mouse', 'Moo', 'Mo', 'Role::Tiny::With')) { } 6 156 162
elsif ($self->type eq 'runtime' and &any(sub { $s->[0] eq $_; } , 'extends', 'with')) { } 7 281 288
Condition88%8/9
$self->type eq "compile" and $s->[0] eq "use" and scalar @$s > 1 and &any(sub { $s->[1] eq $_; } , "Moose", "Mouse", "Moo", "Mo", "Role::Tiny::With")
!ll&&!rl&&r
81756
$self->type eq "compile" and $s->[0] eq "use" and scalar @$s > 1
!ll&&!rl&&r
81081
$self->type eq "compile" and $s->[0] eq "use"
!ll&&!rl&&r
245781
MC/DC75%3/4
$self->type eq "compile" and $s->[0] eq "use" and scalar @$s > 1 and &any(sub { $s->[1] eq $_; } , "Moose", "Mouse", "Moo", "Mo", "Role::Tiny::With")
$self->type eq "compile" $s->[0] eq "use" scalar @$s > 1 &any(sub { $s->[1] eq $_; } , "Moose", "Mouse", "Moo", "Mo", "Role::Tiny::With")
Truth table80%4/5
A and B and C and D
A= $self->type eq "compile"B= $s->[0] eq "use"C= scalar @$s > 1D= &any(sub { $s->[1] eq $_; } , "Moose", "Mouse", "Moo", "Mo", "Role::Tiny::With")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
14 396 ▶ scalar(@$s) > 1 && (any { $s->[1] eq $_ }
Subroutine __ANON__: called CC=1 SCAR=0.0
15 qw(Moose Mouse Moo Mo Role::Tiny::With))) {
16 6 return Tangerine::HookData->new(
17 hooks => [
18 Tangerine::hook::mooselike->new(type => 'runtime'),
19 ],
20 );
21 45 ▶ } elsif ($self->type eq 'runtime' && any { $s->[0] eq $_ } qw(extends with)) {
Subroutine __ANON__: called CC=1 SCAR=0.0
Condition100%3/3
$self->type eq "runtime" and &any(sub { $s->[0] eq $_; } , "extends", "with")
!ll&&!rl&&r
132177
MC/DC100%2/2
$self->type eq "runtime" and &any(sub { $s->[0] eq $_; } , "extends", "with")
$self->type eq "runtime" &any(sub { $s->[0] eq $_; } , "extends", "with")
Truth table100%3/3
A and B
A= $self->type eq "runtime"B= &any(sub { $s->[0] eq $_; } , "extends", "with")
ABresult
0X0
100
111
22 7 ▶ if (scalar(@$s) > 2 && none { $s->[2] eq $_ } ('=>', ',', ';')) {
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$s > 2 and &none(sub { $s->[2] eq $_; } , "=>", ",", ";")) 1 6 7
Condition100%3/3
scalar @$s > 2 and &none(sub { $s->[2] eq $_; } , "=>", ",", ";")
!ll&&!rl&&r
241
MC/DC100%2/2
scalar @$s > 2 and &none(sub { $s->[2] eq $_; } , "=>", ",", ";")
scalar @$s > 2 &none(sub { $s->[2] eq $_; } , "=>", ",", ";")
Truth table100%3/3
A and B
A= scalar @$s > 2B= &none(sub { $s->[2] eq $_; } , "=>", ",", ";")
ABresult
0X0
100
111
23 # Bail out; most likely an indirect object method call
24 return
25 1 }
26 6 my %modules;
27 my $last;
28 6 ▶ for (my $i = 1; $i < scalar(@$s); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$s) 22 0 22
29 22 ▶ next if any { $s->[$i] eq $_ } ('=>', ',');
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { $s->[$i] eq $_; } , "=>", ",") 6 16 22
30 16 ▶ last if $s->[$i] eq ';';
Branch: 1 branch
BranchTrueFalseTotal
if $s->[$i] eq ";" 6 10 16
31 10 ▶ $s->[$i] = substr($s->[$i], 1, -1) if substr($s->[$i], 0, 1) eq '(';
Branch: 1 branch
BranchTrueFalseTotal
if substr($s->[$i], 0, 1) eq "(" 0 10 10
32 10 ▶ if (substr($s->[$i], 0, 1) ne '{') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($s->[$i], 0, 1) ne '{') { } 6 4 10
33 6 my @parents = stripquotelike($s->[$i]);
34 6 $last = $parents[-1];
35 6 $modules{$_} = undef for @parents;
36 } else {
37 4 ▶ next unless $last;
Branch: 1 branch
BranchTrueFalseTotal
unless $last 0 4 4
38 $modules{$last} = $+{version} if
39 4 ▶ $s->[$i] =~ /^\{.*-version\s*?(?:=>|,)\s*?(?:(?:qq?\s*?[^\w]\s*)|'|")?v?
Branch: 1 branch
BranchTrueFalseTotal
if $s->[$i] =~ /^\{.*-version\s*?(?:=>|,)\s*?(?:(?:qq?\s*?[^\w]\s*)|'|")?v? (?<version>\d+?(?:\.\d+)*)(?:(?:\s*?[^\w])|'|")?.*\}\s*$/osx 4 0 4
40 (?<version>\d+?(?:\.\d+)*)(?:(?:\s*?[^\w])|'|")?.*\}\s*$/xso;
41 4 $last = undef;
42 }
43 }
44 return Tangerine::HookData->new(
45 modules => {
46 map {
47 6 ( $_ => Tangerine::Occurence->new(version => $modules{$_}) )
48 } keys %modules,
49 },
50 );
51 }
52 149 return;
53 }
54  
55 16 1;
56  
57 __END__
« Tangerine/hook/testrequires.pm ↑ Summary Tangerine/hook/inline.pm »