NAME
Perl::Critic::Policy::logicLAB::RequireVersionFormat - assert version
number formats
AFFILIATION
This policy is part of Perl::Critic::logicLAB distribution.
VERSION
This documentation describes version 0.05
DESCRIPTION
This policy asserts that a specified version number conforms to a
specified format.
The default format is the defacto format used on CPAN. X.X and X.X_X
where X is an arbitrary integer, in the code this is expressed using the
following regular expression:
\A\d+\.\d+(_\d+)?\z
The following example lines would adhere to this format:
* 0.01, a regular release
* 0.01_1, a developer release
Scope, quoting and representation does not matter. If the version
specification is lazy please see "EXCEPTIONS".
The following example lines would not adhere to this format and would
result in a violation.
* our ($VERSION) = '$Revision$' =~ m{ \$Revision: \s+ (\S+) }x;
* $VERSION = '0.0.1';
* $MyPackage::VERSION = 1.0.61;
* use version; our $VERSION = qv(1.0.611);
* $VERSION = "0.01a";
In addition to the above examples, there are variations in quoting etc.
all would cause a violation.
EXCEPTIONS
In addition there are some special cases, were we simply ignore the
version, since we cannot assert it in a reasonable manner.
* our $VERSION = $Other::VERSION;
We hope that $Other::VERSION conforms where defined, so we ignore
for now.
CONFIGURATION AND ENVIRONMENT
strict_quotes
Strict quotes is off by default.
Strict quotes enforces that you version number must be quoted, like so:
'0.01' and "0.01". 0.01 would in this case cause a violation. This would
also go for any additional formats you could configure as valid using
the "formats" parameter below.
[logicLAB::RequireVersionFormat]
strict_quotes = 1
ignore_quotes
Ignore quotes is on by default.
0.01, '0.01' and "0.01" would be interpreted as the same.
Disabling ignore quotes, would mean that: '0.01' and "0.01" would
violate the default format since quotes are not specifed as part of the
pattern. This would also go for any additional formats you could
configure as valid using the "formats" parameter below.
[logicLAB::RequireVersionFormat]
ignore_quotes = 0
formats
If no formats are specified, the policy only enforces the default format
mentioned in "DESCRIPTION" in combination with the above two
configuration parameters of course.
[logicLAB::RequireVersionFormat]
formats = \A\d+\.\d+(_\d+)?\z || \Av\d+\.\d+\.\d+\z
DEPENDENCIES AND REQUIREMENTS
* Perl::Critic
* Perl::Critic::Utils
* Readonly
* Test::More
* Test::Perl::Critic
INCOMPATIBILITIES
This distribution has no known incompatibilities.
BUGS AND LIMITATIONS
I think it would be a good idea to ignore this particular version string
and versions thereof:
our ($VERSION) = '$Revision$' =~ m{ \$Revision: \s+ (\S+) }x;
I am however still undecided.
BUG REPORTING
Please use Requets Tracker for bug reporting:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Perl-Critic-logicLAB-Prohibit-RequireVersionFormat
TEST AND QUALITY
The following policies have been disabled for this distribution
* Perl::Crititc::Policy::ValuesAndExpressions::ProhibitConstantPragma
* Perl::Crititc::Policy::NamingConventions::Capitalization
TEST COVERAGE
---------------------------- ------ ------ ------ ------ ------ ------ ------
File stmt bran cond sub pod time total
---------------------------- ------ ------ ------ ------ ------ ------ ------
...B/RequireVersionFormat.pm 97.9 75.0 68.2 100.0 100.0 100.0 89.8
Total 97.9 75.0 68.2 100.0 100.0 100.0 89.8
---------------------------- ------ ------ ------ ------ ------ ------ ------
TODO
* I would like to integrate the features of this policy into
Perl::Critic::Policy::Modules::RequireVersionVar, but I was aiming
for a proof of concept first - so this planned patch is still in the
pipeline.
* Address the limitation listed in "BUGS AND LIMITATIONS".
SEE ALSO
* <http://logiclab.jira.com/wiki/display/OPEN/Versioning>
* version
* <http://search.cpan.org/dist/Perl-Critic/lib/Perl/Critic/Policy/Modu
les/RequireVersionVar.pm>
AUTHOR
* Jonas B. Nielsen, jonasbn "<jonasbn@cpan.org>"
LICENSE AND COPYRIGHT
Copyright (c) 2009-2014 Jonas B. Nielsen. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.