Branch Coverage

blib/lib/MP3/Tag.pm
Criterion Covered Total %
branch 367 716 51.2


line true false branch
22 1404 410 if $self->{'parent'}
26 410 1394 unless $self->parent_ok
205 174 0 if (eval { do { require File::Spec; 'File::Spec'->can('rel2abs') } }) { }
221 87 0 if (-f $filename or -c $filename)
226 87 0 if ($mp3data)
247 0 88 if $skip_weaken or not eval { do { require Scalar::Util; &Scalar::Util::weaken($self->[0]); 1 } }
254 0 1544 unless $self->[0]
257 0 1544 unless $smeth
290 852 85 if exists $self->{'gottags'}
294 0 0 unless $self->{'__proxy'}[0] or $ENV{'MP3TAG_TEST_WEAKEN'}
297 295 470 unless defined $ref
328 1 2 if ($settable)
355 16 16 if ($whichTag =~ /1/) { }
16 0 elsif ($whichTag =~ /2/) { }
451 0 161 if (wantarray) { }
111 50 elsif (defined $out and length $out) { }
457 23 0 if exists $out{'title'}
459 0 23 wantarray ? :
553 0 5 unless $r =~ s[^.*?/][]s
559 0 5 @_ ? :
561 0 5 unless defined $r
563 0 5 unless $r =~ s[^.*?/][]s
571 6 5 unless defined $r
579 2 5 unless defined $r
580 0 5 unless $r =~ s[^.*?/][]s
587 2 5 unless defined $r
589 0 5 unless $r =~ s[^.*?/][]s
590 3 2 if $r <= 26
599 2 282 ref $rwhat ? :
601 0 0 unless $self->{'__proxy'}[0] or $ENV{'MP3TAG_TEST_WEAKEN'}
608 633 1064 unless exists $self->{$pack}
612 1 1065 if $pack eq 'ID3v1' and not $MP3::Tag::ID3v1::ok_length{$what}
613 1 1064 if $do_can and not $self->{$pack}->can($what)
614 0 1064 if ($check_only and $self->{$pack}->can(my $m = $what . '_have'))
615 0 0 unless $self->{$pack}->$m(@$args)
616 0 0 $ret_from ? :
618 803 261 unless defined($out = $self->{$pack}->$what(@$args))
620 33 38 if not length $out and $ignore_0length{$pack}
622 836 228 unless defined $out
623 0 228 if $check_only
624 0 228 if ($all)
625 0 0 $ret_from ? :
628 68 160 if $ret_from
631 0 56 if $all
639 55 227 unless defined $o
667 0 0 unless $self->{'__proxy'}[0] or $ENV{'MP3TAG_TEST_WEAKEN'}
669 14 6 unless exists $self->{'CDDB_File'}
671 1 5 unless defined $v
683 3 1 unless exists $mp3->{'ID3v1'}
688 2 2 if not $force2 and $mp3->{'ID3v1'}->fits_tag({$elt, $val}) and not exists $mp3->{'ID3v2'}
690 2 0 unless exists $mp3->{'ID3v2'}
698 0 0 unless $w and $h
703 0 0 unless my $r = (shift())->aspect_ratio
709 0 0 $r ? :
735 0 0 if $t
1196 19 5 ref $self ? :
1223 4 20 unless $conf_rex
1225 0 24 if ($item =~ /^(force)$/) { }
0 24 elsif (not $item =~ /$conf_rex/) { }
1231 0 24 if $item eq 'extra_config_keys'
1255 2617 5 ref $self ? :
1262 88 595 if $c
1298 0 0 if $k =~ /^translate_/
1319 0 0 unless ($self->{'userdata'})
1320 0 0 unless $self->{'__proxy'}[0] or $ENV{'MP3TAG_TEST_WEAKEN'}
1324 0 0 unless defined(my $d = $self->{'userdata'}[$item])
1349 0 0 unless @_ or exists $self->{'ID3v2'}
1350 2 4 unless exists $self->{'ID3v2'}
1352 1 5 if defined $self->{'ID3v2'}->get_frame($item)
1353 0 6 unless @_
1370 0 0 unless exists $self->{'ID3v2'}
1386 0 0 unless $tag =~ /^ID3v[12]$/
1387 0 0 unless exists $self->{$tag}
1389 0 0 if $tag eq 'ID3v1'
1390 0 0 unless $res
1403 0 0 unless exists $self->{'ID3v2'}
1502 1 48 unless (exists $self->{'ID3v2'})
1503 0 1 if @_ <= 3 or not defined $_[3]
1512 7 162 unless (exists $self->{'ID3v2'})
1513 0 7 if @_ <= 1 or @_ <= 2 and not defined $_[1]
1519 0 169 if ($tr)
1521 0 0 unless (ref $translate eq 'HASH')
1526 0 0 if not $do and $fname =~ s/^(\w{4})(?:\(([^()]*(?:\([^()]+\)[^()]*)*)\))/$1/
1528 0 0 unless $do
1530 0 169 if $update and not $tr
1532 16 153 if @_ > 2 or @_ == 2 and not defined $_[1]
1535 18 135 if @_ == 2
1540 84 51 if defined $val
1541 135 0 unless $update
1543 0 0 if not defined $val or $val eq $nval
1559 0 0 unless $self->get_config('person_frames')
1567 0 0 unless exists $self->{'ID3v2'}
1574 3 27 unless exists $self->{'ID3v2'}
1581 0 0 unless exists $self->{'ID3v2'}
1588 0 7 unless exists $self->{'ID3v2'}
1613 0 0 unless $from = $from->{'ID3v2'}
1615 0 0 unless @$f_ids
1617 0 0 unless exists $to->{'ID3v2'}
1650 0 0 unless $tr
1666 0 0 unless $tr
1696 0 0 unless ($self->{'ID3v2'} or $forceframe)
1698 0 0 unless $force{$tag}
1700 0 0 if $tag =~ /^TXXX\[(cd(?:db|index)_id)\]$/
1701 0 0 if ($tag eq 'TXXX[MCDI-fulltoc]')
1705 0 0 if $v
1709 0 0 if $self->have_id3v2_frame_by_descr($tag) and not $forceframe
1710 0 0 unless $force{$tag} or $self->{'ID3v2'} or $forceframe
1712 0 0 if $tag =~ /^TXXX\[(cd(?:db|index)_id)\]$/
1713 0 0 if ($tag eq 'TXXX[MCDI-fulltoc]')
1715 0 0 unless -e $file
1716 0 0 unless $self->track
1719 0 0 unless eval { do { die "Can't open `${file}' for read: $!" unless open F, "< $file"; die "Can't binmode `${file}' for read: $!" unless binmode F; local $/; $v = ; die "Can't close `${file}' for read: $!" unless CORE::close F } }
1720 0 0 unless open F, "< $file"
1721 0 0 unless binmode F
1724 0 0 unless CORE::close F
1727 0 0 if defined $v
2133 0 2 if @$args
2134 0 2 unless my(@f) = $h =~ /^(\w+)/
2135 2 0 if exists $trans{$f[0]}
2150 0 128 if $upto and $upto ne ']' and $upto ne '}'
2151 0 128 if $upto and not defined $upto and $skip
2153 307 17 $upto || !defined($upto) ? :
2155 146 142 $upto eq ']' ? :
288 546 $upto ? :
2160 237 290 if (defined $1)
2162 73 164 if ($upto and $upto eq ']') { }
63 202 elsif ($upto and $upto eq '}') { }
2169 1 289 defined $2 ? :
2171 0 290 if $skip and $what ne '{'
2173 1 289 if ($what eq '{' and $_[1] =~ s/^([dD])(\d+)}//) { }
0 289 elsif ($what eq '{' and $_[1] =~ s/^U(\d+)}//) { }
60 229 elsif ($what eq '{' and $_[1] =~ s/^($longer_f|[mMS]L|SML)}//o) { }
163 66 elsif ($what eq '{' and $_[1] =~ s/^(!)?(([talgcynfFeEABDNvLrqQSmsCpouMHwh]|ID3v[12]|ID3v2-modified|$longer_f|U\d+)(:|\|\|?)|$frame_bra)//o) { }
0 66 elsif ($what eq '{' and $_[1] =~ s/^ID3v1}//) { }
0 66 elsif ($what eq '{' and $_[1] =~ s/^(sh|nm)P\[//s) { }
5 61 elsif ($what eq '{' and $_[1] =~ s/^I\((\w+)\)//s) { }
1 60 elsif ($what eq '{' and $_[1] =~ s/^T\[([^\[\]]*)\]\}//s) { }
6 54 elsif ($what eq '{') { }
4 50 elsif ($what eq '%') { }
2174 0 1 if $skip
2175 1 0 if ($1 eq 'd') { }
2181 0 0 if $skip
2185 0 60 if $skip
2196 0 2 unless $delim or $id =~ /^[A-Z]{3}[A-Z\d](\d\d)?\b/ or @handlers and @handlers == @_handlers
2199 35 128 if ($delim) { }
2206 52 76 if $have_bra
2207 30 98 if $_[1] =~ s/^(:|\|\|?)//
2208 98 30 unless ($delim)
2209 0 98 if $neg
2211 2 94 unless (@handlers or $self->{'ID3v2'} or $neg)
2212 0 2 if $self->get_config('id3v2_missing_fatal')
2216 2 96 if $skip || $nonesuch and $_[1] =~ s/^\}//
2217 96 0 if ($_[1] =~ /^[\}&]/) { }
2218 2 94 if (@handlers) { }
2219 2 0 unless $skip
2227 6 90 if ($_[1] =~ s/^&/%{/) { }
2229 0 6 if $skip
2231 10 2 defined $_ && length $_ ? :
2237 65 96 if ($delim)
2240 0 65 if $alt and $neg
2243 21 44 if ($simple and 2 >= length $simple || $simple =~ /^U/) { }
0 44 elsif (($simple || '') eq 'ID3v2-modified') { }
14 30 elsif ($simple) { }
0 30 elsif (@handlers) { }
2244 13 8 1 == length $simple ? :
2250 0 14 if $alt
2262 14 51 if ($alt and $alt ne '||') { }
2263 3 11 if ($_[1] =~ s/^([^\\])\}//) { }
2264 3 0 unless $skipping
2266 0 11 unless $_[1] =~ s/^/%{/
2272 15 50 if $skipping
2273 7 20 if ($alt and $have and not $simple)
2274 0 7 if (@handlers) { }
2280 37 13 unless $have and $alt
2282 0 0 if $str and ref $str and exists $str->{'_Data'}
2285 0 0 if $skip
2286 0 0 if $self->{'ID3v1'}
2292 0 0 unless $_[1] =~ s/^\}//
2293 0 0 if $skip
2294 0 0 $what eq 'sh' ? :
2299 4 1 if ($flags =~ s/i//) { }
2302 0 1 unless $_[1] =~ s/^((?:[^\\\}]|(?:\\\\)*\\\}|\\+[^\\\}]|\\\\)*)\}//s
2305 0 1 if $skip
2309 1 4 if $skip
2312 0 1 if $skip
2315 0 6 unless ($self->{'ID3v2'} or $skip)
2316 0 0 if $self->get_config('id3v2_missing_fatal')
2321 0 6 if ($_[1] =~ s/ID3v2}//) { }
0 6 elsif ($_[1] =~ s/^(composer|performer)}//) { }
6 0 elsif ($_[1] =~ s[^frames(?:/(.*?))?}][]) { }
0 0 elsif ($_[1] =~ s(^(_)?out_frames\[(.*?)//(.*?)\]})[]) { }
0 0 elsif ($_[1] =~ s/^ID3v2-size}//) { }
0 0 elsif ($_[1] =~ s/^ID3v2-pad}//) { }
0 0 elsif ($_[1] =~ s/^ID3v2-stripped}//) { }
0 0 elsif ($_[1] =~ s/^ID3v2-modified}//) { }
2322 0 0 if (not $skip and $self->{'ID3v2'})
2323 0 0 if ($self->get_config('id3v2_recalculate')) { }
2330 0 0 unless $skip
2332 4 2 defined $1 ? :
2333 5 1 unless $skip
2338 0 0 $v2 ? :
0 0 unless $skip
2342 0 0 $v2 ? :
0 0 unless $skip
2346 0 0 if $v2 and not exists $v2->{'frameIDs'}
2347 0 0 $v2 ? :
0 0 unless $skip
2350 0 0 if $v2 and not exists $v2->{'frameIDs'}
2351 0 0 $v2 ? :
0 0 unless $skip
2354 0 0 unless $skip
2364 39 233 unless defined $str
2365 0 272 if (defined $maxwidth and length $str > $maxwidth)
2366 0 0 if ($str =~ /^(?:\+|(\-))?(\d*)(\.\d*)?$/) { }
2367 0 0 if (length($1 or '') + length($2) <= $maxwidth) { }
2369 0 0 if $w
2376 0 0 if length $str <= $maxwidth
2379 0 0 if length $str > length $s0
2386 16 256 if (defined $minwidth)
2387 0 16 unless defined $fill
2388 1 15 if ($left) { }
2396 145 179 if (defined $upto) { }
2397 73 55 $upto eq ']' ? :
0 128 unless not $upto or $upto eq ']' ? $_[1] =~ s/^\]// : $_[1] =~ s/^\}//
2401 0 179 if length $_[1]
2440 8 27 if $flags =~ /i/
2441 4 31 if ($flags =~ /f/)
2444 0 4 unless (open F, "< $data")
2445 0 0 if $flags =~ /F/
2448 0 4 if ($flags =~ /B/) { }
2452 0 0 if ($e = $self->get_config('decode_encoding_files') and $e->[0])
2459 0 4 unless CORE::close F
2463 0 35 if ($flags =~ /[ln]/)
2467 0 35 if ($flags =~ /n/)
2468 0 0 unless my $track = $self->track1
2472 0 35 if $flags =~ /I/
2473 34 1 unless ($flags =~ /b/)
2557 0 0 if ($self->get_config('parse_filename_merge_dots')->[0])
2560 0 0 if $what =~ /[ABN]/
2563 0 0 unless $case
2570 0 42 if ($min and $min ne '1')
2574 3 39 $min ? :
2586 0 47 if ($_[1])
2587 0 0 unless my($check, $fail, $id) = $code =~ /^(=(=)?)?(\w+)/
2589 0 0 unless $check
2590 0 0 if $fail and not my($o) = $self->process_handlers($id, $_[1], $_[2])
2591 0 0 unless defined $o
2594 0 47 if $code eq '%'
2596 1 46 if $code eq 'n'
2597 0 0 if $code eq 'y' and $self->get_config('year_is_timestamp')->[0]
2599 0 46 if $code eq 'y'
2602 18 28 if $code =~ /^[talgc]$/
2604 0 28 if $code =~ /^=([ABDfFN]|\{d\d+\})$/
2606 2 26 if $code =~ /^=([talgceEwhvLrqQSmsCpouMH]|\{.*\})$/
2608 0 0 $self->interpolate("%{$+:1}") ? :
0 26 if $code =~ /^==(([talgcynfFeEABDNvLrqQSmsCpouMHwh])|\{(.*)\})$/
2610 0 26 if $code eq '=n'
2612 0 26 if $code eq '=y'
2614 24 2 if $code =~ /^\{(U\d+|\w{4}(\d\d+|(?:\([^\)]*\))?(?:\[.*\])?)?)\}$/s
2618 1 1 if $code eq 'E'
2619 1 0 if $code eq 'e'
2622 0 0 unless $code =~ /^=/
2629 2 33 $is_rex ? :
2640 11 47 if (defined $1) { }
2641 4 7 $is_rex ? :
2644 23 24 if ($3)
2648 0 0 unless $id =~ /^[A-Z]{3}[A-Z\d](\d\d)?\b/ or @handlers and @handlers == @_handlers
2650 0 23 unless my($meth) = $id =~ /^(\w+)/
2656 21 2 if $have_bra
2657 0 23 unless $pattern =~ s/^}//
2658 0 23 if @handlers
2664 33 2 unless $is_rex
2665 0 35 if length $pattern
2668 21 24 !ref($_) && length $_ == 1 ? :
2684 0 0 unless @{$pattern->[2];} or $pattern->[3]
2685 0 35 unless my(@vals) = $data =~ /$pattern->[1]()/s
2688 0 35 unless $cv == @{$pattern->[2];}
2691 0 45 unless defined(my $v = $vals[$c++])
2692 0 45 if ref $k
2700 1 34 if exists $h{'track'}
2701 0 35 if wantarray and @a
2807 41 0 unless $e and $e->[0]
2838 0 1 $l ? :
2852 0 16 unless $f =~ /($ext_re)/
2984 0 0 unless ($info)
2987 0 0 unless defined $info
2998 0 0 unless eval { do { 'I' x (shift())->mpeg_layer } }
3000 0 0 (shift())->frames_padded ? :
0 0 unless eval { do { (shift())->frames_padded ? 'Yes' : 'No' } }
3001 0 0 (shift())->is_copyrighted ? :
0 0 unless eval { do { (shift())->is_copyrighted ? 'Yes' : 'No' } }
3006 32 0 if defined $ms
3008 0 0 unless defined $ms
3030 0 0 if defined $d
3032 0 0 if $self->{'mp3info'} or $self->{'filename'} =~ /\.mp[23]$/i
3034 0 0 unless $r
3075 1 14 unless ref $self
3077 14 1 if defined $time
3080 51 0 if $f =~ /^\??({([^{}]+)}|.)/
3083 0 51 if (not $c++ and $f =~ /^=>(\w)$/)
3084 0 0 unless my $u = $Unit{$1}
3085 0 0 unless defined $time
3092 0 51 unless $ff =~ s/^({[^{}]+}|\w)//
3094 36 15 if ($opt)
3095 15 21 if ($what eq 'H') { }
15 6 elsif ($what eq 'm' or $what eq '{mL}') { }
6 0 elsif ($what eq '{ML}') { }
3096 1 14 unless defined $time
3099 0 15 unless defined $time
3107 0 36 unless $what =~ /^(?:{(.*)}|(.))/
3108 20 16 unless $opt
3112 8 5 if $what eq 's' || $what eq '{SL}' and grep $have{$_}, ('H', 'm', 'mL') or $what eq '{mL}' and $have{'H'}
3115 3 28 if $what eq '%{ML}' and grep $have{$_}, ('H', 'm', 'mL', 's', 'S', 'SL')
3116 5 26 if ($what eq '%{SML}' and grep $have{$_}, ('H', 'm', 'mL')) { }
3118 5 0 unless $res =~ /^\d\d/
3153 0 14 if @wr == 1 and not $wr[0] =~ /\D/
3173 13 1 if $wr
3209 14 18 unless defined $data
3212 13 19 unless (exists $mp3->{'ID3v1'})
3220 143 74 unless defined $d
3221 18 56 unless ref $d
3222 74 0 if $d->[1] ne 'ID3v1'
3227 0 31 defined $mp3->{'ms'} ? :
3231 5 17 if not $force2 and $mp3->{'ID3v1'}->fits_tag($data) and not exists $mp3->{'ID3v2'} and $do_length < 2
3234 3 23 unless (exists $mp3->{'ID3v2'})
3235 2 1 if (defined $wr2) { }
3236 0 2 unless $wr2
3244 113 69 unless defined $d
3245 13 56 unless ref $d
3246 60 9 if $d->[1] ne 'ID3v2'
3251 0 26 if $do_length and not $mp3->have_id3v2_frame('TLEN')
3262 0 71 if ref $data
3269 68 3 if @data == 1
3273 49 89 if $genre eq ''
3276 14 75 if ($genre =~ /\D/)
3280 12 2 if $genre_num eq '255' or $genre_num eq ''
3281 1 1 if $firstnum
3282 1 0 if $prefer_num
3284 0 0 unless defined $genre_num
3287 61 27 unless ($prefer_num or $genre =~ /\D/)
3288 22 39 unless my $genre_str = MP3::Tag::ID3v1::genres($genre)
3289 15 24 if $firstnum
3293 0 73 if lc $genre eq 'rx'
3294 0 73 if lc $genre eq 'cr'
3295 37 36 if length $genre and not $genre =~ /\D/
3296 72 1 unless $seen{$genre}++
3298 7 48 if $firstnum
3314 13 1 if grep(($ext eq lc $_), @_)
3320 82 2 if (exists $self->{'filename'} and defined $self->{'filename'})
3327 0 0 if $line =~ /^\s*(#|$)/
3328 0 0 unless $line =~ /^\s*(\w+)\s*=\s*(.*?)\s*$/
3348 0 0 unless defined $file
3349 0 0 unless defined $file
3350 0 0 if $ENV{'HOME'}
3351 0 0 unless -e $file
3352 0 0 unless open F, "< $file"
3357 0 0 unless CORE::close F
3373 0 0 if eval "require MP3::Tag::$par; 1"