Name : perl-Perl-Critic-Policy-Variables-ProhibitUnusedVarsStricter
| |
Version : 0.114
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp154.1.1
| Date : 2023-01-27 17:41:43
|
Group : Unspecified
| Source RPM : perl-Perl-Critic-Policy-Variables-ProhibitUnusedVarsStricter-0.114-lp154.1.1.src.rpm
|
Size : 0.07 MB
| |
Packager : https://www_suse_com/
| |
Summary : Critique unused variables in Perl source
|
Description :
Unused variables clutter code and require the reader to do mental bookkeeping to figure out if the variable is actually used or not.
Right now, this only looks for lexical variables which are unused other than in the statement that declares them.
my $x; # not ok, assuming no other appearances. my AATTy = (); # not ok, assuming no other appearances. our $z; # ok, global. local $w; # ok, global.
This policy is a variant on the core policy Perl::Critic::Policy::Variables::ProhibitUnusedVariables which attempts to be more strict in its checking of whether a variable is used. The specific differences are:
* An attempt is made to take into account the scope of the declaration.
* An attempt is made to find variables which are interpolated into double-quotish strings (including regexes) and here documents.
* An attempt is made to find variables which are used in regular expression \'(?{...})\' and \'(??{...})\' constructions, and in the replacement portion of \'s/.../.../e\'.
* An attempt is made to find variables which are used in subroutine signatures.
This policy intentionally does not report variables as unused if the code takes a reference to the variable, even if it is otherwise unused. For example things like
\\( my $foo = \'bar\' ) \\do{ my $foo => \'bar\' }
will not be reported as a violation even if \'$foo\' is otherwise unused. The reason is that this is an idiom for making a reference to a mutable string when all you have is an immutable string. This policy does not check to see if anything is done with the reference.
This policy also does not detect unused variables declared inside various odd corners such as
s///e qr{(?{...})} qr{(??{...})} \"AATT{[ ... ]}\" ( $foo, my $bar ) = ( 1, 2 ) sub ( $foo = $bar ) { ... } # Signature, not prototype
Most of these are because the PPI parse of the original document does not include the declarations. The list assignment is missed because PPI does not parse it as containing a PPI::Statement::Variable. However, variables *used* inside such constructions *will* be detected.
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-P/15.4/noarch |