Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyCommas3pm
Disallow empty consecutive commas
Overview
This policy is part of the "Perl::Critic::Pulp" add-on. It prohibits empty comma operators "," or "=>" meaning either consecutive commas or a comma at the start of a list or expression.
print 'foo',,'bar'; # bad@a = (,1,2); # badfoo (x, => 123); # bada =>=> 456; # badfor (; $i++<10; $i++,,) # badfunc (,) # bad
Extra commas like this are harmless and simply collapse out when the program runs (see "List value constructors" in perldata), so this policy is only under the "cosmetic" theme (see "POLICY THEMES" in Perl::Critic). Usually this sort of thing is just a stray, or leftover from cut and paste, or perhaps some over-enthusiastic column layout. Occasionally it can be something more dubious,
# did you mean 1..6 range operator?@a = (1,,6); # bad# this is two args, did you want three?foo (1, , 2); # bad# this is three args, probably you forgot a valuebar (abc => , # baddef => 20);
A comma at the end of a list or call is allowed. That's quite usual and can be a good thing when cutting and pasting lines (see "RequireTrailingCommas" to mandate them!).
@b = ("foo","bar", # ok);
If you use multiple commas in some systematic way for code layout you can always disable "ProhibitEmptyCommas" from your .perlcriticrc file in the usual way (see "CONFIGURATION" in Perl::Critic),
[-ValuesAndExpressions::ProhibitEmptyCommas]
Home page
http://user42.tuxfamily.org/perl-critic-pulp/index.html
Releases
4 releases since Debian 10 (Buster); the text changed 1 time.