Some false positives

Bug #1086527 reported by Pierre Rudloff
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libperl-critic-perl (Ubuntu)
New
Undecided
Unassigned

Bug Description

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.

ProblemType: Bug
DistroRelease: Ubuntu 12.10
Package: libperl-critic-perl 1.117-2
ProcVersionSignature: Ubuntu 3.5.0-19.30-generic 3.5.7
Uname: Linux 3.5.0-19-generic i686
ApportVersion: 2.6.1-0ubuntu6
Architecture: i386
Date: Tue Dec 4 20:21:41 2012
MarkForUpload: True
PackageArchitecture: all
SourcePackage: libperl-critic-perl
UpgradeStatus: Upgraded to quantal on 2012-10-25 (40 days ago)

Revision history for this message
Pierre Rudloff (rudloff) wrote :
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

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.