| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::Subroutines::ProhibitExportingUndeclaredSubs; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
505
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
29
|
|
|
4
|
1
|
|
|
1
|
|
13
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
33
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use Carp qw(croak); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
44
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use English qw(-no_match_vars); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
7
|
1
|
|
|
1
|
|
321
|
use base 'Perl::Critic::Policy'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
67
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
|
|
42
|
use Perl::Critic::Utils qw( |
|
10
|
|
|
|
|
|
|
:severities |
|
11
|
|
|
|
|
|
|
&hashify |
|
12
|
|
|
|
|
|
|
&policy_short_name |
|
13
|
1
|
|
|
1
|
|
4
|
); |
|
|
1
|
|
|
|
|
1
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
332
|
use Perl::Critic::StricterSubs::Utils qw( |
|
16
|
|
|
|
|
|
|
&find_declared_constant_names |
|
17
|
|
|
|
|
|
|
&find_declared_subroutine_names |
|
18
|
|
|
|
|
|
|
&find_exported_subroutine_names |
|
19
|
1
|
|
|
1
|
|
110
|
); |
|
|
1
|
|
|
|
|
2
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = 0.04; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
26
|
|
|
|
|
|
|
|
|
27
|
6
|
|
|
6
|
0
|
21673
|
sub supported_parameters { return } |
|
28
|
5
|
|
|
5
|
1
|
46
|
sub default_severity { return $SEVERITY_HIGH } |
|
29
|
0
|
|
|
0
|
1
|
0
|
sub default_themes { return qw( strictersubs bugs ) } |
|
30
|
6
|
|
|
6
|
1
|
42525
|
sub applies_to { return 'PPI::Document' } |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub violates { |
|
35
|
6
|
|
|
6
|
1
|
165
|
my ($self, $elem, $doc) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
6
|
|
|
|
|
11
|
my @exported_sub_names = (); |
|
38
|
|
|
|
|
|
|
eval { |
|
39
|
6
|
|
|
|
|
26
|
@exported_sub_names = find_exported_subroutine_names( $doc ); |
|
40
|
6
|
|
|
|
|
16
|
1; |
|
41
|
6
|
50
|
|
|
|
12
|
} or do { |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
0
|
if ( $EVAL_ERROR =~ m/Found \s multiple/mxs ) { |
|
44
|
0
|
|
|
|
|
0
|
my $pname = policy_short_name(__PACKAGE__); |
|
45
|
0
|
|
0
|
|
|
0
|
my $fname = $doc->filename() || 'unknown'; |
|
46
|
0
|
|
|
|
|
0
|
warn qq{$pname: $EVAL_ERROR in file "$fname"\n}; |
|
47
|
0
|
|
|
|
|
0
|
return; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
}; |
|
51
|
|
|
|
|
|
|
|
|
52
|
6
|
|
|
|
|
20
|
my @declared_sub_names = find_declared_subroutine_names( $doc ); |
|
53
|
6
|
|
|
|
|
24
|
my @declared_constants = find_declared_constant_names( $doc ); |
|
54
|
6
|
|
|
|
|
23
|
my %declared_sub_names = hashify( @declared_sub_names, |
|
55
|
|
|
|
|
|
|
@declared_constants ); |
|
56
|
|
|
|
|
|
|
|
|
57
|
6
|
|
|
|
|
44
|
my @violations = (); |
|
58
|
6
|
|
|
|
|
13
|
for my $sub_name ( @exported_sub_names ) { |
|
59
|
13
|
100
|
|
|
|
544
|
if ( not exists $declared_sub_names{ $sub_name } ){ |
|
60
|
5
|
|
|
|
|
12
|
my $desc = qq{Subroutine "$sub_name" is exported but not declared}; |
|
61
|
5
|
|
|
|
|
9
|
my $expl = qq{Perhaps you forgot to define "$sub_name"}; |
|
62
|
5
|
|
|
|
|
24
|
push @violations, $self->violation( $desc, $expl, $doc ); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
6
|
|
|
|
|
667
|
return @violations; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=pod |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Perl::Critic::Policy::Subroutines::ProhibitExportingUndeclaredSubs |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AFFILIATION |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This policy is part of L<Perl::Critic::StricterSubs|Perl::Critic::StricterSubs>. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
This Policy checks that any subroutine listed in C<@EXPORT> or C<@EXPORT_OK> |
|
88
|
|
|
|
|
|
|
is actually defined in the current file. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Jeffrey Ryan Thalhammer <thaljef@cpan.org> |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Copyright (c) 2007 Jeffrey Ryan Thalhammer. All rights reserved. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
|
99
|
|
|
|
|
|
|
the same terms as Perl itself. The full text of this license can be found in |
|
100
|
|
|
|
|
|
|
the LICENSE file included with this module. |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
############################################################################## |
|
106
|
|
|
|
|
|
|
# Local Variables: |
|
107
|
|
|
|
|
|
|
# mode: cperl |
|
108
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
|
109
|
|
|
|
|
|
|
# fill-column: 78 |
|
110
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
|
111
|
|
|
|
|
|
|
# c-indentation-style: bsd |
|
112
|
|
|
|
|
|
|
# End: |
|
113
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab : |