line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::Policy::ValuesAndExpressions::ProhibitVersionStrings; |
2
|
|
|
|
|
|
|
|
3
|
40
|
|
|
40
|
|
319026
|
use 5.010001; |
|
40
|
|
|
|
|
177
|
|
4
|
40
|
|
|
40
|
|
257
|
use strict; |
|
40
|
|
|
|
|
112
|
|
|
40
|
|
|
|
|
1364
|
|
5
|
40
|
|
|
40
|
|
220
|
use warnings; |
|
40
|
|
|
|
|
93
|
|
|
40
|
|
|
|
|
998
|
|
6
|
40
|
|
|
40
|
|
594
|
use Readonly; |
|
40
|
|
|
|
|
116
|
|
|
40
|
|
|
|
|
2244
|
|
7
|
|
|
|
|
|
|
|
8
|
40
|
|
|
40
|
|
265
|
use Perl::Critic::Utils qw{ :severities }; |
|
40
|
|
|
|
|
96
|
|
|
40
|
|
|
|
|
2462
|
|
9
|
40
|
|
|
40
|
|
5617
|
use parent 'Perl::Critic::Policy'; |
|
40
|
|
|
|
|
102
|
|
|
40
|
|
|
|
|
415
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.146'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Readonly::Scalar my $DESC => q{Version string used}; |
16
|
|
|
|
|
|
|
Readonly::Scalar my $EXPL => q{Use a real number instead}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
19
|
|
|
|
|
|
|
|
20
|
93
|
|
|
93
|
0
|
1643
|
sub supported_parameters { return () } |
21
|
88
|
|
|
88
|
1
|
402
|
sub default_severity { return $SEVERITY_MEDIUM } |
22
|
86
|
|
|
86
|
1
|
422
|
sub default_themes { return qw(core pbp maintenance) } |
23
|
34
|
|
|
34
|
1
|
121
|
sub applies_to { return 'PPI::Statement::Include' } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub violates { |
28
|
80
|
|
|
80
|
1
|
240
|
my ($self, $elem, undef) = @_; |
29
|
|
|
|
|
|
|
|
30
|
80
|
|
|
|
|
166
|
my $version; |
31
|
|
|
|
|
|
|
|
32
|
80
|
100
|
|
|
|
237
|
if ( my $module = $elem->module() ) { |
33
|
72
|
100
|
|
|
|
2075
|
return if $module eq 'lib'; |
34
|
|
|
|
|
|
|
|
35
|
71
|
|
|
|
|
209
|
$version = $elem->module_version(); |
36
|
|
|
|
|
|
|
} else { |
37
|
8
|
|
|
|
|
235
|
$version = $elem->schild(1); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
79
|
100
|
|
|
|
3302
|
return if not defined $version; |
41
|
22
|
100
|
|
|
|
110
|
return if not $version->isa('PPI::Token::Number::Version'); |
42
|
|
|
|
|
|
|
|
43
|
14
|
|
|
|
|
57
|
return $self->violation($DESC, $EXPL, $elem); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#----------------------------------------------------------------------------- |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=pod |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Perl::Critic::Policy::ValuesAndExpressions::ProhibitVersionStrings - Don't use strings like C<v1.4> or C<1.4.5> when including other modules. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 AFFILIATION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This Policy is part of the core L<Perl::Critic|Perl::Critic> |
62
|
|
|
|
|
|
|
distribution. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 DESCRIPTION |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Whenever you C<use> or C<require> a module, you can specify a minimum |
68
|
|
|
|
|
|
|
version requirement. To ensure compatibility with older Perls, this |
69
|
|
|
|
|
|
|
version number should be expressed as a floating-point number. Do not |
70
|
|
|
|
|
|
|
use v-strings or three-part numbers. The Perl convention for |
71
|
|
|
|
|
|
|
expressing version numbers as floats is: version + (patch level / |
72
|
|
|
|
|
|
|
1000). |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
use Foo v1.2 qw(foo bar); # not ok |
75
|
|
|
|
|
|
|
use Foo 1.2.03 qw(foo bar); # not ok |
76
|
|
|
|
|
|
|
use Foo 1.00203 qw(foo bar); # ok |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 CONFIGURATION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
This Policy is not configurable except for the standard options. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHOR |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 COPYRIGHT |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
93
|
|
|
|
|
|
|
it under the same terms as Perl itself. The full text of this license |
94
|
|
|
|
|
|
|
can be found in the LICENSE file included with this module. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Local Variables: |
99
|
|
|
|
|
|
|
# mode: cperl |
100
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
101
|
|
|
|
|
|
|
# fill-column: 78 |
102
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
103
|
|
|
|
|
|
|
# c-indentation-style: bsd |
104
|
|
|
|
|
|
|
# End: |
105
|
|
|
|
|
|
|
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |