Merge pull request #1003 from DeterminateSystems/perlcritic-level-4

perlcritic: level 4
This commit is contained in:
Eelco Dolstra
2021-09-27 20:23:55 +02:00
committed by GitHub
98 changed files with 163 additions and 60 deletions

View File

@ -8,11 +8,10 @@ use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
use Hydra::Controller::Project;
use JSON;
use JSON::Any;
use JSON::MaybeXS;
use DateTime;
use Digest::SHA qw(sha256_hex);
use Text::Diff;
use File::Slurp;
use IPC::Run qw(run);
@ -67,7 +66,7 @@ sub latestbuilds : Chained('api') PathPart('latestbuilds') Args(0) {
push @list, buildToHash($_) foreach @latest;
$c->stash->{'plain'} = {
data => scalar (JSON::Any->objToJson(\@list))
data => scalar (encode_json(\@list))
};
$c->forward('Hydra::View::Plain');
}
@ -108,7 +107,7 @@ sub jobsets : Chained('api') PathPart('jobsets') Args(0) {
push @list, jobsetToHash($_) foreach @jobsets;
$c->stash->{'plain'} = {
data => scalar (JSON::Any->objToJson(\@list))
data => scalar (encode_json(\@list))
};
$c->forward('Hydra::View::Plain');
}
@ -126,7 +125,7 @@ sub queue : Chained('api') PathPart('queue') Args(0) {
push @list, buildToHash($_) foreach @builds;
$c->stash->{'plain'} = {
data => scalar (JSON::Any->objToJson(\@list))
data => scalar (encode_json(\@list))
};
$c->forward('Hydra::View::Plain');
}
@ -170,7 +169,7 @@ sub nrbuilds : Chained('api') PathPart('nrbuilds') Args(0) {
@arr = reverse(@arr);
$c->stash->{'plain'} = {
data => scalar (JSON::Any->objToJson(\@arr))
data => scalar (encode_json(\@arr))
};
$c->forward('Hydra::View::Plain');
}

View File

@ -8,7 +8,6 @@ use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
use File::Basename;
use File::stat;
use File::Slurp;
use Data::Dump qw(dump);
use Nix::Store;
use Nix::Config;

View File

@ -6,6 +6,7 @@ use warnings;
use base 'Hydra::Base::Controller::ListBuilds';
use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
use JSON::MaybeXS;
use Net::Prometheus;
sub job : Chained('/') PathPart('job') CaptureArgs(3) {
@ -50,7 +51,7 @@ sub shield :Chained('job') PathPart('shield') Args(0) {
$c->response->content_type('application/json');
$c->stash->{'plain'} = {
data => scalar (JSON::Any->objToJson(
data => scalar (encode_json(
{
schemaVersion => 1,
label => "hydra build",

View File

@ -4,7 +4,7 @@ use utf8;
use strict;
use warnings;
use base 'Hydra::Base::Controller::REST';
use File::Slurp;
use File::Slurper qw(read_text);
use Crypt::RandPasswd;
use Digest::SHA1 qw(sha1_hex);
use Hydra::Helper::Nix;
@ -165,7 +165,7 @@ sub github_login :Path('/github-login') Args(0) {
my $client_id = $c->config->{github_client_id} or die "github_client_id not configured.";
my $client_secret = $c->config->{github_client_secret} // do {
my $client_secret_file = $c->config->{github_client_secret_file} or die "github_client_secret nor github_client_secret_file is configured.";
my $client_secret = read_file($client_secret_file);
my $client_secret = read_text($client_secret_file);
$client_secret =~ s/\s+//;
$client_secret;
};