lib/SEO/Inspector/Plugin/TitleCheck.pm

filter: Statementstmt 95.6% 22 / 23 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 3 totaltotal 82.0% 32 / 39 CC 4 SCAR 8.9
CC
4
Cov
93%
run
4.0
name
2.0
BEGIN
1.0
CRAP 2.4
« lib/SEO/Inspector/Plugin/MetaDescriptionCheck.pm ↑ Summary bin/seo-inspect »
1 package SEO::Inspector::Plugin::TitleCheck;
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 { 'TitleCheck' }
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
10  
11 5 ▶sub run {
Subroutine run: called CC=4 SCAR=13.9
Pod undocumented
12 5 my ($self, $html) = @_;
13  
14 5 my $tree = HTML::TreeBuilder->new;
15 5 $tree->parse_content($html);
16  
17 # Find the <title> element safely
18 5 my $title;
19 5 for my $el ($tree->find_by_tag_name('title')) {
20 4 $title = $el->as_text;
21 4 last;
22 }
23  
24 5 $tree->delete;
25  
26 5 ▶ if ($title && length $title) {
Branch: 1 branch
BranchTrueFalseTotal
if ($title and length $title) 4 1 5
Condition66%2/3
$title and length $title
!ll&&!rl&&r
104
MC/DC50%1/2
$title and length $title
$title length $title
Truth table66%2/3
A and B
A= $titleB= length $title
ABresult
0X0
100
111
27 4 return { status => 'ok', notes => 'title present' };
28 }
29  
30 1 return { status => 'error', notes => 'missing title' };
31 }
32  
33 5 1;
« lib/SEO/Inspector/Plugin/MetaDescriptionCheck.pm ↑ Summary bin/seo-inspect »