| 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
Condition66%2/3
$title and length $title
MC/DC50%1/2
$title and length $title
$title
length $title
Truth table66%2/3
A and B
A= $titleB= length $title
| |||||||||||||||||||||||||||||
| 27 | 4 | return { status => 'ok', notes => 'title present' }; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1 | return { status => 'error', notes => 'missing title' }; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 5 | 1; | |||||||||||||||||||||||||||