lib/SEO/Inspector/Plugin/MetaDescriptionCheck.pm

filter: Statementstmt 95.8% 23 / 24 Branchbran 75.0% 3 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 3 totaltotal 76.1% 32 / 42 CC 5 SCAR 11.5
CC
5
Cov
87%
run
5.1
name
2.0
BEGIN
1.0
CRAP 3.1
« blib/lib/SEO/Inspector.pm ↑ Summary lib/SEO/Inspector/Plugin/TitleCheck.pm »
1 package SEO::Inspector::Plugin::MetaDescriptionCheck;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use HTML::TreeBuilder;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 7 ▶sub new { bless {}, shift }
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
8  
9 0 ▶sub name { 'MetaDescriptionCheck' }
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
10  
11 5 ▶sub run {
Subroutine run: called CC=5 SCAR=16.3
Pod undocumented
12 5 my ($self, $html) = @_;
13  
14 5 my $tree = HTML::TreeBuilder->new;
15 5 $tree->parse_content($html);
16  
17 # Find <meta name="description"> safely
18 5 my $meta_content;
19 5 for my $el ($tree->find_by_tag_name('meta')) {
20 3 ▶ next unless defined $el->attr('name') && $el->attr('name') eq 'description';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $el->attr("name") and $el->attr("name") eq "description" 0 3 3
Condition33%1/3
defined $el->attr("name") and $el->attr("name") eq "description"
!ll&&!rl&&r
003
MC/DC0%0/2
defined $el->attr("name") and $el->attr("name") eq "description"
defined $el->attr("name") $el->attr("name") eq "description"
Truth table33%1/3
A and B
A= defined $el->attr("name")B= $el->attr("name") eq "description"
ABresult
0X0
100
111
21 3 $meta_content = $el->attr('content');
22 3 last;
23 }
24  
25 5 $tree->delete;
26  
27 5 ▶ if ($meta_content) {
Branch: 1 branch
BranchTrueFalseTotal
if ($meta_content) 3 2 5
28 3 return { status => 'ok', notes => 'meta description present' };
29 }
30  
31 2 return { status => 'warn', notes => 'missing meta description' };
32 }
33  
34 5 1;
« blib/lib/SEO/Inspector.pm ↑ Summary lib/SEO/Inspector/Plugin/TitleCheck.pm »