Perl::...ersion(3pm)
okay so bestie π welcome to the Perl::Critic::Policy::ValuesAndExpressions::ProhibitComplexVersion manual page β yep, the one whose header gets squished down to Perl::...ersion(3pm) β brought to you by User Contributed Perl Documentation. grab a strawberry π and letβs get into it.
πΈ NAME πΈ
Perl::Critic::Policy::ValuesAndExpressions::ProhibitComplexVersion β Prohibit version values from outside the module.
π AFFILIATION π
This Policy is part of the core Perl::Critic distribution. iconic behavior, honestly π.
β¨ DESCRIPTION β¨
okay so hereβs the tempting idea: keep a whole group of related modules at the same version number by having all of them import the version number from one designated module. for example, module Foo::Master could be the version master for the Foo package, and all the other modules could use its $VERSION like this:
use Foo::Master; our $VERSION = $Foo::Master::VERSION;
and ngl, this turns out not to be a good idea π. all sorts of unintended things can happen β anything from unintended version number changes to denial-of-service attacks (since Foo::Master is executed by the 'use').
this policy examines statements that assign to $VERSION, and it declares a violation under two circumstances:
- first, if that statement uses a fully-qualified symbol that did not originate in a package declared in the file;
- second, if there is a
usestatement on the same line that makes the assignment.
by default, an exception is made for use version; because of its recommendation by Perl Best Practices. see the forbid_use_version configuration variable if you do not want an exception made for use version;. π
π οΈ CONFIGURATION π οΈ
the construction
use version; our $VERSION = qv('1.2.3');
is exempt from this policy by default, because it is recommended by Perl Best Practices. should you wish to identify use version; as a violation, add the following to your perlcriticrc file:
[ValuesAndExpressions::ProhibitComplexVersion]
forbid_use_version = 1
slay, thatβs the whole config vibe πβ¨
π CAVEATS π
this code assumes that the hallmark of a violation is a 'use' on the same line as the $VERSION assignment, because that is the way to have it seen by ExtUtils::MakeMaker->parse_version(). other ways to get a version value from outside the module can be imagined, and this policy is currently oblivious to them. no cap, thatβs the caveat π«Ά.
π AUTHOR π
Thomas R. Wyant, III wyant at cpan dot org
π COPYRIGHT π
Copyright (c) 2009-2023 Tom Wyant
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. the full text of this license can be found in the LICENSE file included with this module. periodt π
this page was served fresh from perl v5.42.0 on 2024-10-23 πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Perl-Critic 1.156.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms