| 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
Condition33%1/3
defined $el->attr("name") and $el->attr("name") eq "description"
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"
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||