From 741590c9231c1db360700ce5eae1e49db540a756 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 7 Sep 2021 21:53:07 -0400 Subject: [PATCH] perlcritic: explicitly assign the result of readdir/file reads --- src/lib/Hydra/Helper/Nix.pm | 4 ++-- src/lib/Hydra/Plugin/CoverityScan.pm | 6 +++--- src/lib/Hydra/Plugin/SoTest.pm | 4 ++-- t/s3-backup-test.pl | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index 063e053e..e76ac18b 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -343,11 +343,11 @@ sub getMachines { for my $machinesFile (@machinesFiles) { next unless -e $machinesFile; open my $conf, "<$machinesFile" or die; - while (<$conf>) { + while (my $line = <$conf>) { chomp; s/\#.*$//g; next if /^\s*$/; - my @tokens = split /\s/, $_; + my @tokens = split /\s/, $line; my @supportedFeatures = split(/,/, $tokens[5] || ""); my @mandatoryFeatures = split(/,/, $tokens[6] || ""); $machines{$tokens[0]} = diff --git a/src/lib/Hydra/Plugin/CoverityScan.pm b/src/lib/Hydra/Plugin/CoverityScan.pm index 472b8e7e..c7b39d02 100644 --- a/src/lib/Hydra/Plugin/CoverityScan.pm +++ b/src/lib/Hydra/Plugin/CoverityScan.pm @@ -53,9 +53,9 @@ sub buildFinished { my $covTarball; opendir my $tarballs_handle, $tarballs or die; - while (readdir $tarballshandle) { - next unless $_ =~ /.*-coverity-int\.(tgz|lzma|xz|bz2|zip)$/; - $covTarball = "$tarballs/$_"; last; + while (my $file = readdir $tarballshandle) { + next unless $file =~ /.*-coverity-int\.(tgz|lzma|xz|bz2|zip)$/; + $covTarball = "$tarballs/$file"; last; } closedir $tarballs_handle; diff --git a/src/lib/Hydra/Plugin/SoTest.pm b/src/lib/Hydra/Plugin/SoTest.pm index e3abf4cc..5b45f153 100644 --- a/src/lib/Hydra/Plugin/SoTest.pm +++ b/src/lib/Hydra/Plugin/SoTest.pm @@ -102,8 +102,8 @@ sub buildFinished { open( $authfile, "<", $sotest->{authfile} ) or die "Cannot open Sotest authfile \${\$sotest->{authfile}}"; - while (<$authfile>) { - if ( $_ =~ /(.+):(.+)/m ) { + while (my $line = <$authfile>) { + if ( $line =~ /(.+):(.+)/m ) { $sotest_username = $1; $sotest_password = $2; } diff --git a/t/s3-backup-test.pl b/t/s3-backup-test.pl index 825162d3..9332ab15 100644 --- a/t/s3-backup-test.pl +++ b/t/s3-backup-test.pl @@ -40,9 +40,9 @@ ok(-e "/tmp/s3/hydra/$successful_hash.narinfo", "The narinfo of a build that's a my $gcRootsDir = getGCRootsDir; opendir my $dir, $gcRootsDir or die; -while(readdir $dir) { - next if $_ eq "." or $_ eq ".."; - unlink "$gcRootsDir/$_"; +while(my $file = readdir $dir) { + next if $file eq "." or $file eq ".."; + unlink "$gcRootsDir/$file"; } closedir $dir; system("hydra-s3-backup-collect-garbage");