first round of Perl::Critic cleanups. Do not use return undef, use a bare return instead

This commit is contained in:
Colin Kuskie 2007-12-05 00:30:43 +00:00
parent 75041656ee
commit 96178fd70c
92 changed files with 209 additions and 209 deletions

View file

@ -704,7 +704,7 @@ sub getRecurrenceDates {
my %date;
my $recur = {$self->getRecurrence};
return undef unless $recur->{recurType};
return unless $recur->{recurType};
my %dayNames = (
monday => "m",

View file

@ -233,7 +233,7 @@ Returns a toolbar with a set of icons that hyperlink to functions that delete, e
sub getToolbar {
my $self = shift;
return undef if ($self->getToolbarState);
return if ($self->getToolbarState);
return $self->SUPER::getToolbar();
}

View file

@ -48,7 +48,7 @@ sub addChild {
my @other = @_;
if ($properties->{className} ne "WebGUI::Asset::Post") {
$self->session->errorHandler->security("add a ".$properties->{className}." to a ".$self->get("className"));
return undef;
return;
}
return $self->SUPER::addChild($properties, @other);
}
@ -371,7 +371,7 @@ sub getEditUrl {
#-------------------------------------------------------------------
sub getImageUrl {
my $self = shift;
return undef if ($self->get("storageId") eq "");
return if ($self->get("storageId") eq "");
my $storage = $self->getStorageLocation;
my $url;
foreach my $filename (@{$storage->getFiles}) {
@ -578,7 +578,7 @@ sub getThread {
#-------------------------------------------------------------------
sub getThumbnailUrl {
my $self = shift;
return undef if ($self->get("storageId") eq "");
return if ($self->get("storageId") eq "");
my $storage = $self->getStorageLocation;
my $url;
foreach my $filename (@{$storage->getFiles}) {
@ -663,8 +663,8 @@ An integer indicating either thumbss up (+1) or thumbs down (-1)
sub insertUserPostRating {
my $self = shift;
my $rating = shift;
return undef unless ($rating == -1 || $rating == 1);
return undef if $self->hasRated;
return unless ($rating == -1 || $rating == 1);
return if $self->hasRated;
$self->session->db->write("insert into Post_rating (assetId,userId,ipAddress,dateOfRating,rating) values (?,?,?,?,?)",
[$self->getId,
$self->session->user->userId,
@ -914,8 +914,8 @@ An integer indicating either thumbss up (+1) or thumbs down (-1)
sub rate {
my $self = shift;
my $rating = shift;
return undef unless ($rating == -1 || $rating == 1);
return undef if $self->hasRated;
return unless ($rating == -1 || $rating == 1);
return if $self->hasRated;
$self->insertUserPostRating($rating);
$self->recalculatePostRating();
$self->getThread->updateThreadRating();

View file

@ -584,8 +584,8 @@ An integer between 1 and 5 (5 being best) to rate this post with.
sub rate {
my $self = shift;
my $rating = shift;
return undef unless ($rating == -1 || $rating == 1);
return undef if $self->hasRated;
return unless ($rating == -1 || $rating == 1);
return if $self->hasRated;
$self->SUPER::rate($rating);
##Thread specific karma adjustment for CS

View file

@ -159,7 +159,7 @@ if there is no such feed.
sub getRssUrl {
my $self = shift;
my $rssFromParentId = $self->get('rssCapableRssFromParentId');
return undef unless defined $rssFromParentId;
return unless defined $rssFromParentId;
WebGUI::Asset->newByDynamicClass($self->session, $rssFromParentId)->getUrl;
}

View file

@ -422,7 +422,7 @@ Returns a toolbar with a set of icons that hyperlink to functions that delete, e
sub getToolbar {
my $self = shift;
return undef if ($self->getToolbarState);
return if ($self->getToolbarState);
return $self->SUPER::getToolbar();
}

View file

@ -364,7 +364,7 @@ sub getOverridesList {
$output .= '<table cellspacing="0" cellpadding="3" border="1">';
$output .= '<tr class="tableHeader"><td>'.$i18n->get('fieldName').'</td><td>'.$i18n->get('edit delete fieldname').'</td><td>'.$i18n->get('Original Value').'</td><td>'.$i18n->get('New value').'</td><td>'.$i18n->get('Replacement value').'</td></tr>';
my $shortcut = $self->getShortcutOriginal;
return undef unless defined $shortcut;
return unless defined $shortcut;
foreach my $definition (@{$shortcut->definition($self->session)}) {
foreach my $prop (keys %{$definition->{properties}}) {
next if $definition->{properties}{$prop}{fieldType} eq 'hidden';

View file

@ -117,7 +117,7 @@ Returns a toolbar with a set of icons that hyperlink to functions that delete, e
sub getToolbar {
my $self = shift;
return undef if ($self->getToolbarState);
return if ($self->getToolbarState);
return '<p>'.$self->SUPER::getToolbar().'</p>';
}

View file

@ -27,7 +27,7 @@ You can't add children to a wiki page.
=cut
sub addChild {
return undef;
return;
}
#-------------------------------------------------------------------
@ -185,7 +185,7 @@ sub getEditForm {
sub getWiki {
my $self = shift;
my $parent = $self->getParent;
return undef unless defined $parent and $parent->isa('WebGUI::Asset::Wobject::WikiMaster');
return unless defined $parent and $parent->isa('WebGUI::Asset::Wobject::WikiMaster');
return $parent;
}

View file

@ -257,7 +257,7 @@ sub addChild {
if ($properties->{className} ne "WebGUI::Asset::Event") {
$self->session->errorHandler->security("add a ".$properties->{className}." to a ".$self->get("className"));
return undef;
return;
}
return $self->SUPER::addChild($properties, @other);

View file

@ -80,7 +80,7 @@ sub addChild {
if ($properties->{className} ne "WebGUI::Asset::Post::Thread"
and $properties->{className} ne 'WebGUI::Asset::RSSFromParent') {
$self->session->errorHandler->security("add a ".$properties->{className}." to a ".$self->get("className"));
return undef;
return;
}
return $self->SUPER::addChild($properties, @other);
}

View file

@ -264,11 +264,11 @@ sub addToScratchCart {
my $scratchCart = $self->session->scratch->get('EMS_scratch_cart');
my @eventsInCart = split("\n",$scratchCart);
my ($isApproved) = $self->session->db->quickArray("select approved from EventManagementSystem_products where productId = ?",[$event]);
return undef unless $isApproved;
return unless $isApproved;
unless (scalar(@eventsInCart) || $scratchCart) {
# the cart is empty, so check if this is a master event or not.
my ($isChild) = $self->session->db->quickArray("select prerequisiteId from EventManagementSystem_products where productId = ?",[$event]);
return undef if $isChild;
return if $isChild;
$self->session->scratch->set('currentMainEvent',$event);
$self->session->scratch->set('EMS_scratch_cart', $event);
return $event;
@ -276,7 +276,7 @@ sub addToScratchCart {
# check if event is actually available.
my ($numberRegistered) = $self->session->db->quickArray("select count(*) from EventManagementSystem_registrations as r, EventManagementSystem_purchases as p, transaction as t where t.transactionId=p.transactionId and t.status='Completed' and r.purchaseId = p.purchaseId and r.returned=0 and r.productId=?",[$event]);
my ($maxAttendees) = $self->session->db->quickArray("select maximumAttendees from EventManagementSystem_products where productId=?",[$event]);
return undef unless ($self->canApproveEvents || ($maxAttendees > $numberRegistered));
return unless ($self->canApproveEvents || ($maxAttendees > $numberRegistered));
my $bid = $self->session->scratch->get('currentBadgeId');
my @pastEvents = ($bid)?$self->session->db->buildArray("select r.productId from EventManagementSystem_registrations as r, EventManagementSystem_purchases as p, transaction as t where r.returned=0 and r.badgeId=? and t.transactionId=p.transactionId and t.status='Completed' and p.purchaseId=r.purchaseId group by productId",[$bid]):();

View file

@ -97,7 +97,7 @@ sub definition {
#-------------------------------------------------------------------
sub duplicate {
# Buggo: how do we duplicate these?
return undef;
return;
}

View file

@ -444,12 +444,12 @@ sub getProjectInstance {
my $session = shift;
my $db = $session->db;
my $projectId = $_[0];
return undef unless $projectId;
return unless $projectId;
my ($assetId) = $db->quickArray("select assetId from PM_project where projectId=?",[$projectId]);
if($assetId) {
return WebGUI::Asset->newByDynamicClass($session,$assetId);
}
return undef;
return;
}
#-------------------------------------------------------------------

View file

@ -824,8 +824,8 @@ recent revision will be fetched.
sub _getFileFromDatabase {
my ($constraint, $dbLink);
my $self = shift;
my $recordId = shift || return undef;
my $fieldName = shift || return undef;
my $recordId = shift || return;
my $fieldName = shift || return;
my $revision = shift;
$dbLink = $self->_getDbLink;
@ -4088,7 +4088,7 @@ sub _constructSearchQuery {
my $searchType = ($self->session->form->process("searchType") || $self->session->scratch->get('SQLForm_'.$self->getId.'searchType')) eq 'and' ? 'and' : 'or';
return undef if (!@constraints);
return if (!@constraints);
# Construct the search query
my $sortField = @sortClauses ? ('('.join('+', @sortClauses).') AS sqlform_orderby') : '1 AS sqlform_orderby';

View file

@ -154,7 +154,7 @@ sub _convertToEpoch {
my $time = $_[1];
unless ($date =~ m{^\d+/\d+/\d+} and $time =~ m{^\d+:\d+}) {
return undef;
return;
}
my ($month,$day,$year) = split("/",$date);

View file

@ -289,7 +289,7 @@ sub _find_record {
}
}
return undef;
return;
}
#-------------------------------------------------------------------
@ -348,7 +348,7 @@ sub _get_rss_data {
if (!$response->is_success()) {
$session->errorHandler->warn("Error retrieving url '$url': " .
$response->status_line());
return undef;
return;
}
my $xml = $response->content();
@ -380,7 +380,7 @@ sub _get_rss_data {
$session->errorHandler->warn("error parsing rss for url $url :".$@);
#Returning undef on a parse failure is a change from previous behaviour,
#but it SHOULDN'T have a major effect.
return undef;
return;
}
# make sure that the {channel} points to the channel