Merge pull request #1043 from DeterminateSystems/perl-warnings

Fixup Perl warnings around undefined variables
This commit is contained in:
Graham Christensen
2021-10-20 10:48:05 -04:00
committed by GitHub
7 changed files with 19 additions and 12 deletions

View File

@ -10,7 +10,7 @@ use Hydra::Helper::CatalystUtils;
sub isEnabled {
my ($self) = @_;
return $self->{config}->{enable_bitbucket_status} == 1;
return ($self->{config}->{enable_bitbucket_status} // 0) == 1;
}
sub toBitBucketState {

View File

@ -53,7 +53,7 @@ sub buildFinished {
my $covTarball;
opendir my $tarballs_handle, $tarballs or die;
while (my $file = readdir $tarballshandle) {
while (my $file = readdir $tarballs_handle) {
next unless $file =~ /.*-coverity-int\.(tgz|lzma|xz|bz2|zip)$/;
$covTarball = "$tarballs/$file"; last;
}

View File

@ -12,7 +12,7 @@ use Hydra::Helper::Email;
sub isEnabled {
my ($self) = @_;
return $self->{config}->{email_notification} == 1;
return ($self->{config}->{email_notification} // 0) == 1;
}
my $template = <<EOF;

View File

@ -34,7 +34,7 @@ sub _parseValue {
my $start_options = 3;
# if deepClone has "=" then is considered an option
# and not the enabling of deepClone
if (index($deepClone, "=") != -1) {
if (defined($deepClone) && index($deepClone, "=") != -1) {
undef $deepClone;
$start_options = 2;
}

View File

@ -97,8 +97,8 @@ sub _iterate {
}
sub fetchInput {
my ($self, $type, $name, $value, $project, $jobset) = @_;
return undef if $type ne "github_refs";
my ($self, $input_type, $name, $value, $project, $jobset) = @_;
return undef if $input_type ne "github_refs";
my ($owner, $repo, $type, $fut, $prefix) = split ' ', $value;
die "type field is neither 'heads' nor 'tags', but '$type'"

View File

@ -21,11 +21,18 @@ sub isEnabled {
}
my $client;
my %compressors = (
xz => "| $Nix::Config::xz",
bzip2 => "| $Nix::Config::bzip2",
none => ""
);
my %compressors = ();
$compressors{"none"} = "";
if (defined($Nix::Config::bzip2)) {
$compressors{"bzip2"} = "| $Nix::Config::bzip2",
}
if (defined($Nix::Config::xz)) {
$compressors{"xz"} = "| $Nix::Config::xz",
}
my $lockfile = Hydra::Model::DB::getHydraPath . "/.hydra-s3backup.lock";
sub buildFinished {