perlcritic: don't open files as bare words

This commit is contained in:
Graham Christensen 2021-09-06 22:19:00 -04:00
parent efd1d78b97
commit 21e1ff0da1
5 changed files with 17 additions and 17 deletions

View file

@ -141,8 +141,8 @@ sub registerRoot {
my ($path) = @_; my ($path) = @_;
my $link = gcRootFor $path; my $link = gcRootFor $path;
return if -e $link; return if -e $link;
open ROOT, ">$link" or die "cannot create GC root `$link' to `$path'"; open my $root, ">$link" or die "cannot create GC root `$link' to `$path'";
close ROOT; close $root;
} }
@ -341,8 +341,8 @@ sub getMachines {
for my $machinesFile (@machinesFiles) { for my $machinesFile (@machinesFiles) {
next unless -e $machinesFile; next unless -e $machinesFile;
open CONF, "<$machinesFile" or die; open my $conf, "<$machinesFile" or die;
while (<CONF>) { while (<$conf>) {
chomp; chomp;
s/\#.*$//g; s/\#.*$//g;
next if /^\s*$/; next if /^\s*$/;
@ -358,7 +358,7 @@ sub getMachines {
, mandatoryFeatures => [ @mandatoryFeatures ] , mandatoryFeatures => [ @mandatoryFeatures ]
}; };
} }
close CONF; close $conf;
} }
return \%machines; return \%machines;

View file

@ -52,12 +52,12 @@ sub buildFinished {
my $tarballs = "$storePath/tarballs"; my $tarballs = "$storePath/tarballs";
my $covTarball; my $covTarball;
opendir TARBALLS, $tarballs or die; opendir my $tarballs_handle, $tarballs or die;
while (readdir TARBALLS) { while (readdir $tarballshandle) {
next unless $_ =~ /.*-coverity-int\.(tgz|lzma|xz|bz2|zip)$/; next unless $_ =~ /.*-coverity-int\.(tgz|lzma|xz|bz2|zip)$/;
$covTarball = "$tarballs/$_"; last; $covTarball = "$tarballs/$_"; last;
} }
closedir TARBALLS; closedir $tarballs_handle;
unless (defined $covTarball) { unless (defined $covTarball) {
print STDERR "CoverityScan.pm: Coverity tarball not found in $tarballs; skipping upload...\n"; print STDERR "CoverityScan.pm: Coverity tarball not found in $tarballs; skipping upload...\n";

View file

@ -26,9 +26,9 @@ my $client = Net::Amazon::S3::Client->new( s3 => Net::Amazon::S3->new( retry =>
my $db = Hydra::Model::DB->new(); my $db = Hydra::Model::DB->new();
my $gcRootsDir = getGCRootsDir; my $gcRootsDir = getGCRootsDir;
opendir DIR, $gcRootsDir or die; opendir my $dir, $gcRootsDir or die;
my @roots = readdir DIR; my @roots = readdir $dir;
closedir DIR; closedir $dir;
my @actual_roots = (); my @actual_roots = ();
foreach my $link (@roots) { foreach my $link (@roots) {

View file

@ -63,9 +63,9 @@ sub keepBuild {
# Read the current GC roots. # Read the current GC roots.
print STDERR "*** reading current roots...\n"; print STDERR "*** reading current roots...\n";
my $gcRootsDir = getGCRootsDir; my $gcRootsDir = getGCRootsDir;
opendir DIR, $gcRootsDir or die; opendir my $dir, $gcRootsDir or die;
my @roots = readdir DIR; my @roots = readdir $dir;
closedir DIR; closedir $dir;
# For scheduled builds, we register the derivation as a GC root. # For scheduled builds, we register the derivation as a GC root.

View file

@ -39,12 +39,12 @@ ok(-e "/tmp/s3/hydra/$successful_hash.nar", "The nar of a build that's a root is
ok(-e "/tmp/s3/hydra/$successful_hash.narinfo", "The narinfo of a build that's a root is not removed by gc"); ok(-e "/tmp/s3/hydra/$successful_hash.narinfo", "The narinfo of a build that's a root is not removed by gc");
my $gcRootsDir = getGCRootsDir; my $gcRootsDir = getGCRootsDir;
opendir DIR, $gcRootsDir or die; opendir my $dir, $gcRootsDir or die;
while(readdir DIR) { while(readdir $dir) {
next if $_ eq "." or $_ eq ".."; next if $_ eq "." or $_ eq "..";
unlink "$gcRootsDir/$_"; unlink "$gcRootsDir/$_";
} }
closedir DIR; closedir $dir;
system("hydra-s3-backup-collect-garbage"); system("hydra-s3-backup-collect-garbage");
ok(not -e "/tmp/s3/hydra/$successful_hash.nar", "The nar of a build that's not a root is removed by gc"); ok(not -e "/tmp/s3/hydra/$successful_hash.nar", "The nar of a build that's not a root is removed by gc");
ok(not -e "/tmp/s3/hydra/$successful_hash.narinfo", "The narinfo of a build that's not a root is removed by gc"); ok(not -e "/tmp/s3/hydra/$successful_hash.narinfo", "The narinfo of a build that's not a root is removed by gc");