Perlcritic Thinks Hashes are Statements Separated by Commas

118 Views Asked by At

I'm getting a perlcritic violation that makes no sense for blocks of code like the following:

$object->insert(
    {   
        %defaults,
        name => 'TEST',
        line => 1,
        keywords => 'TEST OBJECT',
        %overrides
    }
);

Perlcritic 1.117 says "Comma used to separate statements at line 880, column 4. See pages 68,71 of PBP."

I can only assume that perlcritic is mis-identifying these hashes as code blocks.

I've disabled it by inserting "## no critic (ProhibitCommaSeparatedStatements)" at the top of each such "block," but is there a better way to deal with this?

1

There are 1 best solutions below

0
On

I believe the problem is that it gets confused by %defaults and %overrides. I bet if you removed those, it wouldn't complain any more.

I ran into this the other day and just haven't yet written up a ticket.