Kevin Ryde > Perl-Critic-Pulp > Perl::Critic::Policy::Documentation::ProhibitUnbalancedParens

Download:
Perl-Critic-Pulp-85.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 85   Source  

NAME ^

Perl::Critic::Policy::Documentation::ProhibitUnbalancedParens - don't leave an open bracket or paren

DESCRIPTION ^

This policy is part of the Perl::Critic::Pulp add-on. It reports unbalanced or mismatched parentheses, brackets and braces in POD text paragraphs,

    Blah blah (and something.    # bad

    Blah blah ( [ ).             # bad

    Blah blah brace }.           # bad

This is only cosmetic and normally only a minor irritant to readability so this policy is low priority and under the "cosmetic" theme (see "POLICY THEMES" in Perl::Critic).

Text and command paragraphs are checked, but verbatim paragraphs can have anything. There are some exceptions to paren balancing. The intention is to be forgiving of common or reasonable constructs. Currently this means,

Unrecognised Forms

A mathematical half-open range like the following is not recognised.

    [1,2)             # bad, currently

Perhaps just numbers like this would be unambiguous, but if it's an expression then it's hard to distinguish a parens typo from some mathematics. The suggestion for now is an =for per below to flag it as an exception. Another way would be to write 1 <= X < 2, which might be clearer to mathematically unsophisticated readers.

Parens spanning multiple paragraphs are not recognised,

    (This is some     # bad

    thing.)           # bad

Hopefully this is uncommon, and probably better style not to be parenthetical about something so big enough that it runs to multiple paragraphs or has a verbatim block in the middle etc.

Disabling

If an unbalanced paren is intended you can add an =for to tell ProhibitUnbalancedParens to allow it.

    =for ProhibitUnbalancedParens allow next

    Something ( deliberately unclosed.

Or with a count of paragraphs to ignore,

    =for ProhibitUnbalancedParens allow next 2

    First deliberate [ unclosed.

    Second (.

The usual no critic

    ## no critic (ProhibitUnbalancedParens)

works too as a whole-file disable, but the annotation must be before any __END__ token, and if the POD is after the __END__ then Perl::Critic 1.112 is required. Individual =for has the advantage of being with an exception.

As always if you don't care about this at all you can disable ProhibitUnbalancedParens completely from your .perlcriticrc in the usual way (see "CONFIGURATION" in Perl::Critic),

    [-Documentation::ProhibitUnbalancedParens]

BUGS ^

What should be done for =begin ... =end sections? Skip probably?

SEE ALSO ^

Perl::Critic::Pulp, Perl::Critic

HOME PAGE ^

http://user42.tuxfamily.org/perl-critic-pulp/index.html

COPYRIGHT ^

Copyright 2011, 2012, 2013, 2014 Kevin Ryde

Perl-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/>.

syntax highlighting: