NAME
Perl::Critic::Policy::Variables::ProhibitUselessInitialization - prohibit superfluous initializations
DESCRIPTION
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?
AUTHOR
John Trammell <johntrammell -at- gmail -dot- com>
COPYRIGHT
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.
desc()
Returns a string containing a sort description of this policy.
expl()
Returns a string containing an explanation of this policy.
supported_parameters
Define parameters supported by this policy. There are none.
default_severity
Returns a numeric constant defining the severity of violating this policy.
default_themes
Returns a list of strings defining the themes for this policy.
applies_to
Returns a string describing the elements to which this policy applies.
violates
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
.
violates_scalar($elem)
Returns true if $elem
contains an assignment of the form
my $foo = undef;
See http://search.cpan.org/dist/PPI/lib/PPI/Statement/Variable.pm for details on how this function works.
violates_list($elem)
Returns true if $elem
contains an assignment of the forms:
my @foo = (); # useless array init
my %bar = (); # useless hash init