| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
####################################################################### |
|
2
|
|
|
|
|
|
|
# $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/Perl-Critic-More/lib/Perl/Critic/Policy/Modules/RequirePerlVersion.pm $ |
|
3
|
|
|
|
|
|
|
# $Date: 2013-10-29 09:39:11 -0700 (Tue, 29 Oct 2013) $ |
|
4
|
|
|
|
|
|
|
# $Author: thaljef $ |
|
5
|
|
|
|
|
|
|
# $Revision: 4222 $ |
|
6
|
|
|
|
|
|
|
######################################################################## |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Perl::Critic::Policy::Modules::RequirePerlVersion; |
|
9
|
|
|
|
|
|
|
|
|
10
|
6
|
|
|
6
|
|
6847
|
use 5.006001; |
|
|
6
|
|
|
|
|
75
|
|
|
|
6
|
|
|
|
|
289
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
6
|
|
|
6
|
|
40
|
use strict; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
223
|
|
|
13
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
190
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
6
|
|
|
6
|
|
34
|
use Readonly; |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
363
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
6
|
|
|
6
|
|
35
|
use Perl::Critic::Utils qw{ :severities }; |
|
|
6
|
|
|
|
|
18
|
|
|
|
6
|
|
|
|
|
504
|
|
|
18
|
6
|
|
|
6
|
|
1072
|
use base 'Perl::Critic::Policy'; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
2216
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '1.003'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => 'Missing Perl version'; |
|
25
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => 'Add "use 5.006" or similar'; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
28
|
|
|
|
|
|
|
|
|
29
|
4
|
|
|
4
|
1
|
281
|
sub default_severity { return $SEVERITY_LOWEST } |
|
30
|
1
|
|
|
1
|
1
|
88
|
sub default_themes { return qw< more compatibility > } |
|
31
|
8
|
|
|
8
|
1
|
36265
|
sub applies_to { return 'PPI::Document' } |
|
32
|
9
|
|
|
9
|
0
|
51453
|
sub supported_parameters { return () } |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub violates { |
|
37
|
8
|
|
|
8
|
1
|
90
|
my ( $self, $elem, $doc ) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
8
|
|
|
|
|
27
|
my $includes = $doc->find('PPI::Statement::Include'); |
|
40
|
8
|
100
|
|
|
|
106
|
if ($includes) { |
|
41
|
7
|
|
|
|
|
13
|
for my $stmt ( @{$includes} ) { |
|
|
7
|
|
|
|
|
18
|
|
|
42
|
9
|
100
|
|
|
|
88
|
next if $stmt->type ne 'use'; |
|
43
|
8
|
100
|
|
|
|
222
|
return if $stmt->version; |
|
44
|
3
|
50
|
|
|
|
77
|
return if $stmt->module =~ m< |
|
45
|
|
|
|
|
|
|
\A |
|
46
|
|
|
|
|
|
|
v |
|
47
|
|
|
|
|
|
|
\d+ |
|
48
|
|
|
|
|
|
|
(?: |
|
49
|
|
|
|
|
|
|
[.] \d+ |
|
50
|
|
|
|
|
|
|
(?: |
|
51
|
|
|
|
|
|
|
_ \d+ |
|
52
|
|
|
|
|
|
|
)? |
|
53
|
|
|
|
|
|
|
)* |
|
54
|
|
|
|
|
|
|
\z |
|
55
|
|
|
|
|
|
|
>xms; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
52
|
return $self->violation( $DESC, $EXPL, $doc ); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#--------------------------------------------------------------------------- |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=for stopwords |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Perl::Critic::Policy::Modules::RequirePerlVersion - Require a C<use 5.006;> or similar. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AFFILIATION |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This policy is part of L<Perl::Critic::More|Perl::Critic::More>, a bleeding |
|
79
|
|
|
|
|
|
|
edge supplement to L<Perl::Critic|Perl::Critic>. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
As Perl evolves, new desirable features get added. The best ones seem to |
|
84
|
|
|
|
|
|
|
break backward compatibility, unfortunately. As a favor to downstream |
|
85
|
|
|
|
|
|
|
developers, it's good to state explicitly which Perl version will not be able |
|
86
|
|
|
|
|
|
|
to parse your code. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
For example, the C<our> keyword was first appeared in a stable Perl in version |
|
89
|
|
|
|
|
|
|
5.6.0. Therefore, if your code employs C<our>, then you should have a line |
|
90
|
|
|
|
|
|
|
like this near the very top of your file: |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
use 5.006; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
or |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
use v5.6.0; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
The former is preferred as the latter can trigger v-string compatibility |
|
99
|
|
|
|
|
|
|
warnings. (If someone could please explain that to me, I'd really appreciate |
|
100
|
|
|
|
|
|
|
it!) |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Additionally, it's good form to state that minimum version in your |
|
103
|
|
|
|
|
|
|
F<Makefile.PL> or F<Build.PL> file. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHOR |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Chris Dolan <cdolan@cpan.org> |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Copyright (c) 2006-2008 Chris Dolan |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
114
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
|
115
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Local Variables: |
|
120
|
|
|
|
|
|
|
# mode: cperl |
|
121
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
|
122
|
|
|
|
|
|
|
# fill-column: 78 |
|
123
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
|
124
|
|
|
|
|
|
|
# c-indentation-style: bsd |
|
125
|
|
|
|
|
|
|
# End: |
|
126
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |