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: 62621
Status: resolved
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: danrumney [...] warpmail.net
Cc:
AdminCc:

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



Subject: False positive for 'Subroutine "XXX" does not end with "return"'
I ran Perl::Critic against a script and received the following: Subroutine "notify_high_key_usage" does not end with "return" I've attached the file 'notify_high_key_usage.pl' which contains that function in its entirety. By my eyeballing, there's a clear return; at the end of the sub and no other possible exit points. I can't see anything arcane in that sub that would lead to Perl::Critic::Policy::Subroutines::RequireFinalReturn getting confused... but maybe I'm wrong. This was discovered using Strawberry Perl v 5.10.1.0 on a Windows XP system.
Subject: notify_high_key_usage.pl
sub notify_high_key_usage { my $warnings = shift; my $flag_file = File::Spec->catfile( File::Spec->rootdir(), 'var','svcDaemonNotified'); my $logger = Log::Log4perl->get_logger('daemon'); my $notification_sent; # Check to see if there is a flag if ( -e $flag_file ) { my ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks ) = stat $flag_file; # # Only send notification once every 24 hours # if ( ( time - $mtime ) < 86_400 ) { $notification_sent = 1; } } if ( !$notification_sent ) { my $warnings_list = join "\n", @{$warnings}); my $message = <<"MESSAGE"; Warning Notice -------------- $warnings_list Please resolve these ASAP You will received another notification in 24 hours MESSAGE my %mail_info = ( To => 'configbrowser_cmvc@localhost', From => 'configbrowser_cmvc@' . hostname, Subject => 'Key Usage Warning', Message => $message, ); if ( sendmail(%mail_info) ) { $logger->info('Sent warning email'); # # Indicate that notification has been sent # (creates an empty file) # my $flag_fh = IO::File->new( $flag_file, 'w' ); if($flag_fh) { $flag_fh->close(); } else { $logger->error("Couldn't update flag file '$flag_file': $OS_ERROR"); } } else { $logger->error('Failed to send warning email'); } } return; }
On Mon Nov 01 13:48:43 2010, dancrumb wrote: Show quoted text
> I ran Perl::Critic against a script and received the following: > Subroutine "notify_high_key_usage" does not end with "return" > > I've attached the file 'notify_high_key_usage.pl' which contains that > function in its entirety. > > By my eyeballing, there's a clear return; at the end of the sub and no > other possible exit points. I can't see anything arcane in that sub that > would lead to Perl::Critic::Policy::Subroutines::RequireFinalReturn > getting confused... but maybe I'm wrong. > > This was discovered using Strawberry Perl v 5.10.1.0 on a Windows XP
system. Does the attached file compile on your system? It fails under 5.10.1 on mine, giving $ perl ../notify_high_key_usage.pl syntax error at ../notify_high_key_usage.pl line 24, near "})" Execution of ../notify_high_key_usage.pl aborted due to compilation errors. I'm afraid the results of a Perl::Critic analysis on a file that is not syntactically valid Perl have to be considered undefined. Eyeballing line 24 shows what appears to be a close parenthesis without a matching open parenthesis. If I remove the apparently-offending close parenthesis, the file not only compiles but passes Subroutines::RequireFinalReturn.
Subject: Re: [rt.cpan.org #62621] False positive for 'Subroutine "XXX" does not end with "return"'
Date: Mon, 01 Nov 2010 13:34:52 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Dan Rumney <danrumney [...] warpmail.net>
Ack! I'm going to blame Perl:EPIC for that ;) Turns out that Perl:EPIC (a plugin to Eclipse, if you're not aware of it) doesn't do a great job of finding syntax errors on the fly. I followed your steps and, indeed, that was the problem... sorry about burning your time like that... and thank you for the speedy feedback! Go ahead and close this bug report. Dan On 11/1/2010 1:30 PM, Tom Wyant via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=62621> > > On Mon Nov 01 13:48:43 2010, dancrumb wrote:
>> I ran Perl::Critic against a script and received the following: >> Subroutine "notify_high_key_usage" does not end with "return" >> >> I've attached the file 'notify_high_key_usage.pl' which contains that >> function in its entirety. >> >> By my eyeballing, there's a clear return; at the end of the sub and no >> other possible exit points. I can't see anything arcane in that sub that >> would lead to Perl::Critic::Policy::Subroutines::RequireFinalReturn >> getting confused... but maybe I'm wrong. >> >> This was discovered using Strawberry Perl v 5.10.1.0 on a Windows XP
> system. > > Does the attached file compile on your system? It fails under 5.10.1 on > mine, giving > > $ perl ../notify_high_key_usage.pl > syntax error at ../notify_high_key_usage.pl line 24, near "})" > Execution of ../notify_high_key_usage.pl aborted due to compilation errors. > > I'm afraid the results of a Perl::Critic analysis on a file that is not > syntactically valid Perl have to be considered undefined. > > Eyeballing line 24 shows what appears to be a close parenthesis without > a matching open parenthesis. If I remove the apparently-offending close > parenthesis, the file not only compiles but passes > Subroutines::RequireFinalReturn.
On Mon Nov 01 14:35:13 2010, dancrumb wrote: Show quoted text
> Ack! > > I'm going to blame Perl:EPIC for that ;) > > Turns out that Perl:EPIC (a plugin to Eclipse, if you're not aware of > it) doesn't do a great job of finding syntax errors on the fly. > > I followed your steps and, indeed, that was the problem... sorry about > burning your time like that... and thank you for the speedy feedback!
No problem. Not that much time burnt in the first place. And if I were to make it a problem, I would have to start in on myself before anyone else, since I have filed my share of reports that turned out to be bogus. Show quoted text
> > Go ahead and close this bug report. >
Will do. Thanks for letting us know the resolution so we can in fact do that.