perlcritic: each() called at line 752, column 35. The each function may cause undefined behavior when operating on the hash while iterating. Use a foreach loop over the hash's keys or values instead.

This commit is contained in:
Graham Christensen
2021-10-20 11:56:16 -04:00
parent 7dcf6a01c6
commit 4dfe787bc2
4 changed files with 16 additions and 8 deletions

View File

@ -64,7 +64,8 @@ sub updateDeclarativeJobset {
$db->txn_do(sub {
my $jobset = $project->jobsets->update_or_create(\%update);
$jobset->jobsetinputs->delete;
while ((my $name, my $data) = each %{$declSpec->{"inputs"}}) {
foreach my $name (keys %{$declSpec->{"inputs"}}) {
my $data = $declSpec->{"inputs"}{$name};
my $row = {
name => $name,
type => $data->{type}
@ -84,7 +85,8 @@ sub handleDeclarativeJobsetJson {
my @kept = keys %$declSpec;
push @kept, ".jobsets";
$project->jobsets->search({ name => { "not in" => \@kept } })->update({ enabled => 0, hidden => 1 });
while ((my $jobsetName, my $spec) = each %$declSpec) {
foreach my $jobsetName (keys %$declSpec) {
my $spec = $declSpec{$jobsetName};
eval {
updateDeclarativeJobset($db, $project, $jobsetName, $spec);
1;