Perl::Critic::Policy::Variables::ProhibitUselessInitialization - prohibit superfluous initializations
Don't clutter your code with unnecessary variable initialization:
my $scalar = undef; # don't do this my @array = (); # or this my %hash = (); # or this
Instead, do this:
my $scalar; # equivalent my @array; # ditto my %hash; # isn't that better?
John Trammell <johntrammell -at- gmail -dot- com>
Copyright (c) John Joseph Trammell. All rights reserved.
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.
Returns a string containing a sort description of this policy.
Returns a string containing an explanation of this policy.
Define parameters supported by this policy. There are none.
Returns a numeric constant defining the severity of violating this policy.
Returns a list of strings defining the themes for this policy.
Returns a string describing the elements to which this policy applies.
Method to determine if the element currently under scrutiny violates this policy. If it does, return a properly constructed Perl::Critic::Violation object. Otherwise, return undef.
Perl::Critic::Violation
undef
Returns true if $elem contains an assignment of the form
$elem
my $foo = undef;
See http://search.cpan.org/dist/PPI/lib/PPI/Statement/Variable.pm for details on how this function works.
Returns true if $elem contains an assignment of the forms:
my @foo = (); # useless array init my %bar = (); # useless hash init
To install Perl::Critic::PetPeeves::JTRAMMELL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::Critic::PetPeeves::JTRAMMELL
CPAN shell
perl -MCPAN -e shell install Perl::Critic::PetPeeves::JTRAMMELL
For more information on module installation, please visit the detailed CPAN module installation guide.