|
NAMEPerl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyCommas - disallow empty consecutive commasDESCRIPTIONThis 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); # bad foo (x, => 123); # bad a =>=> 456; # bad for (; $i++<10; $i++,,) # bad func (,) # 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 value bar (abc => , # bad def => 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] SEE ALSOPerl::Critic::Pulp, Perl::Critic, Perl::Critic::Policy::CodeLayout::RequireTrailingCommas, Perl::Critic::Policy::ValuesAndExpressions::ProhibitCommaSeparatedStatements, Perl::Critic::Policy::Tics::ProhibitManyArrowsHOME PAGEhttp://user42.tuxfamily.org/perl-critic-pulp/index.htmlCOPYRIGHTCopyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 Kevin RydePerl-Critic-Pulp is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. Perl-Critic-Pulp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>.
Visit the GSP FreeBSD Man Page Interface. |