Merge pull request #1044 from DeterminateSystems/perlcritic-level-3

Perlcritic level 3
This commit is contained in:
Graham Christensen 2021-10-20 17:06:26 -04:00 committed by GitHub
commit 30e50010f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 28 deletions

View file

@ -1,4 +1,4 @@
theme = community
# 5 is the least complainy, 1 is the most complainy
severity = 4
severity = 3

View file

@ -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"

View file

@ -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 });

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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([
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");

View file

@ -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>;