From 7095d0060893d859358ef308a0c10fa2e2cbd562 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Tue, 19 Oct 2021 22:37:17 -0400 Subject: [PATCH] perlcritic: make all open() calls three-argument Two-argument calls end up parsing the second argument to guess what should happen, three-arg parses ... less? --- src/lib/Hydra/Helper/Nix.pm | 4 ++-- src/lib/Hydra/View/NixClosure.pm | 2 +- src/lib/Hydra/View/NixLog.pm | 8 ++++---- src/lib/Hydra/View/NixNAR.pm | 2 +- t/plugins/gitea.t | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index e76ac18b..00c1c6a7 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -141,7 +141,7 @@ sub registerRoot { my ($path) = @_; my $link = gcRootFor $path; return if -e $link; - open my $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; } @@ -342,7 +342,7 @@ sub getMachines { for my $machinesFile (@machinesFiles) { next unless -e $machinesFile; - open my $conf, "<$machinesFile" or die; + open(my $conf, "<", $machinesFile) or die; while (my $line = <$conf>) { chomp; s/\#.*$//g; diff --git a/src/lib/Hydra/View/NixClosure.pm b/src/lib/Hydra/View/NixClosure.pm index c157af6b..f1e462d2 100644 --- a/src/lib/Hydra/View/NixClosure.pm +++ b/src/lib/Hydra/View/NixClosure.pm @@ -14,7 +14,7 @@ sub process { my $fh = IO::Handle->new(); - open $fh, "nix-store --export `nix-store -qR @storePaths` | gzip |"; + open($fh, "-|", "nix-store --export `nix-store -qR @storePaths` | gzip"); $c->response->body($fh); diff --git a/src/lib/Hydra/View/NixLog.pm b/src/lib/Hydra/View/NixLog.pm index c2146bd4..7f37ae78 100644 --- a/src/lib/Hydra/View/NixLog.pm +++ b/src/lib/Hydra/View/NixLog.pm @@ -17,13 +17,13 @@ sub process { my $tail = int($c->stash->{tail} // "0"); if ($logPath =~ /\.bz2$/) { - my $doTail = $tail ? " tail -n '$tail' |" : ""; - open $fh, "bzip2 -dc < '$logPath' | $doTail" or die; + my $doTail = $tail ? "| tail -n '$tail'" : ""; + open($fh, "-|", "bzip2 -dc < '$logPath' $doTail") or die; } else { if ($tail) { - open $fh, "tail -n '$tail' '$logPath' |" or die; + open($fh, "-|", "tail -n '$tail' '$logPath'") or die; } else { - open $fh, "<$logPath" or die; + open($fh, "<", $logPath) or die; } } binmode($fh); diff --git a/src/lib/Hydra/View/NixNAR.pm b/src/lib/Hydra/View/NixNAR.pm index cae43275..a3b85818 100644 --- a/src/lib/Hydra/View/NixNAR.pm +++ b/src/lib/Hydra/View/NixNAR.pm @@ -16,7 +16,7 @@ sub process { my $fh = IO::Handle->new(); - open $fh, "nix-store --dump '$storePath' | pixz -0 $pParam |"; + open($fh, "-|", "nix-store --dump '$storePath' | pixz -0 $pParam"); setCacheHeaders($c, 365 * 24 * 60 * 60); diff --git a/t/plugins/gitea.t b/t/plugins/gitea.t index 8180d5b3..9fc7d213 100644 --- a/t/plugins/gitea.t +++ b/t/plugins/gitea.t @@ -60,7 +60,7 @@ if (!defined($pid = fork())) { kill('INT', $pid); } -open my $fh, $filename or die ("Can't open(): $!\n"); +open(my $fh, "<", $filename) or die ("Can't open(): $!\n"); my $i = 0; my $uri = <$fh>; my $data = <$fh>;