Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 68783
Status: open
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: RequireBriefOpen vs sub
Date: Mon, 13 Jun 2011 09:11:39 +1000
To: bug-Perl-Critic [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
The code below tickles RequireBriefOpen where I believe the close() is within 5 lines of the open() and so should not. Sticking in some printfs suggests _get_scope() has decided the whole file is the scope and then _find_close_invocations_or_return() excludes the "sub foo" from its search, return undef if $candidate->isa('PPI::Statement::Sub'); I expect that's meant to skip nested subrs in a block etc. Has _get_scope() gone too far out? Or _find_close_invocations_or_return() meant to know to include the sub which contains the open()?
Index: RequireBriefOpen.run =================================================================== --- RequireBriefOpen.run (revision 4082) +++ RequireBriefOpen.run (working copy) @@ -389,7 +389,22 @@ } #----------------------------------------------------------------------------- +## name close within same sub +## failures 0 +## TODO something wrong on subr scope +## cut +sub foo { + my $fh; + (open $fh, '>', $filename + and binmode($fh) + and print $fh "hello" + and close $fh) + or die; +} + +#----------------------------------------------------------------------------- + # Local Variables: # mode: cperl # cperl-indent-level: 4
On Sun Jun 12 19:11:49 2011, user42@zip.com.au wrote: Show quoted text
> The code below tickles RequireBriefOpen where I believe the close() is > within 5 lines of the open() and so should not. > > > Sticking in some printfs suggests _get_scope() has decided the whole > file is the scope and then _find_close_invocations_or_return() excludes > the "sub foo" from its search, > > return undef if $candidate->isa('PPI::Statement::Sub'); > > I expect that's meant to skip nested subrs in a block etc. Has > _get_scope() gone too far out? Or _find_close_invocations_or_return() > meant to know to include the sub which contains the open()?
I am seeing this as well, with P::C 1.118, on our in-house code. Randy -- Randy J. Ray rjray@blackperl.com randy.j.ray@gmail.com