« blib/lib/Perl/Critic/Policy/Variables/ProhibitAugmentedAssignmentInDeclaration.pm
↑ Summary
blib/lib/Perl/Critic/Exception/Configuration/Option/Policy/ParameterValue.pm »
| 1 | package Perl::Critic::Policy::ValuesAndExpressions::ProhibitVersionStrings; | ||||||||||
| 2 | |||||||||||
| 3 | 40 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 40 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 40 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 40 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 40 | ▶ | use Perl::Critic::Utils qw{ :severities }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 40 | ▶ | use parent 'Perl::Critic::Policy'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 40 | our $VERSION = '1.150'; | |||||||||
| 12 | |||||||||||
| 13 | #----------------------------------------------------------------------------- | ||||||||||
| 14 | |||||||||||
| 15 | 40 | Readonly::Scalar my $DESC => q{Version string used}; | |||||||||
| 16 | 40 | Readonly::Scalar my $EXPL => q{Use a real number instead}; | |||||||||
| 17 | |||||||||||
| 18 | #----------------------------------------------------------------------------- | ||||||||||
| 19 | |||||||||||
| 20 | 90 | ▶ | sub supported_parameters { return () } | ||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 21 | 75 | ▶ | sub default_severity { return $SEVERITY_MEDIUM } | ||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 22 | 86 | ▶ | sub default_themes { return qw(core pbp maintenance) } | ||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 23 | 31 | ▶ | sub applies_to { return 'PPI::Statement::Include' } | ||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 24 | |||||||||||
| 25 | #----------------------------------------------------------------------------- | ||||||||||
| 26 | |||||||||||
| 27 | sub violates { | ||||||||||
| 28 | 57 | ▶ | my ($self, $elem, undef) = @_; | ||||||||
|
Subroutine
violates: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||
| 29 | |||||||||||
| 30 | 57 | my $version; | |||||||||
| 31 | |||||||||||
| 32 | 57 | ▶ | if ( my $module = $elem->module() ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 55 | ▶ | return if $module eq 'lib'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | 55 | $version = $elem->module_version(); | |||||||||
| 36 | } else { | ||||||||||
| 37 | 2 | $version = $elem->schild(1); | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 57 | ▶ | return if not defined $version; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 2 | ▶ | return if not $version->isa('PPI::Token::Number::Version'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | |||||||||||
| 43 | 0 | return $self->violation($DESC, $EXPL, $elem); | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 40 | 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 : | ||||||||||