Tangerine/hook/mooselike.pm

filter: Statementstmt 100% 49 / 49 Branchbran 80.0% 16 / 20 Conditioncond 93.3% 14 / 15 MC/DCmcdc 87.5% 7 / 8 Subroutinesub 100% 13 / 13 Podpod 100% 1 / 1 totaltotal 94.3% 100 / 106 CC 17 SCAR 23.5
CC
17
Cov
94%
run
17.2
BEGIN
1.0
BEGIN
1.0
CRAP 10.5
« Tangerine/hook/list.pm ↑ Summary Tangerine/hook/inline.pm »
1 package Tangerine::hook::mooselike;
2 15 $Tangerine::hook::mooselike::VERSION = '0.21';
3 15 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 15 ▶use parent 'Tangerine::Hook';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use List::Util 1.33 qw(any none);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 ▶use Tangerine::Hook;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 15 ▶use Tangerine::HookData;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use Tangerine::Utils qw(stripquotelike);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub run {
13 156 ▶ my ($self, $s) = @_;
Subroutine run: called CC=17 SCAR=28.4
Pod documented
14 156 ▶ 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 150 156
elsif ($self->type eq 'runtime' and &any(sub { $s->[0] eq $_; } , 'extends', 'with')) { } 7 269 276
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
79716
$self->type eq "compile" and $s->[0] eq "use" and scalar @$s > 1
!ll&&!rl&&r
79077
$self->type eq "compile" and $s->[0] eq "use"
!ll&&!rl&&r
245577
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
15 376 ▶ scalar(@$s) > 1 && (any { $s->[1] eq $_ }
Subroutine __ANON__: called CC=1 SCAR=0.0
16 qw(Moose Mouse Moo Mo Role::Tiny::With))) {
17 6 return Tangerine::HookData->new(
18 hooks => [
19 Tangerine::hook::mooselike->new(type => 'runtime'),
20 ],
21 );
22 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
126177
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
23 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
24 # Bail out; most likely an indirect object method call
25 return
26 1 }
27 6 my %modules;
28 my $last;
29 6 ▶ for (my $i = 1; $i < scalar(@$s); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @$s) 22 0 22
30 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
31 16 ▶ last if $s->[$i] eq ';';
Branch: 1 branch
BranchTrueFalseTotal
if $s->[$i] eq ";" 6 10 16
32 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
33 10 ▶ if (substr($s->[$i], 0, 1) ne '{') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($s->[$i], 0, 1) ne '{') { } 6 4 10
34 6 my @parents = stripquotelike($s->[$i]);
35 6 $last = $parents[-1];
36 6 $modules{$_} = undef for @parents;
37 } else {
38 4 ▶ next unless $last;
Branch: 1 branch
BranchTrueFalseTotal
unless $last 0 4 4
39 $modules{$last} = $+{version} if
40 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
41 (?<version>\d+?(?:\.\d+)*)(?:(?:\s*?[^\w])|'|")?.*\}\s*$/xso;
42 4 $last = undef;
43 }
44 }
45 return Tangerine::HookData->new(
46 modules => {
47 map {
48 6 ( $_ => Tangerine::Occurence->new(version => $modules{$_}) )
49 } keys %modules,
50 },
51 );
52 }
53 143 return;
54 }
55  
56 15 1;
57  
58 __END__
« Tangerine/hook/list.pm ↑ Summary Tangerine/hook/inline.pm »