Comment 2 for bug 1086527

Revision history for this message
gregor herrmann (gregoa) wrote : Re: [Pkg-perl-maintainers] [Bug 1086527] [NEW] Some false positives

On Tue, 04 Dec 2012 19:25:08 -0000, Pierre Rudloff wrote:

> With this file:
> https://svn.strasweb.fr/dl.php?repname=Pierre+Rudloff&path=%2Fperl%2FLatexRudloff.pl&rev=46
> I get some false positives:
> pierre@pierre-MacBook:/var/www/svn-rudloff/perl$ perlcritic --brutal LatexRudloff.pl
> Close filehandles as soon as possible after opening them at line 16, column 8. See page 209 of PBP. (Severity: 4)
> File handle for "print" or "printf" is not braced at line 37, column 17. See page 217 of PBP. (Severity: 1)
>
> I can't close the file handle sooner or it won't work.
> And $space is not a file handle so it does not need to be braced.

I just tried to run
% perlcritic --brutal --verbose 11 LatexRudloff.pl
to get more info.

As for the first issue, the diagnostic output says:

    This policy takes note of calls to `open()' where there is no matching
    `close()' call within `N' lines of code. If you really need to do a lot
    of processing on an open filehandle, then you can move that processing
    to another method like this: [..]

For the second one, `perldoc -f print' is interesting:

     (NOTE: If
     FILEHANDLE is a variable and the next token is a term, it may be misinterpreted as an operator unless you
     interpose a "+" or put parentheses around the arguments.)

What seems to work is

                print +( $space
                  . $space
                  . $numsec . q{.}
                  . $numsubsec . q{.}
                  . $numsubsubsec
                  . $dot
                  . $1 . "\n" )
                  or carp;

Cheers,
gregor

--
 .''`. Homepage: http://info.comodo.priv.at/ - OpenPGP key 0xBB3A68018649AA06
 : :' : Debian GNU/Linux user, admin, and developer - http://www.debian.org/
 `. `' Member of VIBE!AT & SPI, fellow of the Free Software Foundation Europe
   `- NP: Die Schmetterlinge: Hände über Hönnepel