Subject: | ValuesAndExpressions::ProhibitCommaSeparatedStatements false-positive in anon hash reference |
The attachment exhibits this behavior. Two ways of fixing it are also
listed, currently commented-out in the code.
Basically, this form:
$self = bless { %something, something_extra => 1 }, $class;
triggers the ProhibitCommaSeparatedStatements message, even though Perl
properly treats it as a hash reference, not a code block. While this can
be fixed by slight changes to the syntax (see the commented-out lines in
the attachment), it seems that the above should be considered valid code
by Critic.
--
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Randy J. Ray Silicon Valley Scale Modelers:
http://www.svsm.org
rjray@blackperl.com
randy.j.ray@gmail.com
Subject: | Foo.pm |
package Foo;
use strict;
use warnings;
sub new {
my ($class, %args) = @_;
my $self = bless { %args, extra => 1 }, $class;
#my $self = bless +{ %args, extra => 1 }, $class;
#my $self = { %args, extra => 1 };
#bless $self, $class;
return $self;
}
1;