lib/Convert/Pheno/HTTP/Projects.pm

filter: Statementstmt 100% 124 / 124 Branchbran 63.8% 46 / 72 Conditioncond 41.0% 46 / 112 MC/DCmcdc 7.0% 4 / 57 Subroutinesub 100% 14 / 14 Podpod 0.0% 0 / 2 totaltotal 61.4% 234 / 381 CC 83 SCAR 37.0
CC
83
Cov
70%
save
65.2
_read
43.1
open
26.7
CRAP 40.4
« lib/Convert/Pheno/CDISC/DefineXML.pm ↑ Summary lib/Convert/Pheno/HTTP/Service.pm »
1 package Convert::Pheno::HTTP::Projects;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Path::Tiny qw(path);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use JSON::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Convert::Pheno::IO::Atomic qw(write_atomically);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 my $json = JSON::XS->new->utf8->canonical->pretty;
11 12 ▶sub _settings {
Subroutine _settings: called CC=10 SCAR=31.1
12 12 my ($data) = @_;
13 die "Invalid project settings\n" unless ref($data) eq 'HASH' && defined($data->{conversion}) && !ref($data->{conversion})
14 12 ▶ && ref($data->{options}) eq 'HASH' && ref($data->{output}) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data eq "HASH" and defined $data->{"conversion"} and not ref $data->{"conversion"} and ref $data->{"options"} eq "HASH" and ref $data->{"output"} eq "HASH" 0 12 12
Condition33%4/12
ref $data eq "HASH" and defined $data->{"conversion"} and not ref $data->{"conversion"} and ref $data->{"options"} eq "HASH" and ref $data->{"output"} eq "HASH"
!ll&&!rl&&r
0012
ref $data eq "HASH" and defined $data->{"conversion"} and not ref $data->{"conversion"} and ref $data->{"options"} eq "HASH"
!ll&&!rl&&r
0012
ref $data eq "HASH" and defined $data->{"conversion"} and not ref $data->{"conversion"}
!ll&&!rl&&r
0012
ref $data eq "HASH" and defined $data->{"conversion"}
!ll&&!rl&&r
0012
MC/DC0%0/5
ref $data eq "HASH" and defined $data->{"conversion"} and not ref $data->{"conversion"} and ref $data->{"options"} eq "HASH" and ref $data->{"output"} eq "HASH"
ref $data eq "HASH" defined $data->{"conversion"} not ref $data->{"conversion"} ref $data->{"options"} eq "HASH" ref $data->{"output"} eq "HASH"
Truth table16%1/6
A and B and not(C) and D and E
A= ref $data eq "HASH"B= defined $data->{"conversion"}C= not ref $data->{"conversion"}D= ref $data->{"options"} eq "HASH"E= ref $data->{"output"} eq "HASH"
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
15 12 ▶ if (exists $data->{output}{entities}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{"output"}{"entities"}) 12 0 12
16 die "Invalid project entities\n" unless ref($data->{output}{entities}) eq 'ARRAY'
17 12 ▶ && !grep { !defined($_) || ref($_) } @{$data->{output}{entities}};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data->{"output"}{"entities"} eq "ARRAY" and not grep({not defined $_ or ref $_;} @{$$data{"output"}{"entities"};}) 0 12 12
Condition33%2/6
ref $data->{"output"}{"entities"} eq "ARRAY" and not grep({not defined $_ or ref $_;} @{$$data{"output"}{"entities"};})
!ll&&!rl&&r
0012
!defined($_) || ref $_
l!l&&r!l&&!r
0012
MC/DC0%0/2
ref $data->{"output"}{"entities"} eq "ARRAY" and not grep({not defined $_ or ref $_;} @{$$data{"output"}{"entities"};})
ref $data->{"output"}{"entities"} eq "ARRAY" not grep({not defined $_ or ref $_;} @{$$data{"output"}{"entities"};})
MC/DC0%0/2
!defined($_) || ref $_
!defined($_) ref $_
Truth table33%1/3
A and not(B)
A= ref $data->{"output"}{"entities"} eq "ARRAY"B= not grep({not defined $_ or ref $_;} @{$$data{"output"}{"entities"};})
ABresult
0X0
100
111
Truth table33%1/3
not(A) || B
A= !defined($_)B= ref $_
ABresult
1X1
011
000
18 }
19 }
20 3 ▶sub _write {
Subroutine _write: called CC=1 SCAR=0.0
21 3 my ($file, $value) = @_;
22 3 ▶ write_atomically($file, sub { path($_[0])->spew_raw($json->encode($value)) });
Subroutine __ANON__: called CC=1 SCAR=0.0
23 }
24 8 ▶sub _read {
Subroutine _read: called CC=15 SCAR=37.6
25 8 my ($file) = @_;
26 8 ▶ die "Select a project smaller than 4 MiB\n" unless -f $file && !-l $file && -s $file <= 4194304;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $file and not -l $file and -s $file <= 4194304 0 8 8
Condition33%2/6
-f $file and not -l $file and -s $file <= 4194304
!ll&&!rl&&r
008
-f $file and not -l $file
!ll&&!rl&&r
008
MC/DC0%0/3
-f $file and not -l $file and -s $file <= 4194304
-f $file not -l $file -s $file <= 4194304
Truth table25%1/4
A and not(B) and C
A= -f $fileB= not -l $fileC= -s $file <= 4194304
ABCresult
0XX0
10X0
1100
1111
27 8 my $data = $json->decode(path($file)->slurp_raw);
28 die "Unsupported Convert-Pheno project\n" unless ref($data) eq 'HASH'
29 && ($data->{format} || '') eq 'convert-pheno-project' && ($data->{version} || 0) == 1
30 7 ▶ && ref($data->{settings}) eq 'HASH' && ref($data->{sources}) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data eq "HASH" and ($data->{"format"} || "") eq "convert-pheno-project" and ($data->{"version"} || 0) == 1 and ref $data->{"settings"} eq "HASH" and ref $data->{"sources"} eq "HASH" 0 7 7
Condition37%6/16
ref $data eq "HASH" and ($data->{"format"} || "") eq "convert-pheno-project" and ($data->{"version"} || 0) == 1 and ref $data->{"settings"} eq "HASH" and ref $data->{"sources"} eq "HASH"
!ll&&!rl&&r
007
ref $data eq "HASH" and ($data->{"format"} || "") eq "convert-pheno-project" and ($data->{"version"} || 0) == 1 and ref $data->{"settings"} eq "HASH"
!ll&&!rl&&r
007
ref $data eq "HASH" and ($data->{"format"} || "") eq "convert-pheno-project" and ($data->{"version"} || 0) == 1
!ll&&!rl&&r
007
ref $data eq "HASH" and ($data->{"format"} || "") eq "convert-pheno-project"
!ll&&!rl&&r
007
$data->{'format'} || ''
l!l
70
$data->{'version'} || 0
l!l
70
MC/DC0%0/5
ref $data eq "HASH" and ($data->{"format"} || "") eq "convert-pheno-project" and ($data->{"version"} || 0) == 1 and ref $data->{"settings"} eq "HASH" and ref $data->{"sources"} eq "HASH"
ref $data eq "HASH" $data->{'format'} $data->{'version'} ref $data->{"settings"} eq "HASH" ref $data->{"sources"} eq "HASH"
Truth table16%1/6
A and B and C and D and E
A= ref $data eq "HASH"B= $data->{'format'}C= $data->{'version'}D= ref $data->{"settings"} eq "HASH"E= ref $data->{"sources"} eq "HASH"
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
31 7 _settings($data->{settings});
32 7 ▶ die "Invalid project run references\n" if exists($data->{runs}) && (ref($data->{runs}) ne 'ARRAY' || grep {ref($_) || !defined($_)} @{$data->{runs}});
Branch: 1 branch
BranchTrueFalseTotal
if exists $data->{"runs"} and ref $data->{"runs"} ne "ARRAY" || grep({ref $_ or not defined $_;} @{$$data{"runs"};}) 0 7 7
Condition33%3/9
exists $data->{"runs"} and ref $data->{"runs"} ne "ARRAY" || grep({ref $_ or not defined $_;} @{$$data{"runs"};})
!ll&&!rl&&r
070
ref $data->{"runs"} ne "ARRAY" or grep {ref $_ or not defined $_;} @{$$data{"runs"};}
l!l&&r!l&&!r
007
ref $_ || !defined($_)
l!l&&r!l&&!r
005
MC/DC0%0/3
exists $data->{"runs"} and ref $data->{"runs"} ne "ARRAY" || grep({ref $_ or not defined $_;} @{$$data{"runs"};})
exists $data->{"runs"} ref $data->{"runs"} ne "ARRAY" grep {ref $_ or not defined $_;} @{$$data{"runs"};}
MC/DC0%0/2
ref $_ || !defined($_)
ref $_ !defined($_)
Truth table25%1/4
A and B or C
A= exists $data->{"runs"}B= ref $data->{"runs"} ne "ARRAY"C= grep {ref $_ or not defined $_;} @{$$data{"runs"};}
ABCresult
0XX0
1000
11X1
1011
Truth table33%1/3
A || not(B)
A= ref $_B= !defined($_)
ABresult
1X1
011
000
33 7 return $data;
34 }
35  
36 # These operations are available only behind native authorization. A project
37 # manifest must never grant arbitrary filesystem access to an HTTP client.
38 5 ▶sub save {
Subroutine save: called CC=37 SCAR=41.8
Pod undocumented
39 5 my ($jobs, $file, $data) = @_;
40 5 ▶ die "Invalid project contents\n" unless ref($data) eq 'HASH' && ref($data->{settings}) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data eq "HASH" and ref $data->{"settings"} eq "HASH" 0 5 5
Condition33%1/3
ref $data eq "HASH" and ref $data->{"settings"} eq "HASH"
!ll&&!rl&&r
005
MC/DC0%0/2
ref $data eq "HASH" and ref $data->{"settings"} eq "HASH"
ref $data eq "HASH" ref $data->{"settings"} eq "HASH"
Truth table33%1/3
A and B
A= ref $data eq "HASH"B= ref $data->{"settings"} eq "HASH"
ABresult
0X0
100
111
41 5 _settings($data->{settings});
42 5 ▶ die "Invalid project files\n" unless ref($data->{files} || {}) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref($data->{"files"} || {}) eq "HASH" 0 5 5
Condition50%1/2
$data->{'files'} || {}
l!l
50
MC/DC0%0/1
$data->{'files'} || {}
$data->{'files'}
Truth table50%1/2
A
A= $data->{'files'}
Aresult
11
00
43 5 ▶ die "Use a .cpheno project filename\n" unless defined($file) && !ref($file) && $file =~ /\.cpheno\z/i;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $file and not ref $file and $file =~ /\.cpheno\z/i 0 5 5
Condition33%2/6
defined $file and not ref $file and $file =~ /\.cpheno\z/i
!ll&&!rl&&r
005
defined $file and not ref $file
!ll&&!rl&&r
005
MC/DC0%0/3
defined $file and not ref $file and $file =~ /\.cpheno\z/i
defined $file not ref $file $file =~ /\.cpheno\z/i
Truth table25%1/4
A and not(B) and C
A= defined $fileB= not ref $fileC= $file =~ /\.cpheno\z/i
ABCresult
0XX0
10X0
1100
1111
44 5 ▶ die "Project location is unavailable\n" unless -d path($file)->parent && !-l $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -d path($file)->parent and not -l $file 0 5 5
Condition33%1/3
-d path($file)->parent and not -l $file
!ll&&!rl&&r
005
MC/DC0%0/2
-d path($file)->parent and not -l $file
-d path($file)->parent not -l $file
Truth table33%1/3
A and not(B)
A= -d path($file)->parentB= not -l $file
ABresult
0X0
100
111
45 5 ▶ _read($file) if -e $file;
Branch: 1 branch
BranchTrueFalseTotal
if -e $file 2 3 5
46 # Grants use canonical paths. Resolve the project directory too, otherwise
47 # macOS /var -> /private/var (or another directory symlink) breaks references.
48 4 my $parent = path($file)->parent->realpath;
49 4 $file = "@{[$parent->child(path($file)->basename)]}";
50 4 my $assets = path("$file.data");
51 4 ▶ die "Project data folder must not be a symbolic link\n" if -l $assets;
Branch: 1 branch
BranchTrueFalseTotal
if -l $assets 0 4 4
52 # Use a new snapshot so a failed save cannot invalidate the previous manifest.
53 4 $assets->mkpath({mode => 0700});
54 4 my $snapshot = Path::Tiny->tempdir('save-XXXXXXXX', DIR => "$assets", CLEANUP => 0);
55 4 ▶ my $reference = sub { File::Spec->abs2rel("$_[0]", "$parent") };
Subroutine __ANON__: called CC=1 SCAR=0.0
56 4 my %sources;
57 4 ▶ for my $role (keys %{$data->{files} || {}}) {
Condition50%1/2
$data->{'files'} || {}
l!l
40
MC/DC0%0/1
$data->{'files'} || {}
$data->{'files'}
Truth table50%1/2
A
A= $data->{'files'}
Aresult
11
00
58 6 ▶ next if $role eq 'mapping' && length($data->{mapping} || '');
Branch: 1 branch
BranchTrueFalseTotal
if $role eq "mapping" and length($data->{"mapping"} || "") 0 6 6
Condition20%1/5
$role eq "mapping" and length($data->{"mapping"} || "")
!ll&&!rl&&r
600
$data->{'mapping'} || ''
l!l
00
MC/DC0%0/2
$role eq "mapping" and length($data->{"mapping"} || "")
$role eq "mapping" $data->{'mapping'}
Truth table33%1/3
A and B
A= $role eq "mapping"B= $data->{'mapping'}
ABresult
0X0
100
111
59 6 ▶ die "Invalid input role\n" unless $role =~ /\A[a-zA-Z0-9_-]+\z/ && ref($data->{files}{$role}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless $role =~ /\A[a-zA-Z0-9_-]+\z/ and ref $data->{"files"}{$role} eq "ARRAY" 0 6 6
Condition33%1/3
$role =~ /\A[a-zA-Z0-9_-]+\z/ and ref $data->{"files"}{$role} eq "ARRAY"
!ll&&!rl&&r
006
MC/DC0%0/2
$role =~ /\A[a-zA-Z0-9_-]+\z/ and ref $data->{"files"}{$role} eq "ARRAY"
$role =~ /\A[a-zA-Z0-9_-]+\z/ ref $data->{"files"}{$role} eq "ARRAY"
Truth table33%1/3
A and B
A= $role =~ /\A[a-zA-Z0-9_-]+\z/B= ref $data->{"files"}{$role} eq "ARRAY"
ABresult
0X0
100
111
60 6 for my $id (@{$data->{files}{$role}}) {
61 6 my $source = $jobs->resolve_grant($id);
62 5 my $relative = File::Spec->abs2rel($source, $jobs->{root});
63 5 ▶ if ($jobs->{project_owned}{$id} || ($relative !~ /^\.\.(?:[\\\/]|$)/ && !File::Spec->file_name_is_absolute($relative))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($jobs->{"project_owned"}{$id} or not $relative =~ m[^\.\.(?:[\\/]|$)] || "File::Spec"->file_name_is_absolute($relative)) 3 2 5
Condition83%5/6
$jobs->{"project_owned"}{$id} or not $relative =~ m[^\.\.(?:[\\/]|$)] || "File::Spec"->file_name_is_absolute($relative)
l!l&&r!l&&!r
122
$relative =~ m[^\.\.(?:[\\/]|$)] || 'File::Spec'->file_name_is_absolute($relative)
l!l&&r!l&&!r
202
MC/DC66%2/3
$jobs->{"project_owned"}{$id} or not $relative =~ m[^\.\.(?:[\\/]|$)] || "File::Spec"->file_name_is_absolute($relative)
$jobs->{"project_owned"}{$id} $relative =~ m[^\.\.(?:[\\/]|$)] 'File::Spec'->file_name_is_absolute($relative)
Truth table75%3/4
A or not(B || C)
A= $jobs->{"project_owned"}{$id}B= $relative =~ m[^\.\.(?:[\\/]|$)]C= 'File::Spec'->file_name_is_absolute($relative)
ABCresult
1XX1
0001
01X0
0010
64 3 ▶ die "Managed input must be a file\n" unless -f $source;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $source 0 3 3
65 3 ▶ my $copy = $snapshot->child($role . '-' . scalar(@{$sources{$role} || []}) . '-' . path($source)->basename);
Condition50%1/2
$sources{$role} || []
l!l
03
MC/DC0%0/1
$sources{$role} || []
$sources{$role}
Truth table50%1/2
A
A= $sources{$role}
Aresult
11
00
66 3 path($source)->copy($copy);
67 3 $copy->chmod(0600);
68 3 $source = "$copy";
69 }
70 5 ▶ push @{$sources{$role}}, {path => $reference->($source), directory => -d $source ? JSON::XS::true : JSON::XS::false,
Branch: 2 branches
BranchTrueFalseTotal
-d $source ? : 0 5 5
"$source" =~ /^\Q$snapshot\E/ ? : 3 2 5
71 owned => "$source" =~ /^\Q$snapshot\E/ ? JSON::XS::true : JSON::XS::false};
72 }
73 }
74 my %saved = (format => 'convert-pheno-project', version => 1,
75 settings => $data->{settings}, sources => \%sources,
76 3 ▶ runs => $data->{runs} || [], mappingDirty => $data->{mappingDirty} ? JSON::XS::true : JSON::XS::false);
Branch: 1 branch
BranchTrueFalseTotal
$data->{'mappingDirty'} ? : 2 1 3
Condition100%2/2
$data->{'runs'} || []
l!l
21
MC/DC100%1/1
$data->{'runs'} || []
$data->{'runs'}
Truth table100%2/2
A
A= $data->{'runs'}
Aresult
11
00
77 3 for my $part (qw(jsonInput mapping)) {
78 6 ▶ next unless defined($data->{$part}) && length($data->{$part});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data->{$part} and length $data->{$part} 0 6 6
Condition33%1/3
defined $data->{$part} and length $data->{$part}
!ll&&!rl&&r
006
MC/DC0%0/2
defined $data->{$part} and length $data->{$part}
defined $data->{$part} length $data->{$part}
Truth table33%1/3
A and B
A= defined $data->{$part}B= length $data->{$part}
ABresult
0X0
100
111
79 6 ▶ die "Invalid project text\n" if ref($data->{$part}) || length($data->{$part}) > 104857600;
Branch: 1 branch
BranchTrueFalseTotal
if ref $data->{$part} or length $data->{$part} > 104857600 0 6 6
Condition33%1/3
ref $data->{$part} or length $data->{$part} > 104857600
l!l&&r!l&&!r
006
MC/DC0%0/2
ref $data->{$part} or length $data->{$part} > 104857600
ref $data->{$part} length $data->{$part} > 104857600
Truth table33%1/3
A or B
A= ref $data->{$part}B= length $data->{$part} > 104857600
ABresult
1X1
011
000
80 6 ▶ my $target = $snapshot->child($part eq 'mapping' ? 'mapping.yaml' : 'input.json');
Branch: 1 branch
BranchTrueFalseTotal
$part eq 'mapping' ? : 3 3 6
81 6 $target->spew_utf8($data->{$part});
82 6 $target->chmod(0600);
83 6 $saved{$part} = $reference->($target);
84 # Reopen with the exact editor snapshot, not a potentially changed
85 # original mapping. Unfinished edits still require validation in the UI.
86 6 ▶ $sources{mapping} = [{path => $saved{$part}, directory => JSON::XS::false, owned => JSON::XS::true}]
Branch: 1 branch
BranchTrueFalseTotal
if $part eq "mapping" 3 3 6
87 if $part eq 'mapping';
88 }
89 3 ▶ $saved{destination} = $reference->($jobs->resolve_grant($data->{destination})) if $data->{destination};
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"destination"} 3 0 3
90 3 _write($file, \%saved);
91 3 my $handle = $jobs->register_file($file);
92 3 $handle->{displayPath} = $jobs->resolve_grant($handle->{id});
93 3 return {file => $handle};
94 }
95  
96 6 ▶sub open {
Subroutine open: called CC=21 SCAR=32.9
Pod undocumented
97 6 my ($jobs, $file) = @_;
98 6 my $saved = _read($file);
99 6 my $parent = path($file)->parent->realpath;
100 33 ▶ my $resolve = sub {
Subroutine __ANON__: called CC=4 SCAR=17.1
101 33 my ($value) = @_;
102 33 ▶ die "Invalid path in project\n" if !defined($value) || ref($value) || $value =~ /\0/;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $value or ref $value or $value =~ /\0/ 0 33 33
Condition33%2/6
not defined $value or ref $value or $value =~ /\0/
l!l&&r!l&&!r
0033
not defined $value or ref $value
l!l&&r!l&&!r
0033
MC/DC0%0/3
not defined $value or ref $value or $value =~ /\0/
not defined $value ref $value $value =~ /\0/
Truth table25%1/4
not(A) or B or C
A= not defined $valueB= ref $valueC= $value =~ /\0/
ABCresult
1XX1
01X1
0011
0000
103 33 return File::Spec->rel2abs($value, "$parent");
104 6 };
105 6 my (%files, @missing);
106 6 for my $role (sort keys %{$saved->{sources}}) {
107 17 ▶ die "Invalid project sources\n" unless $role =~ /\A[a-zA-Z0-9_-]+\z/ && ref($saved->{sources}{$role}) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless $role =~ /\A[a-zA-Z0-9_-]+\z/ and ref $saved->{"sources"}{$role} eq "ARRAY" 0 17 17
Condition33%1/3
$role =~ /\A[a-zA-Z0-9_-]+\z/ and ref $saved->{"sources"}{$role} eq "ARRAY"
!ll&&!rl&&r
0017
MC/DC0%0/2
$role =~ /\A[a-zA-Z0-9_-]+\z/ and ref $saved->{"sources"}{$role} eq "ARRAY"
$role =~ /\A[a-zA-Z0-9_-]+\z/ ref $saved->{"sources"}{$role} eq "ARRAY"
Truth table33%1/3
A and B
A= $role =~ /\A[a-zA-Z0-9_-]+\z/B= ref $saved->{"sources"}{$role} eq "ARRAY"
ABresult
0X0
100
111
108 17 for my $index (0 .. $#{$saved->{sources}{$role}}) {
109 17 my $entry = $saved->{sources}{$role}[$index];
110 17 ▶ die "Invalid project source\n" unless ref($entry) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $entry eq "HASH" 0 17 17
111 17 my $source = $resolve->($entry->{path});
112 17 my $handle = eval {
113 17 ▶ die "Input type changed\n" if $entry->{directory} ? !-d $source : !-f $source;
Branch: 2 branches
BranchTrueFalseTotal
if $entry->{"directory"} ? !(-d $source) : !(-f $source) 2 15 17
$entry->{'directory'} ? : 0 17 17
114 15 $jobs->register_file($source);
115 };
116 17 ▶ if ($handle) {
Branch: 1 branch
BranchTrueFalseTotal
if ($handle) { } 15 2 17
117 15 $handle->{displayPath} = $jobs->resolve_grant($handle->{id});
118 15 ▶ $jobs->{project_owned}{$handle->{id}} = 1 if $entry->{owned};
Branch: 1 branch
BranchTrueFalseTotal
if $entry->{"owned"} 12 3 15
119 15 push @{$files{$role}}, $handle;
120 }
121 2 ▶ else { push @missing, {role => $role, index => $index, path => $entry->{path}, directory => $entry->{directory} || JSON::XS::false} }
Condition33%1/3
$entry->{'directory'} || &JSON::XS::false()
l!l&&r!l&&!r
020
MC/DC0%0/2
$entry->{'directory'} || &JSON::XS::false()
$entry->{'directory'} &JSON::XS::false()
Truth table33%1/3
A || B
A= $entry->{'directory'}B= &JSON::XS::false()
ABresult
1X1
011
000
122 }
123 }
124 my %result = (file => $jobs->register_file($file), settings => $saved->{settings}, files => \%files,
125 6 ▶ missing => \@missing, runs => $saved->{runs} || [], mappingDirty => $saved->{mappingDirty} || JSON::XS::false);
Condition60%3/5
$saved->{'runs'} || []
l!l
60
$saved->{'mappingDirty'} || &JSON::XS::false()
l!l&&r!l&&!r
420
MC/DC0%0/1
$saved->{'runs'} || []
$saved->{'runs'}
MC/DC0%0/2
$saved->{'mappingDirty'} || &JSON::XS::false()
$saved->{'mappingDirty'} &JSON::XS::false()
Truth table50%1/2
A
A= $saved->{'runs'}
Aresult
11
00
Truth table66%2/3
A || B
A= $saved->{'mappingDirty'}B= &JSON::XS::false()
ABresult
1X1
011
000
126 6 $result{file}{displayPath} = $jobs->resolve_grant($result{file}{id});
127 6 for my $part (qw(jsonInput mapping)) {
128 11 ▶ next unless $saved->{$part};
Branch: 1 branch
BranchTrueFalseTotal
unless $saved->{$part} 0 11 11
129 11 my $source = $resolve->($saved->{$part});
130 # Project-owned text is required: silently dropping it would lose work.
131 11 ▶ die "Missing project data: $saved->{$part}. Restore the companion .cpheno.data folder.\n"
Branch: 1 branch
BranchTrueFalseTotal
unless -f $source and not -l $source and -s $source <= 104857600 1 10 11
Condition66%4/6
-f $source and not -l $source and -s $source <= 104857600
!ll&&!rl&&r
1010
-f $source and not -l $source
!ll&&!rl&&r
1010
MC/DC33%1/3
-f $source and not -l $source and -s $source <= 104857600
-f $source not -l $source -s $source <= 104857600
Truth table50%2/4
A and not(B) and C
A= -f $sourceB= not -l $sourceC= -s $source <= 104857600
ABCresult
0XX0
10X0
1100
1111
132 unless -f $source && !-l $source && -s $source <= 104857600;
133 10 $result{$part} = path($source)->slurp_utf8;
134 }
135 5 ▶ if ($saved->{destination}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($saved->{"destination"}) 5 0 5
136 5 $result{destination} = eval {$jobs->register_file($resolve->($saved->{destination}))};
137 5 ▶ $result{destination}{displayPath} = $jobs->resolve_grant($result{destination}{id}) if $result{destination};
Branch: 1 branch
BranchTrueFalseTotal
if $result{"destination"} 5 0 5
138 5 ▶ push @missing, {role => 'destination', path => $saved->{destination}, directory => JSON::XS::true} unless $result{destination};
Branch: 1 branch
BranchTrueFalseTotal
unless $result{"destination"} 0 5 5
139 }
140 5 return \%result;
141 }
142 1 1;
« lib/Convert/Pheno/CDISC/DefineXML.pm ↑ Summary lib/Convert/Pheno/HTTP/Service.pm »