| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Metrics::Plugin::Core; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Perl::Metrics::Plugin::Core - The Core Perl Metrics Package |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This class provides a set of core metrics for Perl documents, based on |
|
12
|
|
|
|
|
|
|
very simple code using only the core L package. |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 METRICS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
As with all L packages, all metrics can be |
|
17
|
|
|
|
|
|
|
referenced with the global identifier C. |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Metrics are listed as "datatype name". |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
|
33287
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
124
|
|
|
24
|
3
|
|
|
3
|
|
16
|
use base 'Perl::Metrics::Plugin'; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
699
|
|
|
25
|
3
|
|
|
3
|
|
17
|
use List::Util (); |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
64
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
3
|
|
|
3
|
|
15
|
use vars qw{$VERSION}; |
|
|
3
|
|
|
|
|
15
|
|
|
|
3
|
|
|
|
|
201
|
|
|
28
|
|
|
|
|
|
|
BEGIN { |
|
29
|
3
|
|
|
3
|
|
372
|
$VERSION = '0.09'; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=pod |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 integer tokens |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
The C metric represents the total number of L objects |
|
37
|
|
|
|
|
|
|
contained in the document. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
For example, the following one-line document would have a C metric |
|
40
|
|
|
|
|
|
|
of 5 (assuming a single trailing newline) |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
print "Hello World!\n"; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub metric_tokens { |
|
47
|
4
|
|
|
4
|
0
|
13
|
my ($self, $Document) = @_; |
|
48
|
4
|
|
|
|
|
39
|
scalar $Document->tokens; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=pod |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 integer significant_tokens |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
The C metric represents the total number of |
|
56
|
|
|
|
|
|
|
C tokens contained in the document. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
This filters out things like whitespace and comments, and refers (more or |
|
59
|
|
|
|
|
|
|
less) to only the parts of the document that actually do something. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
For more information on significance, see L. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub metric_significant_tokens { |
|
66
|
4
|
|
|
4
|
0
|
10
|
my ($self, $Document) = @_; |
|
67
|
4
|
|
|
|
|
17
|
scalar grep { $_->significant } $Document->tokens; |
|
|
80
|
|
|
|
|
398
|
|
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SUPPORT |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Bugs should be reported via the CPAN bug tracker at |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
L |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
For other issues, contact the author. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 AUTHOR |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L, L, L |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Copyright 2005 - 2008 Adam Kennedy. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This program is free software; you can redistribute |
|
95
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The full text of the license can be found in the |
|
98
|
|
|
|
|
|
|
LICENSE file included with this module. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |