| 1 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # Web::DataService::Diagnostic | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # This module provides a role that is used by 'Web::DataService'. It implements | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # routines for generating diagnostic output about the data service. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # Author: Michael McClennen | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | package Web::DataService::Diagnostic; | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Carp qw(carp croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | our ($CWD); | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | our (%DIAG_PARAM) = ( show => 1, splat => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | # diagnostic_request ( @args ) | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||||||||||||||||
| 24 | # Generate diagnostic output requested from the command-line. This is done by | ||||||||||||||||||||||||||||||||||||||||||
| 25 | # running the data service application with the following command-line | ||||||||||||||||||||||||||||||||||||||||||
| 26 | # arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 27 | # | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # app_name diag <path> <parameters> | ||||||||||||||||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # The path is used to select a data service node, in the same way as if | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # responding to a request, and the parameters (using the same syntax as URL | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # parameters) specify the exact diagnostic output to be generated. | ||||||||||||||||||||||||||||||||||||||||||
| 33 | # | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # Examples: | ||||||||||||||||||||||||||||||||||||||||||
| 35 | # | ||||||||||||||||||||||||||||||||||||||||||
| 36 | # app_name diag /data/records/list 'show=digest' | ||||||||||||||||||||||||||||||||||||||||||
| 37 | # | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # app_name diag /data/ 'show=fields&doc=short' | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # | ||||||||||||||||||||||||||||||||||||||||||
| 40 | # The path argument is required, and so is the parameter "show". The | ||||||||||||||||||||||||||||||||||||||||||
| 41 | # parameter string must follow URL parameter syntax, so don't include any | ||||||||||||||||||||||||||||||||||||||||||
| 42 | # whitespace around the = and & signs. Possible values are: | ||||||||||||||||||||||||||||||||||||||||||
| 43 | # | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # show=digest | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # Generate a digest of the configuration of one or more data service | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # nodes, serialized into YAML. This can be saved to a file and then | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # analyzed by a separate program. The purpose of this functionality is to | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # provide for the generation of a report summarizing the differences | ||||||||||||||||||||||||||||||||||||||||||
| 50 | # between the user interfaces of different data service versions | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # (parameters, responses, formats, vocabularies, etc.), for the purposes | ||||||||||||||||||||||||||||||||||||||||||
| 52 | # of generating change logs and other documentation. By default, the node | ||||||||||||||||||||||||||||||||||||||||||
| 53 | # specified by the path argument is included in the digest, plus | ||||||||||||||||||||||||||||||||||||||||||
| 54 | # (recursively) every node that it links to. The digest will also include | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # every output block, set, and ruleset linked by any of the nodes. | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # | ||||||||||||||||||||||||||||||||||||||||||
| 57 | # The following additional parameters are available: | ||||||||||||||||||||||||||||||||||||||||||
| 58 | # | ||||||||||||||||||||||||||||||||||||||||||
| 59 | # node = <pattern> | ||||||||||||||||||||||||||||||||||||||||||
| 60 | # | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # Only include nodes whose path matches the specified string, which | ||||||||||||||||||||||||||||||||||||||||||
| 62 | # may contain the standard shell wildcards * and ?. You can use this | ||||||||||||||||||||||||||||||||||||||||||
| 63 | # to select a subset of the nodes that would otherwise be included. | ||||||||||||||||||||||||||||||||||||||||||
| 64 | # | ||||||||||||||||||||||||||||||||||||||||||
| 65 | # show=fields | ||||||||||||||||||||||||||||||||||||||||||
| 66 | # | ||||||||||||||||||||||||||||||||||||||||||
| 67 | # Generate a report (as unformatted text) that tabulates all of the output | ||||||||||||||||||||||||||||||||||||||||||
| 68 | # field names matching the other parameters. This functionality can be | ||||||||||||||||||||||||||||||||||||||||||
| 69 | # used to make sure that field names and values are consistent between all | ||||||||||||||||||||||||||||||||||||||||||
| 70 | # of the different data service operations. The path argument is used only to | ||||||||||||||||||||||||||||||||||||||||||
| 71 | # select which data service to analyze, if the application defines more | ||||||||||||||||||||||||||||||||||||||||||
| 72 | # than one. Other parameters include: | ||||||||||||||||||||||||||||||||||||||||||
| 73 | # | ||||||||||||||||||||||||||||||||||||||||||
| 74 | # vocab = <vocab> | ||||||||||||||||||||||||||||||||||||||||||
| 75 | # | ||||||||||||||||||||||||||||||||||||||||||
| 76 | # Only report output field names from the specified vocabulary. If | ||||||||||||||||||||||||||||||||||||||||||
| 77 | # the specified vocabulary has the 'use_field_names' attribute, then | ||||||||||||||||||||||||||||||||||||||||||
| 78 | # the names of the underlying data fields will be used whenever no | ||||||||||||||||||||||||||||||||||||||||||
| 79 | # name was explicitly specified for this vocabulary. | ||||||||||||||||||||||||||||||||||||||||||
| 80 | # | ||||||||||||||||||||||||||||||||||||||||||
| 81 | # name = <pattern> | ||||||||||||||||||||||||||||||||||||||||||
| 82 | # | ||||||||||||||||||||||||||||||||||||||||||
| 83 | # Only report output field names which match the specified pattern. | ||||||||||||||||||||||||||||||||||||||||||
| 84 | # The pattern may contain the standard shell wildcards * and ?. | ||||||||||||||||||||||||||||||||||||||||||
| 85 | # | ||||||||||||||||||||||||||||||||||||||||||
| 86 | # data = <pattern> | ||||||||||||||||||||||||||||||||||||||||||
| 87 | # | ||||||||||||||||||||||||||||||||||||||||||
| 88 | # Only report output field names which are linked to a data field | ||||||||||||||||||||||||||||||||||||||||||
| 89 | # matching the specified pattern. The pattern may contain the standard | ||||||||||||||||||||||||||||||||||||||||||
| 90 | # shell wildcards * and ?. | ||||||||||||||||||||||||||||||||||||||||||
| 91 | # | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | sub diagnostic_request { | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | my ($ds, $request) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diagnostic_request: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | # Start by getting the request parameters, which will tell us which | ||||||||||||||||||||||||||||||||||||||||||
| 98 | # diagnostic operation was requested. | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $params = $Web::DataService::FOUNDATION->get_params($request); | |||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | my $diag = $params->{show} ? lc $params->{show} : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ( $diag eq 'fields' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | return $ds->diagnostic_fields($request, $params); | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | elsif ( $diag eq 'digest' ) | ||||||||||||||||||||||||||||||||||||||||||
| 110 | { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return $ds->diagnostic_digest($request, $params); | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | else | ||||||||||||||||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | print STDERR "Usage:\n\n $0 diag [path] 'show=fields'\n $0 diag [path] 'show=digest'\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | our (%FIELD_PARAM) = ( name => 1, | |||||||||||||||||||||||||||||||||||||||||
| 123 | vocab => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | data => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 125 | doc => 1 ); | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | # diagnostic_fields ( request ) | ||||||||||||||||||||||||||||||||||||||||||
| 128 | # | ||||||||||||||||||||||||||||||||||||||||||
| 129 | # Generate diagnostic information about the output fields defined for this | ||||||||||||||||||||||||||||||||||||||||||
| 130 | # data service. See above for documentation. The report generated by this | ||||||||||||||||||||||||||||||||||||||||||
| 131 | # function is written to standard output, because it is designed to be run | ||||||||||||||||||||||||||||||||||||||||||
| 132 | # only from the command-line. | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | sub diagnostic_fields { | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | my ($ds, $request, $params) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diagnostic_fields: not called CC=44 SCAR=75.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | # First check the query parameters. | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $bad_param; | |||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | foreach my $key ( keys %$params ) | |||||||||||||||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | unless ( $DIAG_PARAM{$key} || $FIELD_PARAM{$key} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Web::DataService::Diagnostic::DIAG_PARAM{$key} or $Web::DataService::Diagnostic::FIELD_PARAM{$key}
MC/DC0%0/2
$Web::DataService::Diagnostic::DIAG_PARAM{$key} or $Web::DataService::Diagnostic::FIELD_PARAM{$key}
$Web::DataService::Diagnostic::DIAG_PARAM{$key}
$Web::DataService::Diagnostic::FIELD_PARAM{$key}
Truth table0%0/3
A or B
A= $Web::DataService::Diagnostic::DIAG_PARAM{$key}B= $Web::DataService::Diagnostic::FIELD_PARAM{$key}
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | print STDERR "ERROR: unknown parameter '$key'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $bad_param = 1; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | return if $bad_param; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $query_vocab = $params->{vocab}; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $query_name = &diag_generate_regex($params->{name}); | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $query_field = &diag_generate_regex($params->{data}); | |||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ( $query_vocab and not $ds->{vocab}{$query_vocab} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$query_vocab and not $ds->{"vocab"}{$query_vocab}
MC/DC0%0/2
$query_vocab and not $ds->{"vocab"}{$query_vocab}
$query_vocab
not $ds->{"vocab"}{$query_vocab}
Truth table0%0/3
A and not(B)
A= $query_vocabB= not $ds->{"vocab"}{$query_vocab}
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | { | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | print STDERR "ERROR: vocabulary '$query_vocab' is not defined for this data service.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my @query; | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | push @query, "vocab = $query_vocab" if $query_vocab; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | push @query, "name = $params->{name}" if $query_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | push @query, "data = $params->{data}" if $query_field; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | # Now check each of the output blocks defined for this data service, looking | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # for fields in those blocks that match the query parameters. | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my (%by_name); | |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | foreach my $block ( keys %{$ds->{block}} ) | |||||||||||||||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $output_list = $ds->{block}{$block}{output_list}; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | next unless ref $output_list eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | # Check all entries in the block's output list. | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | FIELD: | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | foreach my $f ( @$output_list ) | |||||||||||||||||||||||||||||||||||||||||
| 183 | { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | # Ignore any entry in the output_list that does not correspond to | ||||||||||||||||||||||||||||||||||||||||||
| 185 | # an output field. | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | next unless ref $f eq 'HASH' && $f->{output}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $f eq "HASH" and $f->{"output"}
MC/DC0%0/2
ref $f eq "HASH" and $f->{"output"}
ref $f eq "HASH"
$f->{"output"}
Truth table0%0/3
A and B
A= ref $f eq "HASH"B= $f->{"output"}
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | # If an output name was speciied, then ignore any entries whose | ||||||||||||||||||||||||||||||||||||||||||
| 190 | # 'output' attribute does not match. | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ( $query_field ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | next FIELD if $f->{output} !~ $query_field; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | # If a vocabulary was specified, then determine the output name. | ||||||||||||||||||||||||||||||||||||||||||
| 198 | # Ignore entries which do not have a name under this vocabulary. | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my (@matches); | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if ( $query_vocab ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | my $name = $f->{"${query_vocab}_name"} ||= $f->{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$$f{"${query_vocab}_name"} ||= $f->{"name"}
MC/DC0%0/2
$$f{"${query_vocab}_name"} ||= $f->{"name"}
$$f{"${query_vocab}_name"}
$f->{"name"}
Truth table0%0/3
A ||= B
A= $$f{"${query_vocab}_name"}B= $f->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | $name ||= $f->{output} if $ds->{vocab}{$query_vocab}{use_field_names}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name ||= $f->{"output"}
MC/DC0%0/2
$name ||= $f->{"output"}
$name
$f->{"output"}
Truth table0%0/3
A ||= B
A= $nameB= $f->{"output"}
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | my $value = $f->{"${query_vocab}_value"} || $f->{value}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$$f{"${query_vocab}_value"} || $f->{'value'}
MC/DC0%0/2
$$f{"${query_vocab}_value"} || $f->{'value'}
$$f{"${query_vocab}_value"}
$f->{'value'}
Truth table0%0/3
A || B
A= $$f{"${query_vocab}_value"}B= $f->{'value'}
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | next unless defined $name && $name ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $name and $name ne ""
MC/DC0%0/2
defined $name and $name ne ""
defined $name
$name ne ""
Truth table0%0/3
A and B
A= defined $nameB= $name ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | next if $query_name && $name !~ $query_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$query_name and not $name =~ /$query_name/
MC/DC0%0/2
$query_name and not $name =~ /$query_name/
$query_name
not $name =~ /$query_name/
Truth table0%0/3
A and not(B)
A= $query_nameB= not $name =~ /$query_name/
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | push @matches, [$name, $query_vocab, $value]; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | # If no vocabulary was specified, then determine the output name | ||||||||||||||||||||||||||||||||||||||||||
| 216 | # under each available vocabulary. | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | else | ||||||||||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | foreach my $v ( @{$ds->{vocab_list}} ) | |||||||||||||||||||||||||||||||||||||||||
| 221 | { | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | my $name = $f->{"${v}_name"} || $f->{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$$f{"${v}_name"} || $f->{'name'}
MC/DC0%0/2
$$f{"${v}_name"} || $f->{'name'}
$$f{"${v}_name"}
$f->{'name'}
Truth table0%0/3
A || B
A= $$f{"${v}_name"}B= $f->{'name'}
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | $name ||= $f->{output} if $ds->{vocab}{$v}{use_field_names}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name ||= $f->{"output"}
MC/DC0%0/2
$name ||= $f->{"output"}
$name
$f->{"output"}
Truth table0%0/3
A ||= B
A= $nameB= $f->{"output"}
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | my $value = $f->{"${v}_value"} || $f->{value}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$$f{"${v}_value"} || $f->{'value'}
MC/DC0%0/2
$$f{"${v}_value"} || $f->{'value'}
$$f{"${v}_value"}
$f->{'value'}
Truth table0%0/3
A || B
A= $$f{"${v}_value"}B= $f->{'value'}
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | next unless defined $name && $name ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $name and $name ne ""
MC/DC0%0/2
defined $name and $name ne ""
defined $name
$name ne ""
Truth table0%0/3
A and B
A= defined $nameB= $name ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | next if $query_name && $name !~ $query_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$query_name and not $name =~ /$query_name/
MC/DC0%0/2
$query_name and not $name =~ /$query_name/
$query_name
not $name =~ /$query_name/
Truth table0%0/3
A and not(B)
A= $query_nameB= not $name =~ /$query_name/
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | push @matches, [$name, $v, $value]; | |||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | # Ignore entries for which we did not find at least one match. | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | next FIELD unless @matches; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | # If we get to this point, then the entry matches the query so | ||||||||||||||||||||||||||||||||||||||||||
| 239 | # tabulate it by each name. | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | foreach my $m (@matches) | |||||||||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my ($name, $vocab, $value) = @$m; | |||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $new = { block => $block, vocab => $vocab, vvalue => $value, %$f }; | |||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | push @{$by_name{"$vocab:$name"}}, $new; | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | # Get the current working directory, so we can trim path names. | ||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | require "Cwd.pm"; $CWD = &Cwd::getcwd; | |||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | # Go through the entries and compute field widths. | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $options = { doc => $params->{doc}, values => $params->{values} }; | |||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my @column_widths = 0 x 5; | |||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | foreach my $key ( sort { lc $a cmp lc $b } keys %by_name ) | |||||||||||||||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | foreach my $f ( @{$by_name{$key}} ) | |||||||||||||||||||||||||||||||||||||||||
| 264 | { | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $ds->diag_field_widths($key, $f, $options, \@column_widths); | |||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | # Now use this list of rows to print out a report tabulated by field name. | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $options->{template} = " %-$column_widths[0]s %-$column_widths[1]s %-$column_widths[2]s %-$column_widths[3]s\n"; | |||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | print STDOUT "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | print STDOUT "DIAGNOSTIC: FIELDS " . join(', ', @query) . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | print STDOUT "===============================================================================\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | print STDOUT " field name\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my @headings = qw(field block conditionals definition); | |||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | foreach my $i (0..3) | |||||||||||||||||||||||||||||||||||||||||
| 282 | { | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | $headings[$i] = '' unless $column_widths[$i]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | print STDOUT sprintf($options->{template}, @headings); | |||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | print STDOUT "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | foreach my $key ( sort { lc $a cmp lc $b } keys %by_name ) | |||||||||||||||||||||||||||||||||||||||||
| 290 | { | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | my ($vocab, $name) = split qr/:/, $key; | |||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | print STDOUT " $vocab : '$name'\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | foreach my $f ( @{$by_name{$key}} ) | |||||||||||||||||||||||||||||||||||||||||
| 296 | { | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $ds->diag_field_output($name, $f, $options); | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | print STDOUT "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | unless ( keys %by_name ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | { | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | print STDOUT "No matching fields were found.\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | # diag_field_widths ( name, record, options, widths ) | ||||||||||||||||||||||||||||||||||||||||||
| 311 | # | ||||||||||||||||||||||||||||||||||||||||||
| 312 | # By repeatedly calling this function for each output record, the maximum | ||||||||||||||||||||||||||||||||||||||||||
| 313 | # width for each field will be computed. | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | sub diag_field_widths { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | my ($ds, $name, $record, $options, $widths) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_field_widths: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my ($block, $loc, $output, @conditionals); | |||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $block = $record->{block}; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $loc = $ds->{block_loc}{$block}; | |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $output = $record->{output}; | |||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $loc =~ s{$CWD/}{}; | |||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | $output .= " \"$record->{vvalue}\"" if defined $record->{vvalue} && $record->{vvalue} ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $record->{"vvalue"} and $record->{"vvalue"} ne ""
MC/DC0%0/2
defined $record->{"vvalue"} and $record->{"vvalue"} ne ""
defined $record->{"vvalue"}
$record->{"vvalue"} ne ""
Truth table0%0/3
A and B
A= defined $record->{"vvalue"}B= $record->{"vvalue"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | $widths->[0] = length($output) if !defined $widths->[0] || length($output) > $widths->[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $widths->[0] or length $output > $widths->[0]
MC/DC0%0/2
not defined $widths->[0] or length $output > $widths->[0]
not defined $widths->[0]
length $output > $widths->[0]
Truth table0%0/3
not(A) or B
A= not defined $widths->[0]B= length $output > $widths->[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | $widths->[1] = length($block) if !defined $widths->[1] || length($block) > $widths->[1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $widths->[1] or length $block > $widths->[1]
MC/DC0%0/2
not defined $widths->[1] or length $block > $widths->[1]
not defined $widths->[1]
length $block > $widths->[1]
Truth table0%0/3
not(A) or B
A= not defined $widths->[1]B= length $block > $widths->[1]
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | foreach my $c ( qw(if_block not_block if_vocab not_vocab if_field not_field | |||||||||||||||||||||||||||||||||||||||||
| 333 | if_format not_format if_code not_code) ) | ||||||||||||||||||||||||||||||||||||||||||
| 334 | { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | my $value = $record->{$c}; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | next unless $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | $value = join(q{, }, @$value) if ref $value eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $cond = "$c $value"; | |||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | $widths->[2] = length($cond) if !defined $widths->[2] || length($cond) > $widths->[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $widths->[2] or length $cond > $widths->[2]
MC/DC0%0/2
not defined $widths->[2] or length $cond > $widths->[2]
not defined $widths->[2]
length $cond > $widths->[2]
Truth table0%0/3
not(A) or B
A= not defined $widths->[2]B= length $cond > $widths->[2]
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | $widths->[3] = length($loc) if !defined $widths->[3] || length($loc) > $widths->[3]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $widths->[3] or length $loc > $widths->[3]
MC/DC0%0/2
not defined $widths->[3] or length $loc > $widths->[3]
not defined $widths->[3]
length $loc > $widths->[3]
Truth table0%0/3
not(A) or B
A= not defined $widths->[3]B= length $loc > $widths->[3]
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | foreach my $i ( 0..4 ) | |||||||||||||||||||||||||||||||||||||||||
| 346 | { | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | $widths->[$i] //= '0'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$widths->[$i] //= 0
MC/DC0%0/1
$widths->[$i] //= 0
$widths->[$i]
Truth table0%0/2
A
A= $widths->[$i]
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | # diag_field_output ( name, record, options ) | ||||||||||||||||||||||||||||||||||||||||||
| 353 | # | ||||||||||||||||||||||||||||||||||||||||||
| 354 | # Generate a description of a single output field and write it to standard | ||||||||||||||||||||||||||||||||||||||||||
| 355 | # output. | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | sub diag_field_output { | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | my ($ds, $name, $record, $options) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_field_output: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my ($block, $loc, $output, @conditionals); | |||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $block = $record->{block}; | |||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $loc = $ds->{block_loc}{$block}; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $output = $record->{output}; | |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | $loc =~ s{$CWD/}{}; | |||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | $output .= " \"$record->{vvalue}\"" if defined $record->{vvalue} && $record->{vvalue} ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $record->{"vvalue"} and $record->{"vvalue"} ne ""
MC/DC0%0/2
defined $record->{"vvalue"} and $record->{"vvalue"} ne ""
defined $record->{"vvalue"}
$record->{"vvalue"} ne ""
Truth table0%0/3
A and B
A= defined $record->{"vvalue"}B= $record->{"vvalue"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | foreach my $c ( qw(if_block not_block if_vocab not_vocab if_field not_field | |||||||||||||||||||||||||||||||||||||||||
| 372 | if_format not_format if_code not_code) ) | ||||||||||||||||||||||||||||||||||||||||||
| 373 | { | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $value = $record->{$c}; | |||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | next unless $value; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | $value = join(q{, }, @$value) if ref $value eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | push @conditionals, "$c $value"; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | push @conditionals, '' unless @conditionals; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | print STDOUT sprintf($options->{template}, $output, $block, $conditionals[0], $loc); | |||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | for ( my $i = 1; $i < @conditionals; $i++ ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | { | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | print STDOUT sprintf($options->{template}, '', '>>>', $conditionals[$i], ''); | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if ( $options->{doc} && defined $record->{doc_string} && $record->{doc_string} ne '' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$options->{"doc"} and defined $record->{"doc_string"} and $record->{"doc_string"} ne ""
$options->{"doc"} and defined $record->{"doc_string"}
MC/DC0%0/3
$options->{"doc"} and defined $record->{"doc_string"} and $record->{"doc_string"} ne ""
$options->{"doc"}
defined $record->{"doc_string"}
$record->{"doc_string"} ne ""
Truth table0%0/4
A and B and C
A= $options->{"doc"}B= defined $record->{"doc_string"}C= $record->{"doc_string"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | { | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my $doc = $record->{doc_string}; | |||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if ( $options->{doc} eq 'long' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | { | ||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $doc =~ s/\n/"\n "/gs; | |||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | else | ||||||||||||||||||||||||||||||||||||||||||
| 399 | { | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | $doc =~ s/\n.*//s; | |||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | print STDOUT " \"$doc\"\n"; | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | # generate_regex ( string ) | ||||||||||||||||||||||||||||||||||||||||||
| 409 | # | ||||||||||||||||||||||||||||||||||||||||||
| 410 | # Generate a regular expression that will match the given string, with * and ? | ||||||||||||||||||||||||||||||||||||||||||
| 411 | # as wildcards. | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | sub diag_generate_regex { | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | my ($string) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_generate_regex: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | return unless defined $string && $string ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $string and $string ne ""
MC/DC0%0/2
defined $string and $string ne ""
defined $string
$string ne ""
Truth table0%0/3
A and B
A= defined $stringB= $string ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | $string =~ s/[*]/.*/g; | |||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $string =~ s/[?]/./g; | |||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | return qr{^$string$}; | |||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 2 | our (%DIGEST_PARAM) = ( node => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | # diagnostic_digest ( request, params ) | ||||||||||||||||||||||||||||||||||||||||||
| 429 | # | ||||||||||||||||||||||||||||||||||||||||||
| 430 | # Generate diagnostic information about the user-level specification of this | ||||||||||||||||||||||||||||||||||||||||||
| 431 | # data service: the parameters accepted for each operation and the result | ||||||||||||||||||||||||||||||||||||||||||
| 432 | # fields returned. | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | sub diagnostic_digest { | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | my ($ds, $request, $params) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diagnostic_digest: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | # First check the query parameters. | ||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my $bad_param; | |||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | foreach my $key ( keys %$params ) | |||||||||||||||||||||||||||||||||||||||||
| 443 | { | ||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | unless ( $DIAG_PARAM{$key} || $DIGEST_PARAM{$key} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Web::DataService::Diagnostic::DIAG_PARAM{$key} or $Web::DataService::Diagnostic::DIGEST_PARAM{$key}
MC/DC0%0/2
$Web::DataService::Diagnostic::DIAG_PARAM{$key} or $Web::DataService::Diagnostic::DIGEST_PARAM{$key}
$Web::DataService::Diagnostic::DIAG_PARAM{$key}
$Web::DataService::Diagnostic::DIGEST_PARAM{$key}
Truth table0%0/3
A or B
A= $Web::DataService::Diagnostic::DIAG_PARAM{$key}B= $Web::DataService::Diagnostic::DIGEST_PARAM{$key}
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | { | ||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | print STDERR "ERROR: unknown parameter '$key'\n"; | |||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $bad_param = 1; | |||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | return if $bad_param; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | # Then check the node corresponding to the request path. If it is an | ||||||||||||||||||||||||||||||||||||||||||
| 454 | # operation node, report the specification of that operation. | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my $path = $request->node_path; | |||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my $node_query = &diag_generate_regex($params->{node}); | |||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my $digest = { }; | |||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | if ( $node_query ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 461 | { | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $digest->{node_query} = $node_query; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $digest->{_node_query} = $params->{node}; | |||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | # Add all of the nodes defined for this data service. | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | foreach my $p ( sort keys %{$ds->{node_attrs}} ) | |||||||||||||||||||||||||||||||||||||||||
| 469 | { | ||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $ds->diag_add_node($digest, $p); | |||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | # Add values from the data service object. | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $ds->diag_add_ds_obj($digest); | |||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | # Delete keys that were used only during the digest process. | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | delete $digest->{node_query}; | |||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | # Now dump the entire specification as a YAML file. | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | require "YAML.pm"; | |||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | binmode(STDOUT, ":utf8"); | |||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | print STDOUT YAML::Dump($digest); | |||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | # diag_add_ds_obj ( digest ) | ||||||||||||||||||||||||||||||||||||||||||
| 491 | # | ||||||||||||||||||||||||||||||||||||||||||
| 492 | # Add a record to the specified digest object to represent important fields | ||||||||||||||||||||||||||||||||||||||||||
| 493 | # from the data service object that are not specific to any node. | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | sub diag_add_ds_obj { | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | my ($ds, $digest) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_add_ds_obj: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | $digest->{_wds_version} = $Web::DataService::VERSION; | |||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | $digest->{ds}{feature} = { %{$ds->{feature}} } if ref $ds->{feature} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | $digest->{ds}{special} = { %{$ds->{special}} } if ref $ds->{special} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | $digest->{ds}{special_alias} = { %{$ds->{special_alias}} } if ref $ds->{special_alias} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | $digest->{ds}{format} = { %{$ds->{format}} } if ref $ds->{format} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | $digest->{ds}{format_list} = [ @{$ds->{format_list}} ] if ref $ds->{format_list} eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | $digest->{ds}{vocab} = { %{$ds->{vocab}} } if ref $ds->{vocab} eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | $digest->{ds}{vocab_list} = [ @{$ds->{vocab_list}} ] if ref $ds->{vocab_list} eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | foreach my $key ( qw( name title version path_prefix path_re ruleset_prefix | |||||||||||||||||||||||||||||||||||||||||
| 510 | data_source data_provider data_license license_url | ||||||||||||||||||||||||||||||||||||||||||
| 511 | contact_name contact_email ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 512 | { | ||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $digest->{ds}{$key} = $ds->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | # diag_add_node ( digest, path, options ) | ||||||||||||||||||||||||||||||||||||||||||
| 519 | # | ||||||||||||||||||||||||||||||||||||||||||
| 520 | # Add a record to the specified digest object to represent the specified | ||||||||||||||||||||||||||||||||||||||||||
| 521 | # node. Then recursively add records to represent all of the other objects | ||||||||||||||||||||||||||||||||||||||||||
| 522 | # (nodes, output blocks, sets, rulesets) linked to it. | ||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | sub diag_add_node { | ||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | my ($ds, $digest, $path) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_add_node: not called CC=20 SCAR=60.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | # First do some basic checks. Return without doing anything unless we | ||||||||||||||||||||||||||||||||||||||||||
| 529 | # have an actual path, and return immediately if we have already added | ||||||||||||||||||||||||||||||||||||||||||
| 530 | # this path. | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | return unless defined $path && $path ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $path and $path ne ""
MC/DC0%0/2
defined $path and $path ne ""
defined $path
$path ne ""
Truth table0%0/3
A and B
A= defined $pathB= $path ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | return if $digest->{node}{$path}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | # Fail gracefully if this node doesn't exist, by simply returning. We | ||||||||||||||||||||||||||||||||||||||||||
| 536 | # want to complete the specification as best we can. The caller is | ||||||||||||||||||||||||||||||||||||||||||
| 537 | # responsible for checking and adding and error message if necessary. | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | return unless ref $ds->{node_attrs}{$path}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | # If a node query parameter was specified, then only include nodes whose | ||||||||||||||||||||||||||||||||||||||||||
| 542 | # path matches the specified pattern. | ||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | if ( ref $digest->{node_query} eq 'Regexp' && $path !~ $digest->{node_query} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $digest->{"node_query"} eq "Regexp" and not $path =~ /$digest->{"node_query"}/
MC/DC0%0/2
ref $digest->{"node_query"} eq "Regexp" and not $path =~ /$digest->{"node_query"}/
ref $digest->{"node_query"} eq "Regexp"
not $path =~ /$digest->{"node_query"}/
Truth table0%0/3
A and not(B)
A= ref $digest->{"node_query"} eq "Regexp"B= not $path =~ /$digest->{"node_query"}/
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | { | ||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | # Otherwise copy all of the node attributes into a new hash and add it to | ||||||||||||||||||||||||||||||||||||||||||
| 550 | # the specification. | ||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | # print STDERR "Added node $path\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my $node = { %{$ds->{node_attrs}{$path}} }; | |||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | $digest->{node}{$path} = $node; | |||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | # Then compute some important attributes that might be inherited. | ||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | foreach my $key ( qw(disabled undocumented role method arg ruleset output output_label | |||||||||||||||||||||||||||||||||||||||||
| 561 | optional_output summary public_access default_format default_limit | ||||||||||||||||||||||||||||||||||||||||||
| 562 | default_header default_datainfo default_count default_linebreak | ||||||||||||||||||||||||||||||||||||||||||
| 563 | default_save_filename allow_method allow_format allow_vocab) ) | ||||||||||||||||||||||||||||||||||||||||||
| 564 | { | ||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my $value = $ds->node_attr($path, $key); | |||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | if ( defined $value && $value ne '' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $value and $value ne ""
MC/DC0%0/2
defined $value and $value ne ""
defined $value
$value ne ""
Truth table0%0/3
A and B
A= defined $valueB= $value ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | { | ||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | $node->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | # Then compute some other values that might not be specified directly. | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | $node->{ruleset} ||= $ds->determine_ruleset($path); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$node->{"ruleset"} ||= $ds->determine_ruleset($path)
MC/DC0%0/2
$node->{"ruleset"} ||= $ds->determine_ruleset($path)
$node->{"ruleset"}
$ds->determine_ruleset($path)
Truth table0%0/3
A ||= B
A= $node->{"ruleset"}B= $ds->determine_ruleset($path)
| |||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | if ( my @subnode_list = $ds->get_nodelist($path) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | { | ||||||||||||||||||||||||||||||||||||||||||
| 579 | # my @subnode_paths = map { $_->{path} } @subnode_list; | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | $node->{node_list} = \@subnode_list; | |||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | # Then we go through and figure out all of the blocks, sets, and rulesets | ||||||||||||||||||||||||||||||||||||||||||
| 584 | # referenced by this node and add those to the specification as well. | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my (@show_list, @block_list); | |||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | my @out_list = &diag_list_value($node, 'output'); | |||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | foreach my $blockname ( @out_list ) | |||||||||||||||||||||||||||||||||||||||||
| 591 | { | ||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | push @block_list, $blockname; | |||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $ds->diag_add_block($digest, $blockname); | |||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $ds->diag_add_check($digest, 'block', $blockname, "node '$path': output"); | |||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my @summary = &diag_list_value($node, 'summary'); | |||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | foreach my $blockname ( @summary ) | |||||||||||||||||||||||||||||||||||||||||
| 600 | { | ||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | $ds->diag_add_block($digest, $blockname); | |||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $ds->diag_add_check($digest, 'block', $blockname, "node '$path': summary"); | |||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | if ( my $outmap = $node->{optional_output} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 606 | { | ||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | my $set = $ds->{set}{$outmap}; | |||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | if ( $ds->diag_add_check($digest, 'set', $outmap, "node '$path': optional_output") ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 610 | { | ||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | $ds->diag_add_set($digest, $outmap); | |||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | foreach my $v ( @{$set->{value_list}} ) | |||||||||||||||||||||||||||||||||||||||||
| 614 | { | ||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | my $vr = $set->{value}{$v}; | |||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | push @show_list, $vr->{value}; | |||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | if ( $vr->{maps_to} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 620 | { | ||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | push @block_list, $vr->{maps_to}; | |||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | $ds->diag_add_block($digest, $vr->{maps_to}); | |||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | $ds->diag_add_check($digest, 'block', $vr->{maps_to}, "node '$path': optional_output"); | |||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | $node->{show_list} = \@show_list; | |||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | $node->{block_list} = \@block_list; | |||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | if ( my $rs_name = $node->{ruleset} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | { | ||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | $ds->diag_add_ruleset($digest, $rs_name); | |||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | $ds->diag_add_check($digest, 'ruleset', $rs_name, "node '$path'"); | |||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | elsif ( $node->{method} ) | ||||||||||||||||||||||||||||||||||||||||||
| 639 | { | ||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | $ds->diag_add_error($digest, "node '$path'", "no ruleset defined for this node"); | |||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | sub diag_list_value { | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | my ($hash, $field) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_list_value: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | ▶ | return unless defined $hash->{$field} && $hash->{$field} ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $hash->{$field} and $hash->{$field} ne ""
MC/DC0%0/2
defined $hash->{$field} and $hash->{$field} ne ""
defined $hash->{$field}
$hash->{$field} ne ""
Truth table0%0/3
A and B
A= defined $hash->{$field}B= $hash->{$field} ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | if ( ref $hash->{$field} eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | { | ||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | return grep { defined $_ && $_ ne '' } @{$hash->{$field}}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | else | ||||||||||||||||||||||||||||||||||||||||||
| 657 | { | ||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | return $hash->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | # diag_add_subnodes ( digest, path ) | ||||||||||||||||||||||||||||||||||||||||||
| 664 | # | ||||||||||||||||||||||||||||||||||||||||||
| 665 | # Go through the list of nodes that are in the "node list" associated with the | ||||||||||||||||||||||||||||||||||||||||||
| 666 | # specified path, and add them to the digest. These are the nodes that are | ||||||||||||||||||||||||||||||||||||||||||
| 667 | # linked as "subnodes" of the specified path. | ||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||
| 669 | sub diag_add_subnodes { | ||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | my ($ds, $digest, $path) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_add_subnodes: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | # Do some basic checks. Return without doing anything unless we have an | ||||||||||||||||||||||||||||||||||||||||||
| 674 | # actual path. | ||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | return unless defined $path && $path ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $path and $path ne ""
MC/DC0%0/2
defined $path and $path ne ""
defined $path
$path ne ""
Truth table0%0/3
A and B
A= defined $pathB= $path ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||
| 678 | # If there are any nodes listed as subnodes of this path, then add them. | ||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | my @subnodes = $ds->get_nodelist($path); | |||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | foreach my $n ( @subnodes ) | |||||||||||||||||||||||||||||||||||||||||
| 683 | { | ||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $subnode_path = $n->{path}; | |||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | $ds->diag_add_node($digest, $subnode_path); | |||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | $ds->diag_add_check($digest, 'node', $subnode_path, "node '$path': subnode list"); | |||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | sub diag_add_block { | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | my ($ds, $digest, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_add_block: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | # First do some basic checks. Return without doing anything if we weren't | ||||||||||||||||||||||||||||||||||||||||||
| 696 | # given an actual block name, or if we have already added this block. | ||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | return unless defined $name && $name ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $name and $name ne ""
MC/DC0%0/2
defined $name and $name ne ""
defined $name
$name ne ""
Truth table0%0/3
A and B
A= defined $nameB= $name ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | return if $digest->{block}{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | # Just as with nodes, fail gracefully if it doesn't exist. | ||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | ▶ | return unless ref $ds->{block}{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||
| 705 | # Otherwise copy all of the block attributes into a new hash and add it to | ||||||||||||||||||||||||||||||||||||||||||
| 706 | # the specification. | ||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | my $new = { %{$ds->{block}{$name}} }; | |||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | $digest->{block}{$name} = $new; | |||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||
| 712 | # Blocks don't have any other named structures hanging off of them, so we | ||||||||||||||||||||||||||||||||||||||||||
| 713 | # can stop here. | ||||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||
| 717 | sub diag_add_set { | ||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | my ($ds, $digest, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_add_set: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | # First do some basic checks. Return without doing anything if we weren't | ||||||||||||||||||||||||||||||||||||||||||
| 722 | # given an actual set name, or if we have already added this set. | ||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | return unless defined $name && $name ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $name and $name ne ""
MC/DC0%0/2
defined $name and $name ne ""
defined $name
$name ne ""
Truth table0%0/3
A and B
A= defined $nameB= $name ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | return if $digest->{set}{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||
| 727 | # Just as with nodes, fail gracefully if it doesn't exist. | ||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | return unless ref $ds->{set}{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | # Otherwise copy all of the set attributes into a new hash and add it to | ||||||||||||||||||||||||||||||||||||||||||
| 732 | # the specification. | ||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | my $new = { %{$ds->{set}{$name}} }; | |||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | $digest->{set}{$name} = $new; | |||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | # Sets don't have any other named structures hanging off of them, so we | ||||||||||||||||||||||||||||||||||||||||||
| 739 | # can stop here. | ||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||
| 743 | sub diag_add_ruleset { | ||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | my ($ds, $digest, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_add_ruleset: not called CC=18 SCAR=58.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||
| 747 | # First do some basic checks. Return without doing anything if we weren't | ||||||||||||||||||||||||||||||||||||||||||
| 748 | # given an actual ruleset name, or if we have already added this ruleset. | ||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | ▶ | return unless defined $name && $name ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $name and $name ne ""
MC/DC0%0/2
defined $name and $name ne ""
defined $name
$name ne ""
Truth table0%0/3
A and B
A= defined $nameB= $name ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | return if $digest->{ruleset}{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||
| 753 | # Just as with nodes, fail gracefully if it doesn't exist. | ||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | my $rs_list = $ds->{ruleset_diag}{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ▶ | return unless ref $rs_list eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | # Otherwise add the ruleset list to the specification. | ||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | $digest->{ruleset}{$name} = $rs_list; | |||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | # Then go through the rules and add any referenced sets. | ||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | foreach my $rule ( @$rs_list ) | |||||||||||||||||||||||||||||||||||||||||
| 766 | { | ||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ▶ | next unless ref $rule eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | # First look at the 'valid' field. This might be an array, so look at | ||||||||||||||||||||||||||||||||||||||||||
| 770 | # each of the values in turn. | ||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | ▶ | my @valid = ref $rule->{valid} eq 'ARRAY' ? @{$rule->{valid}} : $rule->{valid}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | my @new_valid; | |||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | foreach my $v (@valid) | |||||||||||||||||||||||||||||||||||||||||
| 776 | { | ||||||||||||||||||||||||||||||||||||||||||
| 777 | # If we find a reference, then we must use Perl internal voodoo to | ||||||||||||||||||||||||||||||||||||||||||
| 778 | # unpack it and figure out the name of whatever it refers to. | ||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | if ( ref $v ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 781 | { | ||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | push @new_valid, &diag_decode_ref($v); | |||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | # Otherwise, we assume that it is the name of a Set. So add this | ||||||||||||||||||||||||||||||||||||||||||
| 786 | # set to the digest unless it's already there. | ||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | ▶ | elsif ( $v && $v ne 'FLAG_VALUE' && $v ne 'ANY_VALUE' ) | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$v and $v ne "FLAG_VALUE" and $v ne "ANY_VALUE"
$v and $v ne "FLAG_VALUE"
MC/DC0%0/3
$v and $v ne "FLAG_VALUE" and $v ne "ANY_VALUE"
$v
$v ne "FLAG_VALUE"
$v ne "ANY_VALUE"
Truth table0%0/4
A and B and C
A= $vB= $v ne "FLAG_VALUE"C= $v ne "ANY_VALUE"
| |||||||||||||||||||||||||||||||||||||||||||
| 789 | { | ||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | $ds->diag_add_set($digest, $v); | |||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | $ds->diag_add_check($digest, 'set', $v, "ruleset'$name'"); | |||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | push @new_valid, $v; | |||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||
| 796 | # Now copy this list back to 'valid'. | ||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | if ( @new_valid == 1 ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 799 | { | ||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | $rule->{valid} = $new_valid[0]; | |||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||
| 803 | elsif ( @new_valid > 1 ) | ||||||||||||||||||||||||||||||||||||||||||
| 804 | { | ||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | $rule->{valid} = \@new_valid; | |||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||
| 808 | # If this rule is an inclusion rule, recursively include the target | ||||||||||||||||||||||||||||||||||||||||||
| 809 | # ruleset as well. | ||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | my $inclusion = $rule->{allow} || $rule->{require}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$rule->{'allow'} || $rule->{'require'}
MC/DC0%0/2
$rule->{'allow'} || $rule->{'require'}
$rule->{'allow'}
$rule->{'require'}
Truth table0%0/3
A || B
A= $rule->{'allow'}B= $rule->{'require'}
| |||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | ▶ | if ( $inclusion && ! ref $inclusion ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$inclusion and not ref $inclusion
MC/DC0%0/2
$inclusion and not ref $inclusion
$inclusion
not ref $inclusion
Truth table0%0/3
A and not(B)
A= $inclusionB= not ref $inclusion
| |||||||||||||||||||||||||||||||||||||||||||
| 814 | { | ||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | $ds->diag_add_ruleset($digest, $inclusion); | |||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | $ds->diag_add_check($digest, 'ruleset', $inclusion, "ruleset '$name'"); | |||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||
| 822 | sub diag_decode_ref { | ||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | return unless ref $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_decode_ref: not called CC=6 SCAR=37.4
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | my $obj = B::svref_2object($_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | ▶ | return '*UNKNOWN*' unless $obj->can('GV'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | my $name = $obj->GV->NAME; | |||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | my $pkg = $obj->GV->STASH->NAME; | |||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | ▶ | my $sigil = ref $_[0] eq 'CODE' ? '&' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 833 | : ref $_[0] eq 'HASH' ? '%' | ||||||||||||||||||||||||||||||||||||||||||
| 834 | : ref $_[0] eq 'ARRAY' ? '@' | ||||||||||||||||||||||||||||||||||||||||||
| 835 | : '?'; | ||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | return "${sigil}${pkg}::${name}"; | |||||||||||||||||||||||||||||||||||||||||
| 838 | } | ||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | sub diag_add_check { | ||||||||||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | ▶ | my ($ds, $digest, $type, $name, $key) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_add_check: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||
| 845 | # Check to see if a proper thingy exists under the proper name. If so, | ||||||||||||||||||||||||||||||||||||||||||
| 846 | # return true. | ||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | my $hashkey = $type; | |||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | ▶ | $hashkey = 'ruleset_diag' if $type eq 'ruleset'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | ▶ | $hashkey = 'node_attrs' if $type eq 'node'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | ▶ | return 1 if ref $ds->{$hashkey}{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||
| 854 | # Otherwise, add an error to the specification record and return false. | ||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | $ds->diag_add_error($digest, $key, "unknown $type '$name'"); | |||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||
| 861 | sub diag_add_error { | ||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | ▶ | my ($ds, $digest, $key, $message) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
diag_add_error: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | ▶ | return unless defined $message && $message ne ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $message and $message ne ""
MC/DC0%0/2
defined $message and $message ne ""
defined $message
$message ne ""
Truth table0%0/3
A and B
A= defined $messageB= $message ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | ▶ | $key ||= 'unclassified'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$key ||= "unclassified"
MC/DC0%0/1
$key ||= "unclassified"
$key
Truth table0%0/2
A
A= $key
| |||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | push @{$digest->{errors}{$key}}, $message; | |||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||
| 873 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||