Link/Reporter/Compile.pm

filter: Statementstmt 9.2% 9 / 97 Branchbran 0.0% 0 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 14.2% 2 / 14 Podpod 75.0% 9 / 12 totaltotal 12.9% 20 / 155 CC 19 SCAR 23.3
CC
19
Cov
7%
okay
20.0
filename
20.0
damaged
12.0
CRAP 10.3
« Link.pm ↑ Summary Link/Tester.pm »
1 =head1 NAME
2  
3 WWW::Link::Reporter::Compile - report link errors suitably for use in emacs
4  
5 =head1 SYNOPSIS
6  
7 use WWW::Link;
8 use WWW::Link::Reporter::Compile;
9  
10 $link=new WWW::Link;
11 #over time do things to the link ......
12  
13 $::reporter=new WWW::Link::Reporter::Compile;
14 $::reporter->examine($link)
15  
16 or see WWW::Link::Selector for a way to recurse through all of the links.
17  
18 =head1 DESCRIPTION
19  
20 This is designed for reporting errors in a specific file. It prints
21 out an report which is suitable for use by emacs' compile mode.
22  
23 =cut
24  
25 package WWW::Link::Reporter::Compile;
26 1 $REVISION=q$Revision: 1.8 $ ; $VERSION = sprintf ( "%d.%02d", $REVISION =~ /(\d+).(\d+)/ );
27 1 ▶use WWW::Link::Reporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 @ISA = qw(WWW::Link::Reporter);
30  
31 0 ▶sub broken {
Subroutine broken: not called CC=2 SCAR=17.9
Pod documented
32 0 my $self=shift;
33 0 my $link=shift;
34 0 my $url=$link->url();
35 0 my $filename=$self->filename();
36 0 ▶ $INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $INPUT_LINE_NUMBER 0 0 0
37 0 print "$filename:$INPUT_LINE_NUMBER: broken link $url\n";
38 }
39  
40 =head2 okay
41  
42 I don't see any reason to call the okay function.. however for
43 information? We avoid giving a line number so that this doesn't stop
44 emacs compile.
45  
46 =cut
47  
48 0 ▶sub okay {
Subroutine okay: not called CC=4 SCAR=30.0
Pod documented
49 0 my $self=shift;
50 0 my $link=shift;
51 0 my $redir=shift;
52 0 my $url=$link->url();
53 0 my $filename=$self->filename();
54 0 ▶ $INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $INPUT_LINE_NUMBER 0 0 0
55 0 ▶ $redir && print "$filename:$INPUT_LINE_NUMBER: ";
Branch: 1 branch
BranchTrueFalseTotal
$redir and print "${filename}:${INPUT_LINE_NUMBER}: " 0 0 0
56 0 print "tested okay $url\n";
57 0 ▶ $redir && $self->redirections($link);
Branch: 1 branch
BranchTrueFalseTotal
$redir and $self->redirections($link) 0 0 0
58 0 $self->suggestions($link);
59 0 return 1;
60 }
61  
62 0 ▶sub damaged {
Subroutine damaged: not called CC=3 SCAR=24.8
Pod documented
63 0 my $self=shift;
64 0 my $link=shift;
65 0 my $redir=shift;
66 0 my $url=$link->url();
67 0 my $filename=$self->filename();
68 0 ▶ $INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $INPUT_LINE_NUMBER 0 0 0
69 0 print "$filename:$INPUT_LINE_NUMBER: _may_ be broken link $url\n";
70 0 ▶ $redir && $self->redirections($link);
Branch: 1 branch
BranchTrueFalseTotal
$redir and $self->redirections($link) 0 0 0
71 0 $self->suggestions($link);
72 0 return 1;
73 }
74  
75 0 ▶sub not_checked {
Subroutine not_checked: not called CC=2 SCAR=17.9
Pod documented
76 0 my $self=shift;
77 0 my $link=shift;
78 0 my $url=$link->url();
79 0 my $filename=$self->filename();
80 0 ▶ $INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $INPUT_LINE_NUMBER 0 0 0
81 0 print "$filename:$INPUT_LINE_NUMBER: have not yet checked $url\n";
82 0 $self->suggestions($link);
83 0 return 1;
84 }
85  
86 0 ▶sub disallowed {
Subroutine disallowed: not called CC=2 SCAR=17.9
Pod documented
87 0 my $self=shift;
88 0 my $link=shift;
89 0 my $url=$link->url();
90 0 my $filename=$self->filename();
91 0 ▶ $INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $INPUT_LINE_NUMBER 0 0 0
92 0 print "$filename:$INPUT_LINE_NUMBER: checking of link not allowed $url\n";
93 0 $self->suggestions($link);
94 0 return 1;
95 }
96  
97 0 ▶sub unsupported {
Subroutine unsupported: not called CC=2 SCAR=17.9
Pod documented
98 0 my $self=shift;
99 0 my $link=shift;
100 0 my $url=$link->url();
101 0 my $filename=$self->filename();
102 0 ▶ $INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $INPUT_LINE_NUMBER 0 0 0
103 0 print "$filename:$INPUT_LINE_NUMBER: link uses unsupported protocol $url\n";
104 0 $self->suggestions($link);
105 0 return 1;
106 }
107  
108 0 ▶sub unknown {
Subroutine unknown: not called CC=2 SCAR=17.9
Pod documented
109 0 my $self=shift;
110 0 my $link=shift;
111 0 my $url=$link->url();
112 0 my $filename=$self->filename();
113 0 ▶ $INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $INPUT_LINE_NUMBER 0 0 0
114 0 print "$filename:$INPUT_LINE_NUMBER: unknown link status; error?? $url\n";
115 0 $self->suggestions($link);
116 0 return 1;
117 }
118  
119 0 ▶sub not_found {
Subroutine not_found: not called CC=2 SCAR=17.9
Pod documented
120 0 my $self=shift;
121 0 my $url=shift;
122 0 my $filename=$self->filename();
123 0 ▶ $INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $INPUT_LINE_NUMBER 0 0 0
124 0 print "$filename:$INPUT_LINE_NUMBER: no info for $url\n";
125 }
126  
127 0 ▶sub invalid {
Subroutine invalid: not called CC=2 SCAR=17.9
Pod undocumented
128 0 my $self=shift;
129 0 my $url=shift;
130 0 my $filename=$self->filename();
131 0 ▶ $INPUT_LINE_NUMBER="unknown line" unless defined $INPUT_LINE_NUMBER;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $INPUT_LINE_NUMBER 0 0 0
132 0 print "$filename:$INPUT_LINE_NUMBER: non valid url $url\n";
133 }
134  
135 0 ▶sub redirections {
Subroutine redirections: not called CC=2 SCAR=17.9
Pod undocumented
136 0 my $self=shift;
137 0 my $link=shift;
138 0 my @redirects=$link->redirect_urls();
139 0 foreach my $redir ( @redirects ) {
140 0 print " redirected to $redir\n";
141 }
142 }
143  
144 0 ▶sub suggestions {
Subroutine suggestions: not called CC=3 SCAR=24.8
Pod undocumented
145 0 my $self=shift;
146 0 my $link=shift;
147 0 my $suggestions=$link->fix_suggestions();
148 0 ▶ if ($suggestions) {
Branch: 1 branch
BranchTrueFalseTotal
if ($suggestions) 0 0 0
149 0 foreach $suggest ( @{$suggestions} ) {
150 0 print " suggest $suggest\n";
151 }
152 }
153 0 return 1;
154 }
155  
156 =head2 filename
157  
158 The filename function can be called with one argument to set the
159 filename or will return the current idea of the filename if none is
160 given.
161  
162 Until the filename is set, filename will return the current contents
163 of C<$ARGV>. After it has been set it will return whatever value was
164 last given.
165  
166 =cut
167  
168 0 ▶sub filename {
Subroutine filename: not called CC=4 SCAR=30.0
Pod documented
169 0 my $self=shift;
170 0 my $name=shift;
171 0 ▶ $self->{filename}=$name if defined $name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name 0 0 0
172 0 ▶ return $self->{filename} if defined $self->{filename};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"filename"} 0 0 0
173 0 ▶ return $ARGV if defined $ARGV;
Branch: 1 branch
BranchTrueFalseTotal
if defined $ARGV 0 0 0
174 0 return "unknown file";
175 }
« Link.pm ↑ Summary Link/Tester.pm »