XSS/Element.pm

filter: Statementstmt 96.0% 48 / 50 Branchbran 100% 18 / 18 Conditioncond 87.5% 7 / 8 MC/DCmcdc 80.0% 4 / 5 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 94.4% 85 / 90 CC 14 SCAR 21.5
CC
14
Cov
96%
apply
13.0
__ANON__
2.0
BEGIN
1.0
CRAP 8.5
« XSS/Comment.pm ↑ Summary XSS/Template.pm »
1 package XML::XSS::Element;
2 15 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: XML::XSS element stylesheet rule
4 15 $XML::XSS::Element::VERSION = '0.3.5';
5  
6 15 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use MooseX::SemiAffordanceAccessor;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 15 ▶use MooseX::Clone;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 15 ▶use Scalar::Util qw/ refaddr /;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 15 with 'XML::XSS::Role::Renderer', 'MooseX::Clone';
13  
14 15 ▶no warnings qw/ uninitialized /;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16  
17 30 ▶sub render_attributes {
Subroutine render_attributes: called CC=1 SCAR=0.0
Pod undocumented
18 30 return qw/ process content showtag rename pre intro
19 prechildren prechild postchild postchildren extro post /;
20 }
21  
22 15 has [ render_attributes() ] => ( traits => [qw/ XML::XSS::Role::StyleAttribute Clone /] );
23  
24 72 ▶before "set_$_" => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
25 72 my $self = shift;
26 72 ▶ $self->detach_from_stylesheet if $self->_within_apply;
Branch: 1 branch
BranchTrueFalseTotal
if $self->_within_apply 2 70 72
27 }
28 15 for render_attributes();
29  
30  
31 94 ▶sub apply {
Subroutine apply: called CC=13 SCAR=25.7
32 94 my ( $self, $node, $args ) = @_;
33 94 ▶ $args ||= {};
Condition50%1/2
$args ||= {}
l!l
940
MC/DC0%0/1
$args ||= {}
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
34  
35 return
36 94 ▶ if $self->has_process and !$self->_render( 'process', $node, $args );
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_process and not $self->_render("process", $node, $args) 1 93 94
Condition100%3/3
$self->has_process and not $self->_render("process", $node, $args)
!ll&&!rl&&r
9121
MC/DC100%2/2
$self->has_process and not $self->_render("process", $node, $args)
$self->has_process not $self->_render("process", $node, $args)
Truth table100%3/3
A and not(B)
A= $self->has_processB= not $self->_render("process", $node, $args)
ABresult
0X0
100
111
37  
38 93 my $output = $self->_render( 'pre', $node, $args );
39  
40 93 ▶ my $showtag =
Branch: 2 branches
BranchTrueFalseTotal
$self->has_showtag ? : 14 79 93
$self->has_pre || $self->has_content ? : 20 59 79
Condition100%3/3
$self->has_pre or $self->has_content
l!l&&r!l&&!r
91159
MC/DC100%2/2
$self->has_pre or $self->has_content
$self->has_pre $self->has_content
Truth table100%3/3
A or B
A= $self->has_preB= $self->has_content
ABresult
1X1
011
000
41 $self->has_showtag ? $self->showtag
42 : $self->has_pre || $self->has_content ? 0 : 1;
43  
44 93 my $name;
45 93 ▶ if ($showtag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($showtag) 66 27 93
46 66 ▶ $name =
Branch: 1 branch
BranchTrueFalseTotal
$self->has_rename ? : 3 63 66
47 $self->has_rename
48 ? $self->_render( 'rename', $node, $args )
49 : $node->nodeName;
50  
51 $output .= join ' ',
52 "<$name",
53 0 map { join '=', $_->nodeName, "'@{[$_->serializeContent]}'" }
54 $node->attributes;
55 66 $output .= '>';
56 }
57  
58 93 $output .= $self->_render( 'intro', $node, $args );
59  
60 93 ▶ if ( $self->has_content ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_content) { } 18 75 93
61 18 $output .= $self->_render( 'content', $node, $args );
62 }
63 else {
64 75 ▶ if ( my @children = $node->childNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@children) = $node->childNodes) 57 18 75
65 57 $output .= $self->_render( 'prechildren', $node, $args );
66 57 for ( $node->childNodes ) {
67 83 $output .= $self->_render( 'prechild', $node, $args );
68 83 $output .= $self->render( $_, $args );
69 83 $output .= $self->_render( 'postchild', $node, $args );
70 }
71 57 $output .= $self->_render( 'postchildren', $node, $args );
72 }
73 }
74  
75 93 $output .= $self->_render( 'extro', $node, $args );
76  
77 93 ▶ $output .= "</$name>" if $showtag;
Branch: 1 branch
BranchTrueFalseTotal
if $showtag 66 27 93
78  
79 93 $output .= $self->_render( 'post', $node, $args );
80  
81 93 return $output;
82 }
83  
84 15 1;
85  
86 __END__
« XSS/Comment.pm ↑ Summary XSS/Template.pm »