Plugin/Functions.pm

filter: Statementstmt 85.7% 126 / 147 Branchbran 79.5% 70 / 88 Conditioncond 75.7% 50 / 66 MC/DCmcdc 52.6% 20 / 38 Subroutinesub 86.3% 19 / 22 Podpod 75.0% 6 / 8 totaltotal 78.8% 291 / 369 CC 68 SCAR 27.4
CC
68
Cov
82%
max_state_alt
42.0
nagios_exit
26.1
check_messages
18.2
CRAP 15.5
↑ Summary Plugin/Config.pm »
1 # Functional interface to basic Nagios::Monitoring::Plugin constants, exports,
2 # and functions
3
4 package Nagios::Monitoring::Plugin::Functions;
5
6 22 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
7
8 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 22 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 22 ▶use Params::Validate qw(:types validate);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 22 ▶use Math::Calc::Units;
Subroutine BEGIN: called CC=1 SCAR=0.0
13
14 # Remember to update Nagios::Monitoring::Plugins as well
15 22 our $VERSION = "0.51";
16
17 22 our @STATUS_CODES = qw(OK WARNING CRITICAL UNKNOWN DEPENDENT);
18
19 22 require Exporter;
20 22 our @ISA = qw(Exporter);
21 22 our @EXPORT = (@STATUS_CODES, qw(nagios_exit nagios_die check_messages));
22 22 our @EXPORT_OK = qw(%ERRORS %STATUS_TEXT @STATUS_CODES get_shortname max_state max_state_alt convert $value_re);
23 22 our %EXPORT_TAGS = (
24 all => [ @EXPORT, @EXPORT_OK ],
25 codes => [ @STATUS_CODES ],
26 functions => [ qw(nagios_exit nagios_die check_messages max_state max_state_alt convert) ],
27 );
28
29 22 ▶use constant OK => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 22 ▶use constant WARNING => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 22 ▶use constant CRITICAL => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 22 ▶use constant UNKNOWN => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 22 ▶use constant DEPENDENT => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
34
35 22 our %ERRORS = (
36 'OK' => OK,
37 'WARNING' => WARNING,
38 'CRITICAL' => CRITICAL,
39 'UNKNOWN' => UNKNOWN,
40 'DEPENDENT' => DEPENDENT,
41 );
42
43 22 our %STATUS_TEXT = reverse %ERRORS;
44
45 22 my $value = qr/[-+]?[\d\.]+/;
46 22 our $value_re = qr/$value(?:e$value)?/;
47
48 # _fake_exit flag and accessor/mutator, for testing
49 22 my $_fake_exit = 0;
50 9 ▶sub _fake_exit { @_ ? $_fake_exit = shift : $_fake_exit };
Subroutine _fake_exit: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 9 0 9
51
52 # _use_die flag and accessor/mutator, so exceptions can be raised correctly
53 22 my $_use_die = 0;
54 10 ▶sub _use_die { @_ ? $_use_die = shift : $_use_die };
Subroutine _use_die: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 10 0 10
55
56 76 ▶sub get_shortname {
Subroutine get_shortname: called CC=5 SCAR=16.2
Pod documented
57 76 my $arg = shift;
58
59 76 my $shortname = undef;
60
61 76 ▶ return $arg->{shortname} if (defined($arg->{shortname}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $arg->{"shortname"} 4 72 76
62 72 ▶ $shortname = $arg->{plugin} if (defined( $arg->{plugin}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $arg->{"plugin"} 1 71 72
63
64 72 ▶ $shortname = uc basename($shortname || $ENV{NAGIOS_PLUGIN} || $0);
Condition66%4/6
$shortname || $ENV{'NAGIOS_PLUGIN'} || $0
l!l&&r!l&&!r
1710
$shortname or $ENV{"NAGIOS_PLUGIN"}
l!l&&r!l&&!r
1071
MC/DC0%0/3
$shortname || $ENV{'NAGIOS_PLUGIN'} || $0
$shortname $ENV{"NAGIOS_PLUGIN"} $0
Truth table50%2/4
A or B || C
A= $shortnameB= $ENV{"NAGIOS_PLUGIN"}C= $0
ABCresult
1XX1
01X1
0011
0000
65 72 $shortname =~ s/^CHECK_(?:BY_)?//; # Remove any leading CHECK_[BY_]
66 72 $shortname =~ s/\..*$//; # Remove any trailing suffix
67 72 return $shortname;
68 }
69
70 7 ▶sub max_state {
Subroutine max_state: called CC=6 SCAR=18.3
Pod documented
71 7 ▶ return CRITICAL if grep { $_ == CRITICAL } @_;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == 2;} @_ 1 6 7
72 6 ▶ return WARNING if grep { $_ == WARNING } @_;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == 1;} @_ 3 3 6
73 3 ▶ return OK if grep { $_ == OK } @_;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == 0;} @_ 2 1 3
74 0 ▶ return UNKNOWN if grep { $_ == UNKNOWN } @_;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == 3;} @_ 0 1 1
75 0 ▶ return DEPENDENT if grep { $_ == DEPENDENT } @_;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == 4;} @_ 0 1 1
76 1 return UNKNOWN;
77 }
78
79 0 ▶sub max_state_alt {
Subroutine max_state_alt: not called CC=6 SCAR=37.4
Pod documented
80 0 ▶ return CRITICAL if grep { $_ == CRITICAL } @_;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == 2;} @_ 0 0 0
81 0 ▶ return WARNING if grep { $_ == WARNING } @_;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == 1;} @_ 0 0 0
82 0 ▶ return UNKNOWN if grep { $_ == UNKNOWN } @_;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == 3;} @_ 0 0 0
83 0 ▶ return DEPENDENT if grep { $_ == DEPENDENT } @_;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == 4;} @_ 0 0 0
84 0 ▶ return OK if grep { $_ == OK } @_;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ == 0;} @_ 0 0 0
85 0 return UNKNOWN;
86 }
87
88 # nagios_exit( $code, $message )
89 97 ▶sub nagios_exit {
Subroutine nagios_exit: called CC=23 SCAR=32.6
Pod documented
90 97 my ($code, $message, $arg) = @_;
91
92 # Handle named parameters
93 97 ▶ if (defined $code && ($code eq 'return_code' || $code eq 'message')) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code and $code eq "return_code" || $code eq "message") 9 88 97
Condition83%5/6
defined $code and $code eq "return_code" || $code eq "message"
!ll&&!rl&&r
2869
$code eq "return_code" or $code eq "message"
l!l&&r!l&&!r
9086
MC/DC66%2/3
defined $code and $code eq "return_code" || $code eq "message"
defined $code $code eq "return_code" $code eq "message"
Truth table75%3/4
A and B or C
A= defined $codeB= $code eq "return_code"C= $code eq "message"
ABCresult
0XX0
1000
11X1
1011
94 # Remove last argument if odd no and last is ref
95 9 ▶ if (int(@_ / 2) != @_ / 2 && ref $_[$#_]) {
Branch: 1 branch
BranchTrueFalseTotal
if (int @_ / 2 != @_ / 2 and ref $_[$#_]) { } 9 0 9
Condition33%1/3
int @_ / 2 != @_ / 2 and ref $_[$#_]
!ll&&!rl&&r
009
MC/DC0%0/2
int @_ / 2 != @_ / 2 and ref $_[$#_]
int @_ / 2 != @_ / 2 ref $_[$#_]
Truth table33%1/3
A and B
A= int @_ / 2 != @_ / 2B= ref $_[$#_]
ABresult
0X0
100
111
96 9 $arg = pop @_;
97 } else {
98 0 undef $arg;
99 }
100 9 my %arg = @_;
101 9 $code = $arg{return_code};
102 9 $message = $arg{message};
103 }
104 97 ▶ $arg ||= {};
Condition100%2/2
$arg ||= {}
l!l
5344
MC/DC100%1/1
$arg ||= {}
$arg
Truth table100%2/2
A
A= $arg
Aresult
11
00
105
106 # Handle string codes
107 97 ▶ $code = $ERRORS{$code} if defined $code && exists $ERRORS{$code};
Branch: 1 branch
BranchTrueFalseTotal
if defined $code and exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$code} 30 67 97
Condition100%3/3
defined $code and exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$code}
!ll&&!rl&&r
26530
MC/DC100%2/2
defined $code and exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$code}
defined $code exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$code}
Truth table100%3/3
A and B
A= defined $codeB= exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$code}
ABresult
0X0
100
111
108
109 # Set defaults
110 97 ▶ $code = UNKNOWN unless defined $code && exists $STATUS_TEXT{$code};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code and exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$code} 10 87 97
Condition100%3/3
defined $code and exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$code}
!ll&&!rl&&r
2887
MC/DC100%2/2
defined $code and exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$code}
defined $code exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$code}
Truth table100%3/3
A and B
A= defined $codeB= exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$code}
ABresult
0X0
100
111
111 97 ▶ $message = '' unless defined $message;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $message 4 93 97
112 97 ▶ if (ref $message && ref $message eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $message and ref $message eq 'ARRAY') { } 0 97 97
Condition33%1/3
ref $message and ref $message eq "ARRAY"
!ll&&!rl&&r
9700
MC/DC0%0/2
ref $message and ref $message eq "ARRAY"
ref $message ref $message eq "ARRAY"
Truth table33%1/3
A and B
A= ref $messageB= ref $message eq "ARRAY"
ABresult
0X0
100
111
113 0 $message = join(' ', map { chomp; $_ } @$message);
114 }
115 else {
116 97 chomp $message;
117 }
118
119 # Setup output
120 97 my $output = "$STATUS_TEXT{$code}";
121 97 ▶ $output .= " - $message" if defined $message && $message ne '';
Branch: 1 branch
BranchTrueFalseTotal
if defined $message and $message ne "" 89 8 97
Condition66%2/3
defined $message and $message ne ""
!ll&&!rl&&r
0889
MC/DC50%1/2
defined $message and $message ne ""
defined $message $message ne ""
Truth table66%2/3
A and B
A= defined $messageB= $message ne ""
ABresult
0X0
100
111
122 97 ▶ my $shortname = ($arg->{plugin} ? $arg->{plugin}->shortname : undef);
Branch: 1 branch
BranchTrueFalseTotal
$arg->{'plugin'} ? : 53 44 97
123 97 ▶ $shortname ||= get_shortname(); # Should happen only if funnctions are called directly
Condition66%2/3
$shortname ||= get_shortname()
l!l&&r!l&&!r
53440
MC/DC0%0/2
$shortname ||= get_shortname()
$shortname get_shortname()
Truth table66%2/3
A ||= B
A= $shortnameB= get_shortname()
ABresult
1X1
011
000
124 97 ▶ $output = "$shortname $output" if $shortname;
Branch: 1 branch
BranchTrueFalseTotal
if $shortname 97 0 97
125 97 ▶ if ($arg->{plugin}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg->{"plugin"}) 53 44 97
126 53 my $plugin = $arg->{plugin};
127 53 ▶ $output .= " | ". $plugin->all_perfoutput
Branch: 1 branch
BranchTrueFalseTotal
if $plugin->perfdata and $plugin->all_perfoutput 6 47 53
Condition66%2/3
$plugin->perfdata and $plugin->all_perfoutput
!ll&&!rl&&r
0476
MC/DC50%1/2
$plugin->perfdata and $plugin->all_perfoutput
$plugin->perfdata $plugin->all_perfoutput
Truth table66%2/3
A and B
A= $plugin->perfdataB= $plugin->all_perfoutput
ABresult
0X0
100
111
128 if $plugin->perfdata && $plugin->all_perfoutput;
129 }
130 97 $output .= "\n";
131
132 # Don't actually exit if _fake_exit set
133 97 ▶ if ($_fake_exit) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_fake_exit) 89 8 97
134 89 require Nagios::Monitoring::Plugin::ExitResult;
135 89 return Nagios::Monitoring::Plugin::ExitResult->new($code, $output);
136 }
137
138 8 _nagios_exit($code, $output);
139 }
140
141 23 ▶sub _nagios_exit {
Subroutine _nagios_exit: called CC=4 SCAR=13.9
142 23 my ($code, $output) = @_;
143 # Print output and exit; die if flag set and called via a die in stack backtrace
144 23 ▶ if ($_use_die) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_use_die) 15 8 23
145 15 for (my $i = 0;; $i++) {
146 32 @_ = caller($i);
147 32 ▶ last unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 32 32
148 32 ▶ if ($_[3] =~ m/die/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[3] =~ /die/) 15 17 32
149 15 $! = $code;
150 15 die($output);
151 }
152 }
153 }
154 8 print $output;
155 8 exit $code;
156 }
157
158 # nagios_die( $message, [ $code ]) OR nagios_die( $code, $message )
159 # Default $code: UNKNOWN
160 57 ▶sub nagios_die {
Subroutine nagios_die: called CC=10 SCAR=23.0
Pod documented
161 57 my ($arg1, $arg2, $rest) = @_;
162
163 # Named parameters
164 57 ▶ if (defined $arg1 && ($arg1 eq 'return_code' || $arg1 eq 'message')) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $arg1 and $arg1 eq 'return_code' || $arg1 eq 'message') { } 6 51 57
elsif (defined $arg1 and exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg1} || exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg1}) { } 20 31 51
elsif (defined $arg2 and exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg2} || exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg2}) { } 21 10 31
Condition83%5/6
defined $arg1 and $arg1 eq "return_code" || $arg1 eq "message"
!ll&&!rl&&r
2496
$arg1 eq "return_code" or $arg1 eq "message"
l!l&&r!l&&!r
6049
MC/DC66%2/3
defined $arg1 and $arg1 eq "return_code" || $arg1 eq "message"
defined $arg1 $arg1 eq "return_code" $arg1 eq "message"
Truth table75%3/4
A and B or C
A= defined $arg1B= $arg1 eq "return_code"C= $arg1 eq "message"
ABCresult
0XX0
1000
11X1
1011
165 6 return nagios_exit(@_);
166 }
167
168 # ($code, $message)
169 ▶ elsif (defined $arg1 && (exists $ERRORS{$arg1} || exists $STATUS_TEXT{$arg1})) {
Condition100%6/6
defined $arg1 and exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg1} || exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg1}
!ll&&!rl&&r
22920
exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg1} or exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg1}
l!l&&r!l&&!r
101029
MC/DC100%3/3
defined $arg1 and exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg1} || exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg1}
defined $arg1 exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg1} exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg1}
Truth table100%4/4
A and B or C
A= defined $arg1B= exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg1}C= exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg1}
ABCresult
0XX0
1000
11X1
1011
170 20 return nagios_exit(@_);
171 }
172
173 # ($message, $code)
174 ▶ elsif (defined $arg2 && (exists $ERRORS{$arg2} || exists $STATUS_TEXT{$arg2})) {
Condition100%6/6
defined $arg2 and exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg2} || exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg2}
!ll&&!rl&&r
5521
exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg2} or exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg2}
l!l&&r!l&&!r
10115
MC/DC100%3/3
defined $arg2 and exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg2} || exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg2}
defined $arg2 exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg2} exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg2}
Truth table100%4/4
A and B or C
A= defined $arg2B= exists $Nagios::Monitoring::Plugin::Functions::ERRORS{$arg2}C= exists $Nagios::Monitoring::Plugin::Functions::STATUS_TEXT{$arg2}
ABCresult
0XX0
1000
11X1
1011
175 21 return nagios_exit($arg2, $arg1, $rest);
176 }
177
178 # Else just assume $arg1 is the message and hope for the best
179 else {
180 10 return nagios_exit( UNKNOWN, $arg1, $arg2 );
181 }
182 }
183
184 # For backwards compatibility
185 0 ▶sub die { nagios_die(@_); }
Subroutine die: not called CC=1 SCAR=6.9
Pod undocumented
186
187
188 # ------------------------------------------------------------------------
189 # Utility functions
190
191 # Simple wrapper around Math::Calc::Units::convert
192 sub convert
193 0 ▶{
Subroutine convert: not called CC=1 SCAR=6.9
Pod undocumented
194 0 my ($value, $from, $to) = @_;
195 0 my ($newval) = Math::Calc::Units::convert("$value $from", $to, 'exact');
196 0 return $newval;
197 }
198
199 # ------------------------------------------------------------------------
200 # check_messages - return a status and/or message based on a set of
201 # message arrays.
202 # Returns a nagios status code in scalar context.
203 # Returns a code and a message in list context.
204 # The message is join($join, @array) for the relevant array for the code,
205 # or join($join_all, $message) for all arrays if $join_all is set.
206 53 ▶sub check_messages {
Subroutine check_messages: called CC=18 SCAR=29.0
Pod documented
207 53 my %arg = validate( @_, {
208 critical => { type => ARRAYREF },
209 warning => { type => ARRAYREF },
210 ok => { type => ARRAYREF | SCALAR, optional => 1 },
211 'join' => { default => ' ' },
212 join_all => 0,
213 });
214 50 ▶ $arg{join} = ' ' unless defined $arg{join};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg{"join"} 2 48 50
215
216 # Decide $code
217 50 my $code = OK;
218 50 ▶ $code ||= CRITICAL if @{$arg{critical}};
Branch: 1 branch
BranchTrueFalseTotal
if @{$arg{"critical"};} 21 29 50
Condition50%1/2
$code ||= 2
l!l
021
MC/DC0%0/1
$code ||= 2
$code
Truth table50%1/2
A
A= $code
Aresult
11
00
219 50 ▶ $code ||= WARNING if @{$arg{warning}};
Branch: 1 branch
BranchTrueFalseTotal
if @{$arg{"warning"};} 37 13 50
Condition100%2/2
$code ||= 1
l!l
1918
MC/DC100%1/1
$code ||= 1
$code
Truth table100%2/2
A
A= $code
Aresult
11
00
220 50 ▶ return $code unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 6 44 50
221
222 # Compose message
223 44 my $message = '';
224 44 ▶ if ($arg{join_all}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg{'join_all'}) { } 12 32 44
225 $message = join( $arg{join_all},
226 36 ▶ map { @$_ ? join( $arg{'join'}, @$_) : () }
Branch: 3 branches
BranchTrueFalseTotal
@$_ ? : 26 10 36
$arg{'ok'} ? : 10 2 12
ref $arg{'ok'} ? : 8 2 10
227 $arg{critical},
228 $arg{warning},
229 12 $arg{ok} ? (ref $arg{ok} ? $arg{ok} : [ $arg{ok} ]) : []
230 );
231 }
232
233 else {
234 32 ▶ $message ||= join( $arg{'join'}, @{$arg{critical}} )
Branch: 1 branch
BranchTrueFalseTotal
if $code == 2 13 19 32
Condition33%1/3
$message ||= join($arg{"join"}, @{$arg{"critical"};})
l!l&&r!l&&!r
0130
MC/DC0%0/2
$message ||= join($arg{"join"}, @{$arg{"critical"};})
$message join($arg{"join"}, @{$arg{"critical"};})
Truth table33%1/3
A ||= B
A= $messageB= join($arg{"join"}, @{$arg{"critical"};})
ABresult
1X1
011
000
235 if $code == CRITICAL;
236 32 ▶ $message ||= join( $arg{'join'}, @{$arg{warning}} )
Branch: 1 branch
BranchTrueFalseTotal
if $code == 1 10 22 32
Condition33%1/3
$message ||= join($arg{"join"}, @{$arg{"warning"};})
l!l&&r!l&&!r
0100
MC/DC0%0/2
$message ||= join($arg{"join"}, @{$arg{"warning"};})
$message join($arg{"join"}, @{$arg{"warning"};})
Truth table33%1/3
A ||= B
A= $messageB= join($arg{"join"}, @{$arg{"warning"};})
ABresult
1X1
011
000
237 if $code == WARNING;
238 8 $message ||= ref $arg{ok} ? join( $arg{'join'}, @{$arg{ok}} ) : $arg{ok}
239 32 ▶ if $arg{ok};
Branch: 2 branches
BranchTrueFalseTotal
if $arg{"ok"} 27 5 32
ref $arg{'ok'} ? : 8 1 9
Condition100%3/3
$message ||= ref $arg{"ok"} ? join($arg{"join"}, @{$arg{"ok"};}) : $arg{"ok"}
l!l&&r!l&&!r
1881
MC/DC100%2/2
$message ||= ref $arg{"ok"} ? join($arg{"join"}, @{$arg{"ok"};}) : $arg{"ok"}
$message ref $arg{"ok"} ? join($arg{"join"}, @{$arg{"ok"};}) : $arg{"ok"}
Truth table100%3/3
A ||= B
A= $messageB= ref $arg{"ok"} ? join($arg{"join"}, @{$arg{"ok"};}) : $arg{"ok"}
ABresult
1X1
011
000
240 }
241
242 44 return ($code, $message);
243 }
244
245 # ------------------------------------------------------------------------
246
247 22 1;
248
249 # vim:sw=4:sm:et
250
251 __END__
↑ Summary Plugin/Config.pm »