Branch Coverage

blib/lib/MP3/Tag.pm
Criterion Covered Total %
branch 380 744 51.0


line true false branch
22 1404 410 if $self->{'parent'}
26 410 1394 unless $self->parent_ok
101 0 0 if $force_enc || ($ENV{'LANG'} || '') =~ /\.([-\w]+)$/i && ($i_enc = $1, 1) and not ${^UNICODE} & 8 and not $ENV{'MP3TAG_DECODE_FILES_DEFAULT_RESET'}
103 0 0 if $force_enc || ($ENV{'LANG'} || '') =~ /\.([-\w]+)$/i && ($o_enc = $1, 1) and not ${^UNICODE} & 22 and not $ENV{'MP3TAG_ENCODE_FILES_DEFAULT_RESET'}
105 36 6 unless $t eq "FILES" and not defined $ENV{"MP3TAG_DECODE_${t}_DEFAULT"}
106 42 0 unless defined $e{$t}
107 0 42 if $e{$t}
110 6 0 unless defined $e{'eV1'}
111 6 0 unless defined $e{'eV1'}
112 0 6 if $e{'eV1'}
114 0 6 if defined $ENV{'MP3TAG_ENCODE_FILES_DEFAULT'}
115 6 0 unless defined $e{'eF'}
117 0 6 if not defined $e{'eF'} and defined $ENV{'MP3TAG_DECODE_FILES_DEFAULT'} || defined $ENV{'MP3TAG_DECODE_DEFAULT'}
118 0 6 if $e{'eF'}
214 174 0 if (eval { do { require File::Spec; 'File::Spec'->can('rel2abs') } }) { }
230 87 0 if (-f $filename or -c $filename)
235 87 0 if ($mp3data)
256 0 88 if $skip_weaken or not eval { do { require Scalar::Util; &Scalar::Util::weaken($self->[0]); 1 } }
263 0 1544 unless $self->[0]
266 0 1544 unless $smeth
299 852 85 if exists $self->{'gottags'}
303 0 0 unless $self->{'__proxy'}[0] or $ENV{'MP3TAG_TEST_WEAKEN'}
306 295 470 unless defined $ref
337 1 2 if ($settable)
364 16 16 if ($whichTag =~ /1/) { }
16 0 elsif ($whichTag =~ /2/) { }
460 0 161 if (wantarray) { }
111 50 elsif (defined $out and length $out) { }
466 23 0 if exists $out{'title'}
468 0 23 wantarray ? :
562 0 5 unless $r =~ s[^.*?/][]s
568 0 5 @_ ? :
570 0 5 unless defined $r
572 0 5 unless $r =~ s[^.*?/][]s
580 6 5 unless defined $r
588 2 5 unless defined $r
589 0 5 unless $r =~ s[^.*?/][]s
596 2 5 unless defined $r
598 0 5 unless $r =~ s[^.*?/][]s
599 3 2 if $r <= 26
608 2 282 ref $rwhat ? :
610 0 0 unless $self->{'__proxy'}[0] or $ENV{'MP3TAG_TEST_WEAKEN'}
617 633 1064 unless exists $self->{$pack}
621 1 1065 if $pack eq "ID3v1" and not $MP3::Tag::ID3v1::ok_length{$what}
622 1 1064 if $do_can and not $self->{$pack}->can($what)
623 0 1064 if ($check_only and $self->{$pack}->can(my $m = $what . "_have"))
624 0 0 unless $self->{$pack}->$m(@$args)
625 0 0 $ret_from ? :
627 803 261 unless defined($out = $self->{$pack}->$what(@$args))
629 33 38 if not length $out and $ignore_0length{$pack}
631 836 228 unless defined $out
632 0 228 if $check_only
633 0 228 if ($all)
634 0 0 $ret_from ? :
637 68 160 if $ret_from
640 0 56 if $all
648 55 227 unless defined $o
676 0 0 unless $self->{'__proxy'}[0] or $ENV{'MP3TAG_TEST_WEAKEN'}
678 14 6 unless exists $self->{'CDDB_File'}
680 1 5 unless defined $v
692 3 1 unless exists $mp3->{'ID3v1'}
697 2 2 if not $force2 and $mp3->{'ID3v1'}->fits_tag({$elt, $val}) and not exists $mp3->{'ID3v2'}
699 2 0 unless exists $mp3->{'ID3v2'}
707 0 0 unless $w and $h
712 0 0 unless my $r = (shift())->aspect_ratio
718 0 0 $r ? :
744 0 0 if $t
1205 19 5 ref $self ? :
1232 4 20 unless $conf_rex
1234 0 24 if ($item =~ /^(force)$/) { }
0 24 elsif (not $item =~ /$conf_rex/) { }
1240 0 24 if $item eq "extra_config_keys"
1264 2617 5 ref $self ? :
1271 88 595 if $c
1307 0 0 if $k =~ /^translate_/
1328 0 0 unless ($self->{'userdata'})
1329 0 0 unless $self->{'__proxy'}[0] or $ENV{'MP3TAG_TEST_WEAKEN'}
1333 0 0 unless defined(my $d = $self->{'userdata'}[$item])
1358 0 0 unless @_ or exists $self->{'ID3v2'}
1359 2 4 unless exists $self->{'ID3v2'}
1361 1 5 if defined $self->{'ID3v2'}->get_frame($item)
1362 0 6 unless @_
1379 0 0 unless exists $self->{'ID3v2'}
1395 0 0 unless $tag =~ /^ID3v[12]$/
1396 0 0 unless exists $self->{$tag}
1398 0 0 if $tag eq "ID3v1"
1399 0 0 unless $res
1412 0 0 unless exists $self->{'ID3v2'}
1511 1 48 unless (exists $self->{'ID3v2'})
1512 0 1 if @_ <= 3 or not defined $_[3]
1521 7 162 unless (exists $self->{'ID3v2'})
1522 0 7 if @_ <= 1 or @_ <= 2 and not defined $_[1]
1528 0 169 if ($tr)
1530 0 0 unless (ref $translate eq "HASH")
1535 0 0 if not $do and $fname =~ s/^(\w{4})(?:\(([^()]*(?:\([^()]+\)[^()]*)*)\))/$1/
1537 0 0 unless $do
1539 0 169 if $update and not $tr
1541 16 153 if @_ > 2 or @_ == 2 and not defined $_[1]
1544 18 135 if @_ == 2
1549 84 51 if defined $val
1550 135 0 unless $update
1552 0 0 if not defined $val or $val eq $nval
1568 0 0 unless $self->get_config("person_frames")
1576 0 0 unless exists $self->{'ID3v2'}
1583 3 27 unless exists $self->{'ID3v2'}
1590 0 0 unless exists $self->{'ID3v2'}
1597 0 7 unless exists $self->{'ID3v2'}
1622 0 0 unless $from = $from->{'ID3v2'}
1624 0 0 unless @$f_ids
1626 0 0 unless exists $to->{'ID3v2'}
1659 0 0 unless $tr
1675 0 0 unless $tr
1705 0 0 unless ($self->{'ID3v2'} or $forceframe)
1707 0 0 unless $force{$tag}
1709 0 0 if $tag =~ /^TXXX\[(cd(?:db|index)_id)\]$/
1710 0 0 if ($tag eq "TXXX[MCDI-fulltoc]")
1714 0 0 if $v
1718 0 0 if $self->have_id3v2_frame_by_descr($tag) and not $forceframe
1719 0 0 unless $force{$tag} or $self->{'ID3v2'} or $forceframe
1721 0 0 if $tag =~ /^TXXX\[(cd(?:db|index)_id)\]$/
1722 0 0 if ($tag eq "TXXX[MCDI-fulltoc]")
1724 0 0 unless -e $file
1725 0 0 unless $self->track
1728 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 = readline F; die "Can't close `${file}' for read: $!" unless CORE::close F } }
1729 0 0 unless open F, "< $file"
1730 0 0 unless binmode F
1733 0 0 unless CORE::close F
1736 0 0 if defined $v
2142 0 2 if @$args
2143 0 2 unless my(@f) = $h =~ /^(\w+)/
2144 2 0 if exists $trans{$f[0]}
2151 0 16 $in < 0 ? :
2164 0 128 if $upto and $upto ne "]" and $upto ne "}"
2165 0 128 if $upto and not defined $upto and $skip
2167 307 17 $upto || !defined($upto) ? :
2169 146 142 $upto eq ']' ? :
288 546 $upto ? :
2174 237 290 if (defined $1)
2176 73 164 if ($upto and $upto eq ']') { }
63 202 elsif ($upto and $upto eq '}') { }
2183 1 289 defined $2 ? :
2185 0 290 if $skip and $what ne "{"
2187 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 '%') { }
2188 0 1 if $skip
2189 1 0 if ($1 eq 'd') { }
2195 0 0 if $skip
2199 0 60 if $skip
2210 0 2 unless $delim or $id =~ /^[A-Z]{3}[A-Z\d](\d\d)?\b/ or @handlers and @handlers == @_handlers
2213 35 128 if ($delim) { }
2220 52 76 if $have_bra
2221 30 98 if $_[1] =~ s/^(:|\|\|?)//
2222 98 30 unless ($delim)
2223 0 98 if $neg
2225 2 94 unless (@handlers or $self->{'ID3v2'} or $neg)
2226 0 2 if $self->get_config("id3v2_missing_fatal")
2230 2 96 if $skip || $nonesuch and $_[1] =~ s/^\}//
2231 96 0 if ($_[1] =~ /^[\}&]/) { }
2232 2 94 if (@handlers) { }
2233 2 0 unless $skip
2241 6 90 if ($_[1] =~ s/^&/%{/) { }
2243 0 6 if $skip
2245 10 2 defined $_ && length $_ ? :
2251 65 96 if ($delim)
2254 0 65 if $alt and $neg
2257 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) { }
2258 13 8 1 == length $simple ? :
2264 0 14 if $alt
2276 14 51 if ($alt and $alt ne '||') { }
2277 3 11 if ($_[1] =~ s/^([^\\])\}//) { }
2278 3 0 unless $skipping
2280 0 11 unless $_[1] =~ s/^/%{/
2286 15 50 if $skipping
2287 7 20 if ($alt and $have and not $simple)
2288 0 7 if (@handlers) { }
2294 37 13 unless $have and $alt
2296 0 0 if $str and ref $str and exists $str->{'_Data'}
2299 0 0 if $skip
2300 0 0 if $self->{'ID3v1'}
2306 0 0 unless $_[1] =~ s/^\}//
2307 0 0 if $skip
2308 0 0 $what eq 'sh' ? :
2313 4 1 if ($flags =~ s/i//) { }
2316 0 1 unless $_[1] =~ s/^((?:[^\\\}]|(?:\\\\)*\\\}|\\+[^\\\}]|\\\\)*)\}//s
2319 0 1 if $skip
2323 1 4 if $skip
2326 0 1 if $skip
2329 0 6 unless ($self->{'ID3v2'} or $skip)
2330 0 0 if $self->get_config("id3v2_missing_fatal")
2335 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}//) { }
2336 0 0 if (not $skip and $self->{'ID3v2'})
2337 0 0 if ($self->get_config('id3v2_recalculate')) { }
2344 0 0 unless $skip
2346 4 2 defined $1 ? :
2347 5 1 unless $skip
2352 0 0 $v2 ? :
0 0 unless $skip
2356 0 0 $v2 ? :
0 0 unless $skip
2360 0 0 if $v2 and not exists $v2->{'frameIDs'}
2361 0 0 $v2 ? :
0 0 unless $skip
2364 0 0 if $v2 and not exists $v2->{'frameIDs'}
2365 0 0 $v2 ? :
0 0 unless $skip
2368 0 0 unless $skip
2378 39 233 unless defined $str
2379 0 272 if (defined $maxwidth and length $str > $maxwidth)
2380 0 0 if ($str =~ /^(?:\+|(\-))?(\d*)(\.\d*)?$/) { }
2381 0 0 if (length($1 or '') + length($2) <= $maxwidth) { }
2383 0 0 if $w
2390 0 0 if length $str <= $maxwidth
2393 0 0 if length $str > length $s0
2400 16 256 if (defined $minwidth)
2401 0 16 unless defined $fill
2402 1 15 if ($left) { }
2410 145 179 if (defined $upto) { }
2411 73 55 $upto eq ']' ? :
0 128 unless not $upto or $upto eq "]" ? $_[1] =~ s/^\]// : $_[1] =~ s/^\}//
2415 0 179 if length $_[1]
2455 8 27 if $flags =~ /i/
2456 4 31 if ($flags =~ /f/)
2459 0 4 unless (open F, "< $data")
2460 0 0 if $flags =~ /F/
2463 0 4 if ($flags =~ /B/) { }
2469 0 0 if ($e = $self->get_config("decode_encoding_files") and $e->[0])
2478 0 4 unless CORE::close F
2479 4 0 unless $flags =~ /B/
2483 0 35 if ($flags =~ /[ln]/)
2487 0 35 if ($flags =~ /n/)
2488 0 0 unless my $track = $self->track1
2492 0 35 if $flags =~ /I/
2493 34 1 unless ($flags =~ /b/)
2577 0 0 if ($self->get_config("parse_filename_merge_dots")->[0])
2580 0 0 if $what =~ /[ABN]/
2583 0 0 unless $case
2590 0 42 if ($min and $min ne 1)
2594 3 39 $min ? :
2606 0 47 if ($_[1])
2607 0 0 unless my($check, $fail, $id) = $code =~ /^(=(=)?)?(\w+)/
2609 0 0 unless $check
2610 0 0 if $fail and not my($o) = $self->process_handlers($id, $_[1], $_[2])
2611 0 0 unless defined $o
2614 0 47 if $code eq "%"
2616 1 46 if $code eq "n"
2618 0 0 if $code eq "y" and $self->get_config("year_is_timestamp")->[0]
2620 0 46 if $code eq "y"
2623 18 28 if $code =~ /^[talgc]$/
2625 0 28 if $code =~ /^=([ABDfFN]|\{d\d+\})$/
2627 2 26 if $code =~ /^=([talgceEwhvLrqQSmsCpouMH]|\{.*\})$/
2629 0 0 $self->interpolate("%{$+:1}") ? :
0 26 if $code =~ /^==(([talgcynfFeEABDNvLrqQSmsCpouMHwh])|\{(.*)\})$/
2631 0 26 if $code eq "=n"
2633 0 26 if $code eq "=y"
2635 24 2 if $code =~ /^\{(U\d+|\w{4}(\d\d+|(?:\([^\)]*\))?(?:\[.*\])?)?)\}$/s
2639 1 1 if $code eq "E"
2640 1 0 if $code eq "e"
2643 0 0 unless $code =~ /^=/
2650 2 33 $is_rex ? :
2661 11 47 if (defined $1) { }
2662 4 7 $is_rex ? :
2665 23 24 if ($3)
2669 0 0 unless $id =~ /^[A-Z]{3}[A-Z\d](\d\d)?\b/ or @handlers and @handlers == @_handlers
2671 0 23 unless my($meth) = $id =~ /^(\w+)/
2677 21 2 if $have_bra
2678 0 23 unless $pattern =~ s/^}//
2679 0 23 if @handlers
2685 33 2 unless $is_rex
2686 0 35 if length $pattern
2689 21 24 !ref($_) && (1 == length $_ || 3 >= length $_ && exists $trans{$_}) ? :
2705 0 0 unless @{$pattern->[2];} or $pattern->[3]
2706 0 35 unless my(@vals) = $data =~ /$pattern->[1]()/s
2709 0 35 unless $cv == @{$pattern->[2];}
2712 0 45 unless defined(my $v = $vals[$c++])
2713 0 45 if ref $k
2721 1 34 if exists $h{'track'}
2723 0 35 if wantarray and @a
2828 41 0 unless $e and $e->[0]
2859 0 1 $l ? :
2873 0 16 unless $f =~ /($ext_re)/
3005 0 0 unless ($info)
3008 0 0 unless defined $info
3019 0 0 unless eval { do { "I" x (shift())->mpeg_layer } }
3021 0 0 (shift())->frames_padded ? :
0 0 unless eval { do { (shift())->frames_padded ? "Yes" : "No" } }
3022 0 0 (shift())->is_copyrighted ? :
0 0 unless eval { do { (shift())->is_copyrighted ? "Yes" : "No" } }
3027 32 0 if defined $ms
3029 0 0 unless defined $ms
3051 0 0 if defined $d
3053 0 0 if $self->{'mp3info'} or $self->{'filename'} =~ /\.mp[23]$/i
3055 0 0 unless $r
3096 1 14 unless ref $self
3098 14 1 if defined $time
3101 51 0 if $f =~ /^\??(\{([^{}]+)\}|.)/
3104 0 51 if (not $c++ and $f =~ /^=>(\w)$/)
3105 0 0 unless my $u = $Unit{$1}
3106 0 0 unless defined $time
3113 0 51 unless $ff =~ s/^(\{[^{}]+\}|\w)//
3115 36 15 if ($opt)
3116 15 21 if ($what eq 'H') { }
15 6 elsif ($what eq 'm' or $what eq '{mL}') { }
6 0 elsif ($what eq '{ML}') { }
3117 1 14 unless defined $time
3120 0 15 unless defined $time
3128 0 36 unless $what =~ /^(?:{(.*)}|(.))/
3129 20 16 unless $opt
3133 8 5 if $what eq 's' || $what eq '{SL}' and grep $have{$_}, ("H", "m", "mL") or $what eq "{mL}" and $have{'H'}
3136 3 28 if $what eq "%{ML}" and grep $have{$_}, ("H", "m", "mL", "s", "S", "SL")
3137 5 26 if ($what eq '%{SML}' and grep $have{$_}, ('H', 'm', 'mL')) { }
3139 5 0 unless $res =~ /^\d\d/
3174 0 14 if @wr == 1 and not $wr[0] =~ /\D/
3194 13 1 if $wr
3230 14 18 unless defined $data
3233 13 19 unless (exists $mp3->{'ID3v1'})
3241 143 74 unless defined $d
3242 18 56 unless ref $d
3243 74 0 if $d->[1] ne "ID3v1"
3248 0 31 defined $mp3->{'ms'} ? :
3252 5 17 if not $force2 and $mp3->{'ID3v1'}->fits_tag($data) and not exists $mp3->{'ID3v2'} and $do_length < 2
3255 3 23 unless (exists $mp3->{'ID3v2'})
3256 2 1 if (defined $wr2) { }
3257 0 2 unless $wr2
3265 113 69 unless defined $d
3266 13 56 unless ref $d
3267 60 9 if $d->[1] ne "ID3v2"
3272 0 26 if $do_length and not $mp3->have_id3v2_frame("TLEN")
3283 0 71 if ref $data
3290 68 3 if @data == 1
3294 49 89 if $genre eq ""
3297 14 75 if ($genre =~ /\D/)
3301 12 2 if $genre_num eq 255 or $genre_num eq ""
3302 1 1 if $firstnum
3303 1 0 if $prefer_num
3305 0 0 unless defined $genre_num
3308 61 27 unless ($prefer_num or $genre =~ /\D/)
3309 22 39 unless my $genre_str = MP3::Tag::ID3v1::genres($genre)
3310 15 24 if $firstnum
3314 0 73 if lc $genre eq "rx"
3315 0 73 if lc $genre eq "cr"
3316 37 36 if length $genre and not $genre =~ /\D/
3317 72 1 unless $seen{$genre}++
3319 7 48 if $firstnum
3335 13 1 if grep(($ext eq lc $_), @_)
3341 82 2 if (exists $self->{'filename'} and defined $self->{'filename'})
3348 0 0 if $line =~ /^\s*(#|$)/
3349 0 0 unless $line =~ /^\s*(\w+)\s*=\s*(.*?)\s*$/
3369 0 0 unless defined $file
3370 0 0 unless defined $file
3371 0 0 if $ENV{'HOME'}
3372 0 0 unless -e $file
3373 0 0 unless open F, "< $file"
3378 0 0 unless CORE::close F
3394 0 0 if eval "require MP3::Tag::$par; 1"