line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Spellunker; |
2
|
2
|
|
|
2
|
|
21001
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
73
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
77
|
|
4
|
2
|
|
|
2
|
|
52
|
use 5.008001; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
85
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
402
|
use Spellunker::Pod; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
57
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use parent qw(Exporter); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
12
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
111
|
use version; our $VERSION = version->declare("v0.4.0"); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
16
|
|
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
181
|
use Test::Builder; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
49
|
|
13
|
2
|
|
|
2
|
|
11
|
use File::Spec; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
2128
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $SPELLUNKER = Spellunker::Pod->new(); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @EXPORT = qw( |
18
|
|
|
|
|
|
|
pod_file_spelling_ok |
19
|
|
|
|
|
|
|
all_pod_files_spelling_ok |
20
|
|
|
|
|
|
|
add_stopwords |
21
|
|
|
|
|
|
|
load_dictionary |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $TEST = Test::Builder->new(); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub all_pod_files_spelling_ok { |
27
|
1
|
|
|
1
|
1
|
8
|
local $Test::Builder::Level = $Test::Builder::Level + 1; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
4
|
my @files = all_pod_files(@_); |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
44
|
$TEST->plan(tests => scalar @files); |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
581
|
my $ok = 1; |
34
|
1
|
|
|
|
|
4
|
for my $file (@files) { |
35
|
8
|
50
|
|
|
|
19
|
pod_file_spelling_ok($file) or undef $ok; |
36
|
|
|
|
|
|
|
} |
37
|
1
|
|
|
|
|
95
|
return $ok; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _starting_points { |
41
|
1
|
50
|
|
1
|
|
26
|
return 'blib' if -d 'blib'; |
42
|
0
|
|
|
|
|
0
|
return grep -d, qw(bin lib script); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub all_pod_files { |
46
|
1
|
50
|
|
1
|
1
|
8
|
my @queue = @_ ? @_ : _starting_points(); |
47
|
1
|
|
|
|
|
3
|
my @pod; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
4
|
while (@queue) { |
50
|
22
|
|
|
|
|
30
|
my $file = shift @queue; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# recurse into subdirectories |
53
|
22
|
100
|
|
|
|
276
|
if (-d $file) { |
54
|
12
|
50
|
|
|
|
246
|
opendir(my $dirhandle, $file) or next; |
55
|
12
|
|
|
|
|
272
|
my @newfiles = readdir($dirhandle); |
56
|
12
|
|
|
|
|
145
|
closedir $dirhandle; |
57
|
|
|
|
|
|
|
|
58
|
12
|
|
|
|
|
126
|
@newfiles = File::Spec->no_upwards(@newfiles); |
59
|
12
|
50
|
|
|
|
21
|
@newfiles = grep { $_ ne "CVS" && $_ ne ".svn" } @newfiles; |
|
21
|
|
|
|
|
84
|
|
60
|
|
|
|
|
|
|
|
61
|
12
|
|
|
|
|
53
|
push @queue, map "$file/$_", @newfiles; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# add the file if it meets our criteria |
65
|
22
|
100
|
|
|
|
286
|
if (-f $file) { |
66
|
10
|
100
|
|
|
|
18
|
next unless _is_perl($file); |
67
|
8
|
|
|
|
|
20
|
push @pod, $file; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
6
|
return @pod; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _is_perl { |
75
|
10
|
|
|
10
|
|
39
|
my $file = shift; |
76
|
|
|
|
|
|
|
|
77
|
10
|
50
|
|
|
|
25
|
return 1 if $file =~ /\.PL$/; |
78
|
10
|
100
|
|
|
|
41
|
return 1 if $file =~ /\.p(l|lx|m|od)$/; |
79
|
4
|
50
|
|
|
|
9
|
return 1 if $file =~ /\.t$/; |
80
|
|
|
|
|
|
|
|
81
|
4
|
50
|
|
|
|
131
|
open my $handle, '<', $file or return; |
82
|
4
|
|
|
|
|
50
|
my $first = <$handle>; |
83
|
|
|
|
|
|
|
|
84
|
4
|
100
|
66
|
|
|
49
|
return 1 if defined $first && ($first =~ /^#!.*perl/); |
85
|
|
|
|
|
|
|
|
86
|
2
|
|
|
|
|
29
|
return 0; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub pod_file_spelling_ok { |
90
|
8
|
|
|
8
|
1
|
11
|
my $file = shift; |
91
|
8
|
|
33
|
|
|
35
|
my $name = shift || "POD spelling for $file"; |
92
|
|
|
|
|
|
|
|
93
|
8
|
50
|
|
|
|
194
|
if ( !-r $file ) { |
94
|
0
|
|
|
|
|
0
|
$TEST->ok( 0, $name ); |
95
|
0
|
|
|
|
|
0
|
$TEST->diag("$file does not exist or is unreadable"); |
96
|
0
|
|
|
|
|
0
|
return; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
8
|
|
|
|
|
31
|
my @err = $SPELLUNKER->check_file($file); |
100
|
|
|
|
|
|
|
|
101
|
8
|
|
|
|
|
14
|
my $ok = @err == 0; |
102
|
8
|
|
|
|
|
44
|
$TEST->ok($ok, "$name"); |
103
|
8
|
50
|
|
|
|
3740
|
if (!$ok) { |
104
|
0
|
|
|
|
|
0
|
my $msg = "Errors:\n"; |
105
|
0
|
|
|
|
|
0
|
for (@err) { |
106
|
0
|
|
|
|
|
0
|
my ($lineno, $line, $errs) = @$_; |
107
|
0
|
|
|
|
|
0
|
for my $err (@$errs) { |
108
|
0
|
|
|
|
|
0
|
$msg .= " $lineno: $err\n"; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
0
|
|
|
|
|
0
|
$TEST->diag($msg); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
8
|
|
|
|
|
39
|
return $ok; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub add_stopwords { |
118
|
1
|
|
|
1
|
1
|
17
|
$SPELLUNKER->add_stopwords(@_); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub load_dictionary { |
122
|
1
|
|
|
1
|
1
|
11
|
$SPELLUNKER->load_dictionary(@_); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
1; |
127
|
|
|
|
|
|
|
__END__ |