DBIx/Class/Componentised.pm

filter: Statementstmt 100% 50 / 50 Branchbran 94.4% 17 / 18 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 96.5% 84 / 87 CC 14 SCAR 22.7
CC
14
Cov
97%
inject_base
14.0
BEGIN
1.0
BEGIN
1.0
CRAP 9.7
« DBIx/Class/Storage/DBI/ACCESS.pm ↑ Summary DBIx/Class/CDBICompat/Stringify.pm »
1 package # hide from PAUSE
2 DBIx::Class::Componentised;
3  
4 383 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 383 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 383 ▶use base 'Class::C3::Componentised';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 383 ▶use mro 'c3';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 383 ▶use DBIx::Class::Carp '^DBIx::Class|^Class::C3::Componentised';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 383 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # this warns of subtle bugs introduced by UTF8Columns hacky handling of store_column
14 # if and only if it is placed before something overriding store_column
15 22017 ▶sub inject_base {
Subroutine inject_base: called CC=14 SCAR=26.4
Pod documented
16 22017 my $class = shift;
17 22017 my ($target, @complist) = @_;
18  
19 # we already did load the component
20 22017 ▶ my $keep_checking = ! (
Condition66%2/3
$target->isa('DBIx::Class::UTF8Columns') || $target->isa('DBIx::Class::ForceUTF8')
l!l&&r!l&&!r
2022015
MC/DC50%1/2
$target->isa('DBIx::Class::UTF8Columns') || $target->isa('DBIx::Class::ForceUTF8')
$target->isa('DBIx::Class::UTF8Columns') $target->isa('DBIx::Class::ForceUTF8')
Truth table66%2/3
A || B
A= $target->isa('DBIx::Class::UTF8Columns')B= $target->isa('DBIx::Class::ForceUTF8')
ABresult
1X1
011
000
21 $target->isa ('DBIx::Class::UTF8Columns')
22 ||
23 $target->isa ('DBIx::Class::ForceUTF8')
24 );
25  
26 22017 my @target_isa;
27  
28 22017 ▶ while ($keep_checking && @complist) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keep_checking and @complist) 27270 22017 49287
Condition100%3/3
$keep_checking and @complist
!ll&&!rl&&r
72201027270
MC/DC100%2/2
$keep_checking and @complist
$keep_checking @complist
Truth table100%3/3
A and B
A= $keep_checkingB= @complist
ABresult
0X0
100
111
29  
30 383 ▶ @target_isa = do { no strict 'refs'; @{"$target\::ISA"} }
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
unless @target_isa 22015 5255 27270
31 unless @target_isa;
32  
33 27270 my $comp = pop @complist;
34  
35 # warn here on use of either component, as we have no access to ForceUTF8,
36 # the author does not respond, and the Catalyst wiki used to recommend it
37 27270 for (qw/DBIx::Class::UTF8Columns DBIx::Class::ForceUTF8/) {
38 54535 ▶ if ($comp->isa ($_) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($comp->isa($_)) 5 54530 54535
39 5 $keep_checking = 0; # no use to check from this point on
40 carp_once "Use of $_ is strongly discouraged. See documentation of DBIx::Class::UTF8Columns for more info\n"
41 5 ▶ unless $ENV{DBIC_UTF8COLUMNS_OK};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"DBIC_UTF8COLUMNS_OK"} 4 1 5
42 5 last;
43 }
44 }
45  
46 # something unset $keep_checking - we got a unicode mangler
47 27270 ▶ if (! $keep_checking) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($keep_checking) 5 27265 27270
48  
49 5 my $base_store_column = do { require DBIx::Class::Row; DBIx::Class::Row->can ('store_column') };
50  
51 5 my @broken;
52 5 for my $existing_comp (@target_isa) {
53 7 ▶ my $sc = $existing_comp->can ('store_column')
Branch: 1 branch
BranchTrueFalseTotal
my $sc = $existing_comp->can("store_column") or next 7 0 7
54 or next;
55  
56 7 ▶ if ($sc ne $base_store_column) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sc ne $base_store_column) 2 5 7
57 2 require B;
58 2 my $definer = B::svref_2object($sc)->STASH->NAME;
59 2 ▶ push @broken, ($definer eq $existing_comp)
Branch: 1 branch
BranchTrueFalseTotal
$definer eq $existing_comp ? : 1 1 2
60 ? $existing_comp
61 : "$existing_comp (via $definer)"
62 ;
63 }
64 }
65  
66 5 ▶ carp "Incorrect loading order of $comp by $target will affect other components overriding 'store_column' ("
Branch: 1 branch
BranchTrueFalseTotal
if @broken 2 3 5
67 . join (', ', @broken)
68 .'). Refer to the documentation of DBIx::Class::UTF8Columns for more info'
69 if @broken;
70 }
71  
72 27270 unshift @target_isa, $comp;
73 }
74  
75 22017 $class->next::method(@_);
76 }
77  
78 383 1;
« DBIx/Class/Storage/DBI/ACCESS.pm ↑ Summary DBIx/Class/CDBICompat/Stringify.pm »