line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::HTML::Tidy::Recursive; |
2
|
|
|
|
|
|
|
$Test::HTML::Tidy::Recursive::VERSION = '0.6.0'; |
3
|
1
|
|
|
1
|
|
649
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
23
|
use 5.008; |
|
1
|
|
|
|
|
3
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Test::More; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
722
|
use HTML::T5; |
|
1
|
|
|
|
|
3404
|
|
|
1
|
|
|
|
|
54
|
|
10
|
1
|
|
|
1
|
|
526
|
use File::Find::Object::Rule (); |
|
1
|
|
|
|
|
18786
|
|
|
1
|
|
|
|
|
28
|
|
11
|
1
|
|
|
1
|
|
7
|
use IO::All qw/ io /; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
12
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
73
|
use MooX qw/ late /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has filename_re => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
default => sub { |
18
|
|
|
|
|
|
|
return qr/\.x?html\z/; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has targets => ( is => 'ro', isa => 'ArrayRef', required => 1 ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has filename_filter => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
default => sub { |
27
|
|
|
|
|
|
|
return sub { return 1; } |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has _tidy => ( is => 'rw' ); |
32
|
|
|
|
|
|
|
has _error_count => ( is => 'rw', isa => 'Int', default => 0 ); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub report_error |
35
|
|
|
|
|
|
|
{ |
36
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $args ) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
$self->_error_count( 1 + $self->_error_count ); |
39
|
0
|
|
|
|
|
0
|
diag( $args->{message} ); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub calc_tidy |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
my $tidy = HTML::T5->new( { output_xhtml => 1, } ); |
49
|
0
|
|
|
|
|
0
|
$tidy->ignore( type => TIDY_WARNING, type => TIDY_INFO ); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
0
|
return $tidy; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub run |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
57
|
0
|
|
|
|
|
0
|
plan tests => 1; |
58
|
|
|
|
|
|
|
local $SIG{__WARN__} = sub { |
59
|
0
|
|
|
0
|
|
0
|
my $w = shift; |
60
|
0
|
0
|
|
|
|
0
|
if ( $w !~ /\AUse of uninitialized/ ) |
61
|
|
|
|
|
|
|
{ |
62
|
0
|
|
|
|
|
0
|
die $w; |
63
|
|
|
|
|
|
|
} |
64
|
0
|
|
|
|
|
0
|
return; |
65
|
0
|
|
|
|
|
0
|
}; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
$self->_tidy( $self->calc_tidy ); |
68
|
0
|
|
|
|
|
0
|
$self->traverse; |
69
|
0
|
|
|
|
|
0
|
$self->_tidy('NULL'); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# TEST |
72
|
0
|
|
|
|
|
0
|
return is( $self->_error_count, 0, "No errors" ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub check_using_tidy |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $args ) = @_; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
0
|
my $fn = $args->{filename}; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
0
|
$self->_tidy->parse( $fn, ( scalar io->file($fn)->slurp() ) ); |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
0
|
for my $message ( $self->_tidy->messages ) |
84
|
|
|
|
|
|
|
{ |
85
|
0
|
|
|
|
|
0
|
$self->report_error( |
86
|
|
|
|
|
|
|
{ |
87
|
|
|
|
|
|
|
message => scalar $message->as_string |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
0
|
$self->_tidy->clear_messages(); |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
0
|
return; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub check_file |
98
|
|
|
|
|
|
|
{ |
99
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $args ) = @_; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
0
|
$self->check_using_tidy($args); |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
return; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub traverse |
107
|
|
|
|
|
|
|
{ |
108
|
1
|
|
|
1
|
1
|
35
|
my ($self) = @_; |
109
|
1
|
|
|
|
|
22
|
$self->_error_count(0); |
110
|
1
|
|
|
|
|
33
|
my $filename_re = $self->filename_re; |
111
|
1
|
|
|
|
|
4
|
my $filter = $self->filename_filter; |
112
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
10
|
foreach my $target ( @{ $self->targets } ) |
|
1
|
|
|
|
|
7
|
|
114
|
|
|
|
|
|
|
{ |
115
|
1
|
|
|
|
|
32
|
for my $fn ( |
116
|
|
|
|
|
|
|
File::Find::Object::Rule->file()->name($filename_re)->in($target) ) |
117
|
|
|
|
|
|
|
{ |
118
|
2
|
50
|
|
|
|
21781
|
if ( $filter->($fn) ) |
119
|
|
|
|
|
|
|
{ |
120
|
2
|
|
|
|
|
13
|
$self->check_file( { filename => $fn } ); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
1347
|
return; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
__END__ |