diff --git a/.perlcriticrc b/.perlcriticrc index 9d756697..bfc20693 100644 --- a/.perlcriticrc +++ b/.perlcriticrc @@ -1,4 +1,4 @@ theme = community # 5 is the least complainy, 1 is the most complainy -severity = 4 +severity = 3 diff --git a/flake.nix b/flake.nix index 1982e8b9..b723382b 100644 --- a/flake.nix +++ b/flake.nix @@ -499,7 +499,7 @@ buildInputs = [ makeWrapper autoconf automake libtool unzip nukeReferences pkgconfig libpqxx gitAndTools.topGit mercurial darcs subversion breezy openssl bzip2 libxslt - final.nix perlDeps perl mdbook + final.nix perlDeps perl mdbook pixz boost postgresql_11 (if lib.versionAtLeast lib.version "20.03pre" diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index e76ac18b..3881acbc 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; @@ -488,7 +488,7 @@ sub getTotalShares { } -sub cancelBuilds($$) { +sub cancelBuilds { my ($db, $builds) = @_; return $db->txn_do(sub { $builds = $builds->search({ finished => 0 }); @@ -505,7 +505,7 @@ sub cancelBuilds($$) { } -sub restartBuilds($$) { +sub restartBuilds { my ($db, $builds) = @_; $builds = $builds->search({ finished => 1 }); 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/TaskDispatcher.t b/t/TaskDispatcher.t index c055ce45..4bf3e8ed 100644 --- a/t/TaskDispatcher.t +++ b/t/TaskDispatcher.t @@ -87,24 +87,23 @@ sub make_fake_record { subtest "dispatch_event" => sub { subtest "every plugin gets called once, even if it fails all of them." => sub { - my @plugins = [make_noop_plugin("bogus-1"), make_noop_plugin("bogus-2")]; + my $plugins = [make_noop_plugin("bogus-1"), make_noop_plugin("bogus-2")]; - my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, @plugins); + my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, $plugins); my $event = make_failing_event("bogus-channel"); $dispatcher->dispatch_event($event); is(@{$event->{"called_with"}}, 2, "Both plugins should be called"); - my @expected_names = [ "bogus-1", "bogus-2" ]; - my @actual_names = sort([ - $event->{"called_with"}[0]->name, - $event->{"called_with"}[1]->name - ]); - + my @expected_names = ( "bogus-1", "bogus-2" ); + my @actual_names = sort( + $event->{"called_with"}[0]->name, + $event->{"called_with"}[1]->name + ); is( - @actual_names, - @expected_names, + \@actual_names, + \@expected_names, "Both plugins should be executed, but not in any particular order." ); }; @@ -113,9 +112,9 @@ subtest "dispatch_event" => sub { subtest "dispatch_task" => sub { subtest "every plugin gets called once" => sub { my $bogus_plugin = make_noop_plugin("bogus-1"); - my @plugins = [$bogus_plugin, make_noop_plugin("bogus-2")]; + my $plugins = [$bogus_plugin, make_noop_plugin("bogus-2")]; - my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, @plugins); + my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, $plugins); my $event = make_fake_event("bogus-channel"); my $task = Hydra::Task->new($event, ref $bogus_plugin); @@ -132,9 +131,9 @@ subtest "dispatch_task" => sub { subtest "a task with an invalid plugin is not fatal" => sub { my $bogus_plugin = make_noop_plugin("bogus-1"); - my @plugins = [$bogus_plugin, make_noop_plugin("bogus-2")]; + my $plugins = [$bogus_plugin, make_noop_plugin("bogus-2")]; - my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, @plugins); + my $dispatcher = Hydra::TaskDispatcher->new($db, $prometheus, $plugins); my $event = make_fake_event("bogus-channel"); my $task = Hydra::Task->new($event, "this-plugin-does-not-exist"); diff --git a/t/plugins/gitea.t b/t/plugins/gitea.t index 8180d5b3..56601b95 100644 --- a/t/plugins/gitea.t +++ b/t/plugins/gitea.t @@ -41,7 +41,7 @@ updateRepository('gitea', "$ctx{testdir}/jobs/git-update.sh", $scratch); ok(evalSucceeds($jobset), "Evaluating nix expression"); is(nrQueuedBuildsForJobset($jobset), 1, "Evaluating jobs/runcommand.nix should result in 1 build1"); - + (my $build) = queuedBuildsForJobset($jobset); ok(runBuild($build), "Build should succeed with exit code 0"); @@ -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>;