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;
}