Bumper.pm

filter: Statementstmt 95.2% 398 / 418 Branchbran 80.0% 192 / 240 Conditioncond 76.7% 122 / 159 MC/DCmcdc 63.4% 59 / 93 Subroutinesub 98.1% 53 / 54 Podpod 100% 11 / 11 totaltotal 85.6% 835 / 975 CC 219 SCAR 36.6
CC
219
Cov
87%
_ppi_list_to_perl_list
262.3
_cleanup_bundled_features
32.1
_handle_compat_modules
21.1
CRAP 38.9
↑ Summary Bumper/Helper/Version.pm »
1 5 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package Perl::Version::Bumper;
4 5 $Perl::Version::Bumper::VERSION = '0.277';
5  
6 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 ▶use Path::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use PPI::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use PPI::Token::Operator;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use PPI::Token::Attribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use Carp qw( carp croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 5 ▶use Perl::Version::Bumper::Helper::Version qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
17 version_fmt
18 version_use
19 stable_version
20 stable_version_dec
21 5 );
22  
23 # CLASS METHODS
24  
25 5 my $feature_version;
26  
27 44 ▶sub feature_version { $feature_version }
Subroutine feature_version: called CC=1 SCAR=0.0
Pod documented
28  
29 # reconstruct everything we know about every feature
30 # from the $DATA variable defined at the end of the file
31 my $FEATURE_DATA;
32  
33 5 ▶sub feature_data {
Subroutine feature_data: called CC=9 SCAR=22.0
Pod documented
34 5 my %feature;
35 5 for ( grep !/\A(?:=|\z)/, split /\n/, $FEATURE_DATA ) {
36 155 ▶ if (/\A *([1-9][0-9.]*)/) { # header line
Branch: 1 branch
BranchTrueFalseTotal
if (/\A *([1-9][0-9.]*)/) 5 150 155
37 5 $feature_version = version_fmt($1);
38 5 next;
39 }
40 150 my $feature = substr $_, 0, 33, ''; # %32s
41 150 my $known = substr $_, 0, 9, ''; # %-8s
42 150 my $enabled = substr $_, 0, 9, ''; # %-8s
43 150 my $disabled = substr $_, 0, 9, ''; # %-8s
44 150 my $removed = substr $_, 0, 9, ''; # %-8s
45 150 my @compat = split ' '; # %s
46 150 y/ //d for $feature, $known, $enabled, $disabled, $removed;
47 150 $feature{$feature}{known} = $known;
48 150 ▶ $feature{$feature}{enabled} = $enabled if $enabled;
Branch: 1 branch
BranchTrueFalseTotal
if $enabled 110 40 150
49 150 ▶ $feature{$feature}{disabled} = $disabled if $disabled;
Branch: 1 branch
BranchTrueFalseTotal
if $disabled 35 115 150
50 150 ▶ $feature{$feature}{removed} = $removed if $removed;
Branch: 1 branch
BranchTrueFalseTotal
if $removed 5 145 150
51 150 ▶ $feature{$feature}{compat} = {@compat} if @compat;
Branch: 1 branch
BranchTrueFalseTotal
if @compat 35 115 150
52 150 ▶ $feature{$feature}{unfeature} = 1 if $disabled;
Branch: 1 branch
BranchTrueFalseTotal
if $disabled 35 115 150
53 }
54 5 return \%feature;
55 }
56  
57 5 my %feature = %{ feature_data() };
58  
59 # CONSTRUCTOR
60  
61 8778 ▶sub _feature_in_bundle {
Subroutine _feature_in_bundle: called CC=5 SCAR=16.1
62 8778 my $version_num = shift;
63 return {
64 known => {
65 map +( $_ => $feature{$_}{known} ),
66 grep exists $feature{$_}{known} && $version_num >= $feature{$_}{known},
67 keys %feature
68 },
69 enabled => {
70 map +( $_ => $feature{$_}{enabled} ),
71 grep !exists $feature{$_}{disabled} || $version_num < $feature{$_}{disabled},
72 grep exists $feature{$_}{enabled} && $version_num >= $feature{$_}{enabled},
73 keys %feature
74 },
75 disabled => {
76 map +( $_ => $feature{$_}{disabled} ),
77 grep exists $feature{$_}{disabled} && $version_num >= $feature{$_}{disabled},
78 8778 ▶ keys %feature
Condition91%11/12
exists $feature{$_}{'known'} && $version_num >= $feature{$_}{'known'}
!ll&&!rl&&r
0139445123895
!exists $feature{$_}{'disabled'} || $version_num < $feature{$_}{'disabled'}
l!l&&r!l&&!r
719684719213876
exists $feature{$_}{'enabled'} && $version_num >= $feature{$_}{'enabled'}
!ll&&!rl&&r
7022460080133036
exists $feature{$_}{'disabled'} && $version_num >= $feature{$_}{'disabled'}
!ll&&!rl&&r
2018944757013876
MC/DC50%1/2
exists $feature{$_}{'known'} && $version_num >= $feature{$_}{'known'}
exists $feature{$_}{'known'} $version_num >= $feature{$_}{'known'}
MC/DC100%2/2
!exists $feature{$_}{'disabled'} || $version_num < $feature{$_}{'disabled'}
!exists $feature{$_}{'disabled'} $version_num < $feature{$_}{'disabled'}
MC/DC100%2/2
exists $feature{$_}{'enabled'} && $version_num >= $feature{$_}{'enabled'}
exists $feature{$_}{'enabled'} $version_num >= $feature{$_}{'enabled'}
MC/DC100%2/2
exists $feature{$_}{'disabled'} && $version_num >= $feature{$_}{'disabled'}
exists $feature{$_}{'disabled'} $version_num >= $feature{$_}{'disabled'}
Truth table66%2/3
A && B
A= exists $feature{$_}{'known'}B= $version_num >= $feature{$_}{'known'}
ABresult
0X0
100
111
Truth table100%3/3
not(A) || B
A= !exists $feature{$_}{'disabled'}B= $version_num < $feature{$_}{'disabled'}
ABresult
1X1
011
000
Truth table100%3/3
A && B
A= exists $feature{$_}{'enabled'}B= $version_num >= $feature{$_}{'enabled'}
ABresult
0X0
100
111
Truth table100%3/3
A && B
A= exists $feature{$_}{'disabled'}B= $version_num >= $feature{$_}{'disabled'}
ABresult
0X0
100
111
79 },
80 };
81 }
82  
83 4520 ▶sub new {
Subroutine new: called CC=7 SCAR=21.0
Pod documented
84  
85 # stolen from Moo::Object
86 4520 my $class = shift;
87 my $args = scalar @_ == 1
88 ? ref $_[0] eq 'HASH'
89 0 ▶ ? { %{ $_[0] } }
Branch: 3 branches
BranchTrueFalseTotal
scalar @_ == 1 ? : 0 4520 4520
ref $_[0] eq 'HASH' ? : 0 0 0
@_ % 2 ? : 0 4520 4520
90 : Carp::croak("Single parameters to new() must be a HASH ref"
91 . " data => ". $_[0])
92 : @_ % 2
93 ? Carp::croak("The new() method for $class expects a hash reference or a"
94 . " key/value list. You passed an odd number of arguments")
95 : {@_}
96 ;
97  
98 # handle the version attribute
99 4520 ▶ my $version_arg = $args->{version} // stable_version($]);
Condition66%2/3
$args->{"version"} // stable_version($])
l!l&&r!l&&!r
451910
MC/DC0%0/2
$args->{"version"} // stable_version($])
$args->{"version"} stable_version($])
Truth table66%2/3
A // B
A= $args->{"version"}B= stable_version($])
ABresult
1X1
011
000
100 4520 my $version_num = version_fmt( $version_arg );
101 4517 ▶ croak "Unsupported Perl version: $version_arg (greater than $feature_version)"
Branch: 1 branch
BranchTrueFalseTotal
if $version_num > $feature_version 3 4514 4517
102 if $version_num > $feature_version;
103 4514 ▶ croak "$args->{version} is not a stable Perl version"
Branch: 1 branch
BranchTrueFalseTotal
if $version_num ne stable_version($version_num) 2 4512 4514
104 if $version_num ne stable_version($version_num);
105  
106 4512 return bless {
107 version => version_use($version_num),
108 version_num => $version_num,
109 feature_in_bundle => _feature_in_bundle($version_num),
110 }, $class;
111 };
112  
113 # ATTRIBUTES
114  
115 14723 ▶sub version { shift->{version} }
Subroutine version: called CC=1 SCAR=0.0
Pod documented
116  
117 17797 ▶sub version_num { shift->{version_num} }
Subroutine version_num: called CC=1 SCAR=0.0
Pod documented
118  
119 # PRIVATE FUNCTIONS
120  
121 21150 ▶sub __evaluate {
Subroutine __evaluate: called CC=5 SCAR=28.2
122 map ref()
123 ? $_->[0] eq 'CODE'
124 0 ▶ ? sub { } # leave anonymous subs as is
Subroutine __ANON__: not called CC=1 SCAR=0.0
125 21150 ▶ : $_->[0] eq '[' ? [ __SUB__->( @$_[ 1 .. $#$_ ] ) ] # ARRAY
Branch: 4 branches
BranchTrueFalseTotal
ref $_ ? : 0 21573 21573
$_->[0] eq 'CODE' ? : 0 0 0
$_->[0] eq '[' ? : 0 0 0
$_->[0] eq '{' ? : 0 0 0
126 : $_->[0] eq '{' ? { __SUB__->( @$_[ 1 .. $#$_ ] ) } # HASH
127 : __SUB__->( @$_[ 1 .. $#$_ ] ) # LIST (flattened)
128 : $_, # SCALAR
129 @_;
130 }
131  
132 # given a list of PPI tokens, construct a Perl data structure
133 21150 ▶sub _ppi_list_to_perl_list {
Subroutine _ppi_list_to_perl_list: called CC=29 SCAR=55.7
134  
135 # are there constants we ought to know about?
136 21150 ▶ my $constants = ref $_[-1] eq 'HASH' ? pop @_ : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 0 21150 21150
137  
138 # make sure we have tokens (i.e. deconstruct Statement and Structure objects)
139 21150 my @tokens = grep $_->significant, map $_->tokens, @_;
140 21150 my @stack = my $root = my $ptr = [];
141 21150 my $prev;
142 21150 ▶ while ( my $token = shift @tokens ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = shift @tokens) 21246 21150 42396
143 21246 ▶ if ( $token->isa('PPI::Token::Structure') ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($token->isa('PPI::Token::Structure')) { } 0 21246 21246
elsif ($token eq ',' or $token eq '=>') { } 129 21117 21246
elsif ($token->isa('PPI::Token::Symbol')) { } 0 21117 21117
elsif ($token->isa('PPI::Token::Word') and $token eq 'undef' and $tokens[0] ? $tokens[0] ne '=>' : !0) { } 0 21117 21117
elsif ($token->isa('PPI::Token::HereDoc')) { } 0 21117 21117
144 0 ▶ if ( $token =~ /\A[[{(]\z/ ) { # opening
Branch: 2 branches
BranchTrueFalseTotal
if ($token =~ /\A[[{(]\z/) { } 0 0 0
elsif ($token =~ /\A[]})]\z/) { } 0 0 0
145 $ptr = $token eq '{' && $prev && $prev eq 'sub' # sub { ... }
146 0 ▶ ? do { pop @{ $stack[-1] }; ['CODE'] } # drop 'sub' token
Branch: 1 branch
BranchTrueFalseTotal
$token eq '{' && $prev && $prev eq 'sub' ? : 0 0 0
Condition0%0/6
$token eq "{" and $prev and $prev eq "sub"
!ll&&!rl&&r
000
$token eq "{" and $prev
!ll&&!rl&&r
000
MC/DC0%0/3
$token eq "{" and $prev and $prev eq "sub"
$token eq "{" $prev $prev eq "sub"
Truth table0%0/4
A and B and C
A= $token eq "{"B= $prevC= $prev eq "sub"
ABCresult
0XX0
10X0
1100
1111
147 : ["$token"];
148 0 push @{ $stack[-1] }, $ptr;
149 0 push @stack, $ptr;
150 }
151 elsif ( $token =~ /\A[]})]\z/ ) { # closing
152 0 pop @stack;
153 0 $ptr = $stack[-1];
154 }
155 }
156 ▶ elsif ( $token eq ',' || $token eq '=>' ) { } # skip
Condition66%2/3
$token eq "," or $token eq "=>"
l!l&&r!l&&!r
129021117
MC/DC50%1/2
$token eq "," or $token eq "=>"
$token eq "," $token eq "=>"
Truth table66%2/3
A or B
A= $token eq ","B= $token eq "=>"
ABresult
1X1
011
000
157 elsif ( $token->isa('PPI::Token::Symbol') ) { # variable
158  
159 # construct the expression back (and keep the object around)
160 0 my $expr = PPI::Document->new( \join '', $token, @tokens );
161  
162 # PPI::Document -> PPI::Statement
163 # -> PPI::Token::Symbol (ignored), PPI::Sructure::Subscript (maybe)
164 0 my ( undef, $subscript ) = $expr->child(0)->children;
165 0 ▶ if ( $subscript && $subscript->isa('PPI::Structure::Subscript') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subscript and $subscript->isa('PPI::Structure::Subscript')) { } 0 0 0
Condition0%0/3
$subscript and $subscript->isa("PPI::Structure::Subscript")
!ll&&!rl&&r
000
MC/DC0%0/2
$subscript and $subscript->isa("PPI::Structure::Subscript")
$subscript $subscript->isa("PPI::Structure::Subscript")
Truth table0%0/3
A and B
A= $subscriptB= $subscript->isa("PPI::Structure::Subscript")
ABresult
0X0
100
111
166 0 shift @tokens for $subscript->tokens; # drop subcript tokens
167 0 push @$ptr, "$token$subscript"; # symbol + subscript
168 }
169 else {
170 0 push @$ptr, "$token"; # simple symbol
171 }
172 }
173 ▶ elsif ($token->isa('PPI::Token::Word') # undef
Branch: 1 branch
BranchTrueFalseTotal
$tokens[0] ? : 0 0 0
Condition33%2/6
$token->isa("PPI::Token::Word") and $token eq "undef" and
!ll&&!rl&&r
2111700
$token->isa("PPI::Token::Word") and $token eq "undef"
!ll&&!rl&&r
2111700
MC/DC0%0/3
$token->isa("PPI::Token::Word") and $token eq "undef" and
$token->isa("PPI::Token::Word") $token eq "undef"
Truth table25%1/4
A and B and C
A= $token->isa("PPI::Token::Word")B= $token eq "undef"C=
ABCresult
0XX0
10X0
1100
1111
174 && $token eq 'undef'
175 && ( $tokens[0] ? $tokens[0] ne '=>' : !!1 ) )
176 {
177 0 push @$ptr, undef;
178 }
179 elsif ($token->isa('PPI::Token::HereDoc') ) { # heredoc
180 0 push @$ptr, join '', $token->heredoc;
181 }
182 else {
183 21117 my $next_sibling = $token->snext_sibling;
184 push @$ptr,
185  
186 # maybe a known constant?
187 exists $constants->{$token} && ( $next_sibling ? $next_sibling ne '=>' : !!1 )
188 ? $constants->{$token}
189  
190 # various types of strings
191 : $token->can('literal') ? $token->literal
192 21117 ▶ : $token->can('simplify') ? do {
Branch: 4 branches
BranchTrueFalseTotal
exists $constants->{$token} && ($next_sibling ? $next_sibling ne '=>' : !0) ? : 0 21117 21117
$next_sibling ? : 0 0 0
$token->can('literal') ? : 20823 294 21117
$token->can('simplify') ? : 294 0 294
Condition33%1/3
exists $constants->{$token} and
!ll&&!rl&&r
2111700
MC/DC0%0/2
exists $constants->{$token} and
exists $constants->{$token}
Truth table33%1/3
A and B
A= exists $constants->{$token}B=
ABresult
0X0
100
111
193 294 my $clone = $token->clone;
194 294 ▶ $clone->simplify && $clone->can('literal')
Branch: 3 branches
BranchTrueFalseTotal
$clone->simplify && $clone->can('literal') ? : 294 0 294
$token->can('string') ? : 0 0 0
$token->isa('PPI::Token::Operator') ? : 0 0 0
Condition33%1/3
$clone->simplify and $clone->can("literal")
!ll&&!rl&&r
00294
MC/DC0%0/2
$clone->simplify and $clone->can("literal")
$clone->simplify $clone->can("literal")
Truth table33%1/3
A and B
A= $clone->simplifyB= $clone->can("literal")
ABresult
0X0
100
111
195 ? $clone->literal
196 : "$clone";
197 }
198 : $token->can('string') ? $token->string
199  
200 # stop at the first operator
201 : $token->isa( 'PPI::Token::Operator' ) ? last
202  
203 # give up and just stringify
204 : "$token";
205 }
206 21246 $prev = $token;
207 }
208 21150 return __evaluate(@$root);
209 }
210  
211 14421 ▶sub _drop_statement {
Subroutine _drop_statement: called CC=16 SCAR=27.8
212 14421 my ( $stmt, $keep_comments ) = @_;
213  
214 # remove non-significant elements before the statement
215 14421 ▶ while ( my $prev_sibling = $stmt->previous_sibling ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $prev_sibling = $stmt->previous_sibling) 14967 0 14967
216 14967 ▶ last if $prev_sibling->significant;
Branch: 1 branch
BranchTrueFalseTotal
if $prev_sibling->significant 105 14862 14967
217 14862 ▶ last if $prev_sibling =~ /\n\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $prev_sibling =~ /\n\z/ 14316 546 14862
218 546 $prev_sibling->remove;
219 }
220  
221 # remove non-significant elements after the statement
222 # if there was no significant element before it on the same line
223 # (i.e. it was the only statement on the line)
224 14421 $stmt->document->index_locations;
225 14421 ▶ if ( !$stmt->sprevious_sibling
Branch: 1 branch
BranchTrueFalseTotal
if (not $stmt->sprevious_sibling or $stmt->sprevious_sibling->location->[0] ne $stmt->location->[0]) 14316 105 14421
Condition100%3/3
not $stmt->sprevious_sibling or $stmt->sprevious_sibling->location->[0] ne $stmt->location->[0]
l!l&&r!l&&!r
27314043105
MC/DC100%2/2
not $stmt->sprevious_sibling or $stmt->sprevious_sibling->location->[0] ne $stmt->location->[0]
not $stmt->sprevious_sibling $stmt->sprevious_sibling->location->[0] ne $stmt->location->[0]
Truth table100%3/3
not(A) or B
A= not $stmt->sprevious_siblingB= $stmt->sprevious_sibling->location->[0] ne $stmt->location->[0]
ABresult
1X1
011
000
226 || $stmt->sprevious_sibling->location->[0] ne $stmt->location->[0] )
227 {
228  
229 # collect non-significant elements until next newline (included)
230 14316 my ( $next, @to_drop ) = ($stmt);
231 14316 ▶ while ( $next = $next->next_sibling ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($next = $next->next_sibling) 14655 0 14655
232 14655 ▶ if ( $next->significant ) { # might be a compound statement
Branch: 1 branch
BranchTrueFalseTotal
if ($next->significant) 147 14508 14655
233 147 for my $child ( $next->children ) {
234 147 ▶ last if $child->significant;
Branch: 1 branch
BranchTrueFalseTotal
if $child->significant 93 54 147
235 54 push @to_drop, $child;
236 54 ▶ last if $child =~ /\n\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $child =~ /\n\z/ 54 0 54
237 }
238 147 last;
239 }
240 14508 push @to_drop, $next;
241 14508 ▶ last if $next =~ /\n\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $next =~ /\n\z/ 14169 339 14508
242 }
243  
244 # do not drop comments if asked to keep them
245 14316 ▶ @to_drop = grep !$_->isa('PPI::Token::Comment') && $_ ne "\n", @to_drop
Branch: 1 branch
BranchTrueFalseTotal
if $keep_comments and grep $_->isa("PPI::Token::Comment"), @to_drop 123 14193 14316
Condition100%6/6
$keep_comments and grep $_->isa("PPI::Token::Comment"), @to_drop
!ll&&!rl&&r
113642829123
!$_->isa('PPI::Token::Comment') && $_ ne "\n"
!ll&&!rl&&r
123123123
MC/DC100%2/2
$keep_comments and grep $_->isa("PPI::Token::Comment"), @to_drop
$keep_comments grep $_->isa("PPI::Token::Comment"), @to_drop
MC/DC100%2/2
!$_->isa('PPI::Token::Comment') && $_ ne "\n"
!$_->isa('PPI::Token::Comment') $_ ne "\n"
Truth table100%3/3
A and B
A= $keep_commentsB= grep $_->isa("PPI::Token::Comment"), @to_drop
ABresult
0X0
100
111
Truth table100%3/3
not(A) && B
A= !$_->isa('PPI::Token::Comment')B= $_ ne "\n"
ABresult
0X0
100
111
246 if $keep_comments && grep $_->isa('PPI::Token::Comment'), @to_drop;
247 14316 $_->remove for @to_drop;
248  
249 14316 $stmt->document->flush_locations;
250 }
251  
252 # and finally remove it
253 14421 $stmt->remove;
254 }
255  
256 13530 ▶sub _drop_bare {
Subroutine _drop_bare: called CC=3 SCAR=11.0
257 13530 my ( $type, $module, $doc ) = @_;
258 my $use_module = $doc->find(
259 94746 ▶ sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
260 94746 my ( $root, $elem ) = @_;
261 94746 ▶ return !!1
Branch: 1 branch
BranchTrueFalseTotal
if $elem->isa("PPI::Statement::Include") and $elem->module eq $module and $elem->type eq $type and not $elem->arguments 1395 93351 94746
Condition88%8/9
$elem->isa("PPI::Statement::Include") and $elem->module eq $module and $elem->type eq $type and not $elem->arguments
!ll&&!rl&&r
9335101395
$elem->isa("PPI::Statement::Include") and $elem->module eq $module and $elem->type eq $type
!ll&&!rl&&r
930363151395
$elem->isa("PPI::Statement::Include") and $elem->module eq $module
!ll&&!rl&&r
59214338221710
MC/DC75%3/4
$elem->isa("PPI::Statement::Include") and $elem->module eq $module and $elem->type eq $type and not $elem->arguments
$elem->isa("PPI::Statement::Include") $elem->module eq $module $elem->type eq $type not $elem->arguments
Truth table80%4/5
A and B and C and not(D)
A= $elem->isa("PPI::Statement::Include")B= $elem->module eq $moduleC= $elem->type eq $typeD= not $elem->arguments
ABCDresult
0XXX0
10XX0
110X0
11100
11111
262 if $elem->isa('PPI::Statement::Include')
263 && $elem->module eq $module
264 && $elem->type eq $type
265 && !$elem->arguments; # bare use module
266 93351 return; # only top-level
267 }
268 13530 );
269 13530 ▶ if ( ref $use_module ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $use_module) 1395 12135 13530
270 1395 _drop_statement($_) for @$use_module;
271 }
272 13530 return;
273 }
274  
275 214740 ▶sub _find_include {
Subroutine _find_include: called CC=4 SCAR=13.9
276 214740 my ( $module, $doc, $type ) = @_;
277 my $found = $doc->find(
278 6668355 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
279 6668355 my ( $root, $elem ) = @_;
280 6668355 ▶ return !!1
Branch: 1 branch
BranchTrueFalseTotal
if $elem->isa("PPI::Statement::Include") and $elem->module eq $module 83091 6585264 6668355
Condition100%3/3
$elem->isa("PPI::Statement::Include") and $elem->module eq $module
!ll&&!rl&&r
594743763782783091
MC/DC100%2/2
$elem->isa("PPI::Statement::Include") and $elem->module eq $module
$elem->isa("PPI::Statement::Include") $elem->module eq $module
Truth table100%3/3
A and B
A= $elem->isa("PPI::Statement::Include")B= $elem->module eq $module
ABresult
0X0
100
111
281 if $elem->isa('PPI::Statement::Include')
282 && $elem->module eq $module;
283 6585264 return !!0;
284 }
285 214740 );
286 214740 ▶ croak "Bad condition for PPI::Node->find"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $found 0 214740 214740
287 unless defined $found; # error
288 214740 ▶ return unless $found; # nothing found
Branch: 1 branch
BranchTrueFalseTotal
unless $found 184899 29841 214740
289 29841 ▶ return $type ? grep $_->type eq $type, @$found : @$found;
Branch: 1 branch
BranchTrueFalseTotal
$type ? : 28884 957 29841
290 }
291  
292 17805 ▶sub _version_stmts {
Subroutine _version_stmts: called CC=3 SCAR=11.0
293 17805 my ($doc) = @_;
294 my $version_stmts = $doc->find(
295 788451 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
296 788451 my ( $root, $elem ) = @_;
297 788451 ▶ return !!1 if $elem->isa('PPI::Statement::Include') && $elem->version;
Branch: 1 branch
BranchTrueFalseTotal
if $elem->isa("PPI::Statement::Include") and $elem->version 8991 779460 788451
Condition100%3/3
$elem->isa("PPI::Statement::Include") and $elem->version
!ll&&!rl&&r
703389760718991
MC/DC100%2/2
$elem->isa("PPI::Statement::Include") and $elem->version
$elem->isa("PPI::Statement::Include") $elem->version
Truth table100%3/3
A and B
A= $elem->isa("PPI::Statement::Include")B= $elem->version
ABresult
0X0
100
111
298 779460 return !!0;
299 }
300 17805 );
301 17805 ▶ croak "Bad condition for PPI::Node->find"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version_stmts 0 17805 17805
302 unless defined $version_stmts;
303 17805 ▶ return $version_stmts ? @$version_stmts : ();
Branch: 1 branch
BranchTrueFalseTotal
$version_stmts ? : 8910 8895 17805
304 }
305  
306 5 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
307 5 ENABLED => 'enabled',
308 DISABLED => 'disabled',
309 5 };
310  
311 5 ▶use Hash::Util::FieldHash;
Subroutine BEGIN: called CC=1 SCAR=0.0
312 5 Hash::Util::FieldHash::fieldhash my %feature_by_scope;
313 5 my %feature_votes;
314 5 $feature_votes{+ENABLED} = {};
315 5 $feature_votes{+DISABLED} = {};
316 5 Hash::Util::FieldHash::fieldhashes values %feature_votes;
317  
318 # keep track of features explicitly enabled/disabled in each scope
319 # this is keyed by scope and feature, and the value is status and statement
320 79845 ▶sub _add_feature_to_scope {
Subroutine _add_feature_to_scope: called CC=5 SCAR=16.2
321 79845 my ( $elem, $feature, $status ) = @_;
322 79845 ▶ croak "Invalid status value: '$status'"
Branch: 1 branch
BranchTrueFalseTotal
if $status ne "enabled" and $status ne "disabled" 0 79845 79845
Condition66%2/3
$status ne "enabled" and $status ne "disabled"
!ll&&!rl&&r
68202116430
MC/DC0%0/2
$status ne "enabled" and $status ne "disabled"
$status ne "enabled" $status ne "disabled"
Truth table66%2/3
A and B
A= $status ne "enabled"B= $status ne "disabled"
ABresult
0X0
100
111
323 if $status ne ENABLED && $status ne DISABLED;
324 79845 my $scope = $elem;
325 79845 ▶ while ( $scope->parent ) { # stop at the document root
Branch: 1 branch
BranchTrueFalseTotal
if ($scope->parent) 79845 77901 157746
326 79845 $scope = $scope->parent;
327 79845 ▶ last if $scope->isa('PPI::Structure::Block');
Branch: 1 branch
BranchTrueFalseTotal
if $scope->isa("PPI::Structure::Block") 1944 77901 79845
328 }
329 79845 $feature_by_scope{$scope}{$feature} = [ $status, $elem ];
330 }
331  
332 # return the status of the feature for the scope surrounding the element
333 # the value is one of: ENABLED, DISABLED, '' (the first two are constants)
334 1044 ▶sub _feature_status_in_scope {
Subroutine _feature_status_in_scope: called CC=4 SCAR=13.9
335 1044 my ( $feature, $elem ) = @_;
336 1044 my $scope = $elem->parent;
337 1044 my $status;
338 1044 ▶ while ( $scope ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scope) 2088 345 2433
339 2088 ▶ $status = $feature_by_scope{$scope}{$feature}[0]
Branch: 1 branch
BranchTrueFalseTotal
$status = $feature_by_scope{$scope}{$feature}[0] and last 699 1389 2088
340 and last;
341 1389 $scope = $scope->parent;
342 }
343 1044 ▶ return $status // '';
Condition100%2/2
$status // ""
l!l
699345
MC/DC100%1/1
$status // ""
$status
Truth table100%2/2
A
A= $status
Aresult
11
00
344 }
345  
346 # return the stack of [ status, stmt ] up to the document root
347 # of all scopes where the feature is enabled or disabled
348 324 ▶sub _feature_status_stack {
Subroutine _feature_status_stack: called CC=5 SCAR=16.1
349 324 my ( $feature, $elem ) = @_;
350 324 my @stack;
351 324 my $scope = ( $elem->parent );
352 324 ▶ while ($scope) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scope) 1512 297 1809
353 1512 ▶ if ( my $status = $feature_by_scope{$scope}{$feature}[0] ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $status = $feature_by_scope{$scope}{$feature}[0]) { } 729 783 1512
elsif (not $scope->parent || $status) { } 27 756 783
354 729 push @stack, [ $status, $feature_by_scope{$scope}{$feature}[1] ];
355 }
356 ▶ elsif ( !$scope->parent && !$status ) { # document root
Condition66%2/3
$scope->parent || $status
l!l&&r!l&&!r
756027
MC/DC50%1/2
$scope->parent || $status
$scope->parent $status
Truth table66%2/3
A || B
A= $scope->parentB= $status
ABresult
1X1
011
000
357 27 push @stack, [ '', $feature_by_scope{$scope}{$feature}[1] ];
358 27 last;
359 }
360 1485 $scope = $scope->parent;
361 }
362 324 return @stack;
363 }
364  
365 # replace a given PPI statement with the given code string
366 # (if the code is undef, just remove the statement entirely)
367 9657 ▶sub _replace_stmt {
Subroutine _replace_stmt: called CC=3 SCAR=11.0
368 9657 my ( $old_stmt, $new_code, $keep_comments ) = @_;
369 9657 ▶ if ( defined $new_code ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $new_code) { } 216 9441 9657
370 216 my $new_stmt = PPI::Document->new( \$new_code );
371 216 $old_stmt->insert_before( $_->remove ) for $new_stmt->elements;
372 216 $old_stmt->remove;
373 }
374 9441 else { _drop_statement( $old_stmt, $keep_comments ); }
375 }
376  
377 my %feature_shine = (
378 when_enabled => {
379  
380 # the 'bitwise' feature may break bitwise operators,
381 # so disable it when bitwise operators are detected
382 5412 ▶ bitwise => sub {
Subroutine __ANON__: called CC=15 SCAR=27.1
383 5412 my ($doc) = @_;
384  
385 # in the following code:
386 # - "safe ops" are the ones (binary and dotted binary) that
387 # depend on the 'bitwise' feature being enabled, and for whom
388 # an explicit enablement can be removed (because `use VERSION`
389 # enables it globally)
390 # - "unsafe ops" are the regular binary ops that worked with
391 # 'bitwise' disabled (explicitly or not), and can't have it
392 # enabled (or not disabled), for fear of breaking
393 # (dotted bitwise operators are detected by PPI >= 1.285)
394 my $bitwise_ops = $doc->find(
395 172056 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
396 172056 my ( $root, $elem ) = @_;
397 172056 ▶ $elem->isa('PPI::Token::Operator')
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Token::Operator") and $elem =~ /\A[&|~^]=?\z/ 2490 169566 172056
398 && $elem =~ /\A[&|~^]=?\z/;
399 }
400 5412 );
401 5412 ▶ return unless $bitwise_ops;
Branch: 1 branch
BranchTrueFalseTotal
unless $bitwise_ops 5007 405 5412
402  
403 # binary ops are safe when 'bitwise' is explicitly enabled,
404 # because they behave as expected, and unsafe it 'bitwise'
405 # wasn't explicitly disabled, because they're expected to
406 # have the old (before 'bitwise') behaviour
407 405 my ( @safe_ops, @unsafe_ops );
408 405 for my $op (@$bitwise_ops) {
409 648 my $status = _feature_status_in_scope( bitwise => $op );
410 648 ▶ if ( $status eq ENABLED ) { push @safe_ops, $op; }
Branch: 2 branches
BranchTrueFalseTotal
if ($status eq 'enabled') { } 297 351 648
elsif ($status ne 'disabled') { } 108 243 351
411 108 elsif ( $status ne DISABLED ) { push @unsafe_ops, $op; }
412 }
413  
414 # add dotted bitwise ops to the safe ops list,
415 # when under an explicitly enabled 'bitwise'
416 my $dotted_bitwise_ops = $doc->find(
417 24381 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
418 24381 my ( $root, $elem ) = @_;
419 24381 ▶ $elem->isa('PPI::Token::Operator')
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Token::Operator") and $elem =~ /\A[&|~^]\.=?\z/ 1026 23355 24381
420 && $elem =~ /\A[&|~^]\.=?\z/;
421 }
422 405 );
423 405 ▶ push @safe_ops,
Branch: 1 branch
BranchTrueFalseTotal
if $dotted_bitwise_ops 27 378 405
424 grep _feature_status_in_scope( bitwise => $_ ) eq ENABLED,
425 @$dotted_bitwise_ops
426 if $dotted_bitwise_ops;
427  
428 # safe ops: lnd the explicit `use feature 'bitwise'`
429 # in the enclosing scope and vote to remove it
430 405 for my $safe_op (@safe_ops) {
431 324 my @status_stack = _feature_status_stack( bitwise => $safe_op );
432 324 my $vote = $feature_votes{ +ENABLED }{ $status_stack[0][1] }{bitwise};
433  
434 # by construction, the first scope in the stack is ENABLED
435 324 ▶ if ( @status_stack > 1 && $status_stack[1][0] eq DISABLED ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@status_stack > 1 and $status_stack[1][0] eq 'disabled') { } 135 189 324
Condition100%3/3
@status_stack > 1 and $status_stack[1][0] eq "disabled"
!ll&&!rl&&r
27162135
MC/DC100%2/2
@status_stack > 1 and $status_stack[1][0] eq "disabled"
@status_stack > 1 $status_stack[1][0] eq "disabled"
Truth table100%3/3
A and B
A= @status_stack > 1B= $status_stack[1][0] eq "disabled"
ABresult
0X0
100
111
436 135 $vote->[1]++; # vote to keep
437 }
438 else {
439 189 $vote->[0]++; # vote to delete
440 }
441 }
442  
443 # if there are no unsafe ops, we're done
444 405 ▶ return unless @unsafe_ops;
Branch: 1 branch
BranchTrueFalseTotal
unless @unsafe_ops 297 108 405
445  
446 # the `use VERSION` inserted earlier is always the first in the doc
447 108 my $insert_point = ( _version_stmts($doc) )[0];
448 108 ▶ my $indent = $insert_point->previous_sibling
Branch: 1 branch
BranchTrueFalseTotal
$insert_point->previous_sibling && $insert_point->previous_sibling->isa('PPI::Token::Whitespace') ? : 54 54 108
Condition66%2/3
$insert_point->previous_sibling and $insert_point->previous_sibling->isa("PPI::Token::Whitespace")
!ll&&!rl&&r
54054
MC/DC50%1/2
$insert_point->previous_sibling and $insert_point->previous_sibling->isa("PPI::Token::Whitespace")
$insert_point->previous_sibling $insert_point->previous_sibling->isa("PPI::Token::Whitespace")
Truth table66%2/3
A and B
A= $insert_point->previous_siblingB= $insert_point->previous_sibling->isa("PPI::Token::Whitespace")
ABresult
0X0
100
111
449 && $insert_point->previous_sibling->isa('PPI::Token::Whitespace')
450 ? $insert_point->previous_sibling
451 : '';
452 108 my $no_feature_bitwise =
453 PPI::Document->new( \"no feature 'bitwise';\n" );
454 $insert_point->insert_after( $_->remove )
455 108 for $no_feature_bitwise->elements;
456  
457 # also add an IMPORTANT comment to warn users
458 108 $insert_point = $insert_point->snext_sibling;
459 108 my $todo_comment = PPI::Document->new( \( << "TODO_COMMENT" ) );
460  
461 $indent# IMPORTANT: Please double-check the use of bitwise operators
462 $indent# before removing the `no feature 'bitwise';` line below.
463 $indent# See manual pages 'feature' (section "The 'bitwise' feature")
464 $indent# and 'perlop' (section "Bitwise String Operators") for details.
465 TODO_COMMENT
466 $insert_point->insert_before( $_->remove )
467 108 for $todo_comment->elements;
468 108 ▶ $insert_point->insert_before( $indent->clone ) if $indent;
Branch: 1 branch
BranchTrueFalseTotal
if $indent 54 54 108
469 },
470  
471 # the 'signatures' feature needs prototypes to be updated.
472 3165 ▶ signatures => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
473 3165 my ($doc) = @_;
474  
475 # find all subs with prototypes
476 3165 my $prototypes = $doc->find('PPI::Token::Prototype');
477 3165 ▶ return unless $prototypes;
Branch: 1 branch
BranchTrueFalseTotal
unless $prototypes 3015 150 3165
478  
479 # and turn them into prototype attributes
480 150 for my $proto (@$prototypes) {
481 next
482 165 ▶ if _feature_status_in_scope( signatures => $proto ) eq
Branch: 1 branch
BranchTrueFalseTotal
if _feature_status_in_scope("signatures", $proto) eq "disabled" 30 135 165
483 DISABLED;
484 135 $proto->insert_before( PPI::Token::Operator->new(':') );
485 135 $proto->insert_before(
486 PPI::Token::Attribute->new("prototype$proto") );
487 135 $proto->remove;
488 }
489 },
490  
491 # the 'fc' feature means CORE::fc is not required
492 7500 ▶ fc => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
493 7500 my ($doc) = @_;
494  
495 # find all occurences of 'CORE::fc'
496 my $core_fc = $doc->find(
497 156825 ▶ sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
498 156825 my ( $root, $elem ) = @_;
499 156825 ▶ return !!1
Branch: 1 branch
BranchTrueFalseTotal
if $elem->isa("PPI::Token::Word") and $elem eq "CORE::fc" 180 156645 156825
Condition100%3/3
$elem->isa("PPI::Token::Word") and $elem eq "CORE::fc"
!ll&&!rl&&r
12737129274180
MC/DC100%2/2
$elem->isa("PPI::Token::Word") and $elem eq "CORE::fc"
$elem->isa("PPI::Token::Word") $elem eq "CORE::fc"
Truth table100%3/3
A and B
A= $elem->isa("PPI::Token::Word")B= $elem eq "CORE::fc"
ABresult
0X0
100
111
500 if $elem->isa('PPI::Token::Word') && $elem eq 'CORE::fc';
501 156645 return !!0;
502 }
503 7500 );
504 7500 ▶ return unless $core_fc;
Branch: 1 branch
BranchTrueFalseTotal
unless $core_fc 7365 135 7500
505  
506 # and replace them by 'fc'
507 # (only when not in scope of a `no feature 'fc'`)
508 $_->replace( PPI::Token::Word->new('fc') )
509 135 for grep _feature_status_in_scope( fc => $_ ) ne DISABLED,
510 @$core_fc;
511 },
512 },
513  
514 when_disabled => {
515  
516 # disabling the 'apostrophe_as_package_separator' feature
517 # drops support for apostrophe in package names
518 1290 ▶ apostrophe_as_package_separator => sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
519 1290 my ($doc) = @_;
520  
521 # find all names with an apostrophe
522 my $apostrophes = $doc->find(
523 55485 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
524 55485 my ( $root, $elem ) = @_;
525 55485 ▶ $elem->isa('PPI::Token::Word') && $elem =~ /'/;
Branch: 1 branch
BranchTrueFalseTotal
$elem->isa("PPI::Token::Word") and $elem =~ /'/ 11745 43740 55485
526 }
527 1290 );
528 1290 ▶ return unless $apostrophes;
Branch: 1 branch
BranchTrueFalseTotal
unless $apostrophes 1272 18 1290
529  
530 # and replace it with double colons
531 18 for my $word (@$apostrophes) {
532 next
533 24 ▶ if ENABLED eq _feature_status_in_scope(
Branch: 1 branch
BranchTrueFalseTotal
if "enabled" eq _feature_status_in_scope("apostrophe_as_package_separator", $word) 6 18 24
534 apostrophe_as_package_separator => $word );
535 18 ( my $colon = "$word" ) =~ s/'/::/g;
536 18 $word->replace( bless { content => $colon },
537 'PPI::Token::Word' );
538 }
539 },
540 },
541  
542 5 );
543  
544 # PRIVATE "METHODS"
545  
546 # handle the case of CPAN modules that serve as compatibility layer for some
547 # features on older Perls, or that existed before the feature was developed
548 10737 ▶sub _handle_compat_modules {
Subroutine _handle_compat_modules: called CC=21 SCAR=30.5
549 10737 my ( $self, $doc ) = @_;
550 10737 my $feature_in_bundle = $self->{feature_in_bundle};
551 10737 for my $feature ( grep exists $feature{$_}{compat}, keys %feature ) {
552 75159 for my $compat ( keys %{ $feature{$feature}{compat} } ) {
553 118107 for my $include_compat ( _find_include( $compat => $doc ) ) {
554  
555 # handle `no $compat;`
556 1065 ▶ if ( $include_compat->type eq 'no' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($include_compat->type eq "no") 309 756 1065
557  
558 # if the feature is known and not disabled
559 # and the compat module has an unimport() sub
560 309 ▶ if ( exists $feature_in_bundle->{known}{$feature}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $feature_in_bundle->{"known"}{$feature} and not exists $feature_in_bundle->{"disabled"}{$feature} and $feature{$feature}{"compat"}{$compat} <= 0) 21 288 309
Condition100%6/6
exists $feature_in_bundle->{"known"}{$feature} and not exists $feature_in_bundle->{"disabled"}{$feature} and $feature{$feature}{"compat"}{$compat} <= 0
!ll&&!rl&&r
18010821
exists $feature_in_bundle->{"known"}{$feature} and not exists $feature_in_bundle->{"disabled"}{$feature}
!ll&&!rl&&r
12357129
MC/DC100%3/3
exists $feature_in_bundle->{"known"}{$feature} and not exists $feature_in_bundle->{"disabled"}{$feature} and $feature{$feature}{"compat"}{$compat} <= 0
exists $feature_in_bundle->{"known"}{$feature} not exists $feature_in_bundle->{"disabled"}{$feature} $feature{$feature}{"compat"}{$compat} <= 0
Truth table100%4/4
A and not(B) and C
A= exists $feature_in_bundle->{"known"}{$feature}B= not exists $feature_in_bundle->{"disabled"}{$feature}C= $feature{$feature}{"compat"}{$compat} <= 0
ABCresult
0XX0
10X0
1100
1111
561 && !exists $feature_in_bundle->{disabled}{$feature}
562 && $feature{$feature}{compat}{$compat} <= 0 )
563 {
564 21 my $no_feature = # feature enabled, and not disabled yet
565 PPI::Document->new( \"no feature '$feature';\n" );
566 $include_compat->insert_after( $_->remove )
567 21 for $no_feature->elements;
568 }
569  
570 # some compat modules have no unimport() sub
571 # so we drop the useless `no $compat`
572 _drop_statement($include_compat)
573 if exists $feature_in_bundle->{known}{$feature}
574 309 ▶ || $feature{$feature}{compat}{$compat} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if exists $feature_in_bundle->{"known"}{$feature} or $feature{$feature}{"compat"}{$compat} > 0 186 123 309
Condition66%2/3
exists $feature_in_bundle->{"known"}{$feature} or $feature{$feature}{"compat"}{$compat} > 0
l!l&&r!l&&!r
1860123
MC/DC50%1/2
exists $feature_in_bundle->{"known"}{$feature} or $feature{$feature}{"compat"}{$compat} > 0
exists $feature_in_bundle->{"known"}{$feature} $feature{$feature}{"compat"}{$compat} > 0
Truth table66%2/3
A or B
A= exists $feature_in_bundle->{"known"}{$feature}B= $feature{$feature}{"compat"}{$compat} > 0
ABresult
1X1
011
000
575 }
576  
577 # handle `use $compat;`
578 1065 ▶ if ( $include_compat->type eq 'use' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($include_compat->type eq "use") 756 309 1065
579 756 my $drop_stmt; # should we drop the old statement?
580  
581 # if the feature is known and not enabled or an unfeature
582 # and the compat module has an import() sub
583 756 ▶ if ( exists $feature_in_bundle->{known}{$feature}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $feature_in_bundle->{"known"}{$feature} and !exists $feature_in_bundle->{"enabled"}{$feature} || exists $feature{$feature}{"unfeature"} and $feature{$feature}{"compat"}{$compat} >= 0) 126 630 756
Condition88%8/9
exists $feature_in_bundle->{"known"}{$feature} and !exists $feature_in_bundle->{"enabled"}{$feature} || exists $feature{$feature}{"unfeature"} and $feature{$feature}{"compat"}{$compat} >= 0
!ll&&!rl&&r
6300126
exists $feature_in_bundle->{"known"}{$feature} and !exists $feature_in_bundle->{"enabled"}{$feature} || exists $feature{$feature}{"unfeature"}
!ll&&!rl&&r
333297126
not exists $feature_in_bundle->{"enabled"}{$feature} or exists $feature{$feature}{"unfeature"}
l!l&&r!l&&!r
11115297
MC/DC75%3/4
exists $feature_in_bundle->{"known"}{$feature} and !exists $feature_in_bundle->{"enabled"}{$feature} || exists $feature{$feature}{"unfeature"} and $feature{$feature}{"compat"}{$compat} >= 0
exists $feature_in_bundle->{"known"}{$feature} not exists $feature_in_bundle->{"enabled"}{$feature} exists $feature{$feature}{"unfeature"} $feature{$feature}{"compat"}{$compat} >= 0
Truth table66%4/6
A and not(B) or C and D
A= exists $feature_in_bundle->{"known"}{$feature}B= not exists $feature_in_bundle->{"enabled"}{$feature}C= exists $feature{$feature}{"unfeature"}D= $feature{$feature}{"compat"}{$compat} >= 0
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
584 && ( !exists $feature_in_bundle->{enabled}{$feature}
585 || exists $feature{$feature}{unfeature} )
586 && $feature{$feature}{compat}{$compat} >= 0 )
587 {
588 126 my $use_feature =
589 PPI::Document->new( \"use feature '$feature';\n" );
590 $include_compat->insert_after( $_->remove )
591 126 for $use_feature->elements;
592 126 $drop_stmt++; # it's been replaced
593 }
594  
595 # backward compatibility features, like 'indirect',
596 # can be enabled before being known
597 # (also handle the unlikely case where there's no import())
598 $drop_stmt++
599 if !exists $feature{$feature}{unfeature}
600 && ( exists $feature_in_bundle->{enabled}{$feature}
601 756 ▶ || $feature{$feature}{compat}{$compat} < 0 );
Branch: 1 branch
BranchTrueFalseTotal
if not exists $feature{$feature}{"unfeature"} and exists $feature_in_bundle->{"enabled"}{$feature} || $feature{$feature}{"compat"}{$compat} < 0 297 459 756
Condition83%5/6
not exists $feature{$feature}{"unfeature"} and exists $feature_in_bundle->{"enabled"}{$feature} || $feature{$feature}{"compat"}{$compat} < 0
!ll&&!rl&&r
162297297
exists $feature_in_bundle->{"enabled"}{$feature} or $feature{$feature}{"compat"}{$compat} < 0
l!l&&r!l&&!r
2970297
MC/DC66%2/3
not exists $feature{$feature}{"unfeature"} and exists $feature_in_bundle->{"enabled"}{$feature} || $feature{$feature}{"compat"}{$compat} < 0
not exists $feature{$feature}{"unfeature"} exists $feature_in_bundle->{"enabled"}{$feature} $feature{$feature}{"compat"}{$compat} < 0
Truth table75%3/4
not(A) and B or C
A= not exists $feature{$feature}{"unfeature"}B= exists $feature_in_bundle->{"enabled"}{$feature}C= $feature{$feature}{"compat"}{$compat} < 0
ABCresult
0XX0
1000
11X1
1011
602  
603 756 ▶ _drop_statement($include_compat) if $drop_stmt;
Branch: 1 branch
BranchTrueFalseTotal
if $drop_stmt 423 333 756
604 }
605 }
606 }
607 }
608 }
609  
610 # given $old and $new lists ($new is a subset of $old)
611 # return the items that are in $old and not in $new
612 9573 ▶sub _missing_items {
Subroutine _missing_items: called CC=3 SCAR=11.0
613 9573 my ($old, $new) = @_;
614 9573 my %to_remove;
615 9573 $to_remove{$_}++ for @$old;
616 9573 $to_remove{$_}-- for @$new;
617 9573 return grep $to_remove{$_} > 0, keys %to_remove;
618 }
619  
620 # return $old without any of the $to_remove items
621 9438 ▶sub _remove_items {
Subroutine _remove_items: called CC=1 SCAR=0.0
622 9438 my ( $old, $to_remove ) = @_;
623 9438 my %to_remove;
624 9438 @to_remove{@$to_remove} = ();
625 9438 return grep !exists $to_remove{$_}, @$old;
626 }
627  
628 10737 ▶sub _cleanup_bundled_features {
Subroutine _cleanup_bundled_features: called CC=32 SCAR=34.7
629 10737 my ( $self, $doc, $old_num ) = @_;
630 10737 my $version_num = $self->version_num;
631 10737 my $feature_in_bundle = $self->{feature_in_bundle};
632  
633 # `use feature` and `no feature` are "feature controllers" (or switches),
634 # that are used to enable or disable the feature in the current lexical
635 # scope.
636 #
637 # For every controller, there are several times when we can decide
638 # to remove a feature or not from the argument list of the controller
639 # statement.
640 #
641 # The decision is taken via a "vote": at different times in the
642 # algorithm a vote to remove or keep will be cast. In the end,
643 # a specific feature will be removed from a specific controller
644 # statement when there are no keep votes and at least on remove vote.
645 #
646 # The votes are collected in the %feature_votes hash, which is keyed
647 # by the type of statement: ENABLED (use) or DISABLED (no).
648 # One level down, a FieldHash uses the actual PPI statement as the
649 # key and the values are the features.
650 #
651 # The list of original arguments is stored in the special '' key.
652  
653 10737 for my $module (qw( feature experimental )) {
654  
655 # drop features enabled by this bundle
656 # (also if they were enabled with `use experimental`)
657 21474 for my $stmt ( _find_include( $module => $doc, 'use' ) ) {
658 13233 my @old_args = @{ $feature_votes{ +ENABLED }{$stmt}{''} };
659 my @new_args = # keep enabling features that
660 grep !
661 exists $feature_in_bundle->{enabled}{$_} # are not enabled yet
662 || exists $feature{$_}{unfeature}, # or are unfeatures
663 13233 ▶ grep exists $feature{$_}, # and actually exist
Condition100%3/3
!exists $feature_in_bundle->{'enabled'}{$_} || exists $feature{$_}{'unfeature'}
l!l&&r!l&&!r
36819908838
MC/DC100%2/2
!exists $feature_in_bundle->{'enabled'}{$_} || exists $feature{$_}{'unfeature'}
!exists $feature_in_bundle->{'enabled'}{$_} exists $feature{$_}{'unfeature'}
Truth table100%3/3
not(A) || B
A= !exists $feature_in_bundle->{'enabled'}{$_}B= exists $feature{$_}{'unfeature'}
ABresult
1X1
011
000
664 @old_args;
665 13233 ▶ next if @new_args == @old_args; # nothing to change
Branch: 1 branch
BranchTrueFalseTotal
if @new_args == @old_args 4392 8841 13233
666 $feature_votes{ +ENABLED }{$stmt}{$_}[0]++ # vote to delete
667 8841 for _missing_items( \@old_args, \@new_args );
668 }
669  
670 # drop disabled features that are disabled by this bundle
671 # (also if they were disabled with `no experimental`)
672 21474 for my $stmt ( _find_include( $module => $doc, 'no' ) ) {
673 6846 my @old_args = @{ $feature_votes{ +DISABLED }{$stmt}{''} };
674 my @new_args = # keep disabling features
675 grep exists $feature{$_} # that actually exist and are
676 6846 ▶ && !exists $feature_in_bundle->{disabled}{$_}, # not disabled yet
Condition100%3/3
exists $feature{$_} && !exists $feature_in_bundle->{'disabled'}{$_}
!ll&&!rl&&r
1086486198
MC/DC100%2/2
exists $feature{$_} && !exists $feature_in_bundle->{'disabled'}{$_}
exists $feature{$_} !exists $feature_in_bundle->{'disabled'}{$_}
Truth table100%3/3
A && not(B)
A= exists $feature{$_}B= !exists $feature_in_bundle->{'disabled'}{$_}
ABresult
0X0
100
111
677 @old_args;
678 6846 ▶ next if @new_args == @old_args; # nothing to change
Branch: 1 branch
BranchTrueFalseTotal
if @new_args == @old_args 6114 732 6846
679 $feature_votes{ +DISABLED }{$stmt}{$_}[0]++ # vote to delete
680 732 for _missing_items( \@old_args, \@new_args );
681 }
682 }
683  
684 # deal with compat modules
685 10737 $self->_handle_compat_modules($doc);
686  
687 # apply some feature shine when crossing the feature enablement boundary
688 10737 for my $feature ( sort keys %{ $feature_shine{when_enabled} } ) {
689 32211 my $feature_enabled = $feature{$feature}{enabled};
690 32211 ▶ $feature_shine{when_enabled}{$feature}->($doc)
Branch: 1 branch
BranchTrueFalseTotal
if $old_num < $feature_enabled and $version_num >= $feature_enabled 16077 16134 32211
Condition100%3/3
$old_num < $feature_enabled and $version_num >= $feature_enabled
!ll&&!rl&&r
22171391716077
MC/DC100%2/2
$old_num < $feature_enabled and $version_num >= $feature_enabled
$old_num < $feature_enabled $version_num >= $feature_enabled
Truth table100%3/3
A and B
A= $old_num < $feature_enabledB= $version_num >= $feature_enabled
ABresult
0X0
100
111
691 if $old_num < $feature_enabled # code from before the feature
692 && $version_num >= $feature_enabled; # bumped to after the feature
693 }
694  
695 # apply some feature shine when crossing the feature disablement boundary
696 10737 for my $feature ( sort keys %{ $feature_shine{when_disabled} } ) {
697 10737 my $feature_disabled = $feature{$feature}{disabled};
698 10737 ▶ $feature_shine{when_disabled}{$feature}->($doc)
Branch: 1 branch
BranchTrueFalseTotal
if $old_num < $feature_disabled and $version_num >= $feature_disabled 1290 9447 10737
Condition66%2/3
$old_num < $feature_disabled and $version_num >= $feature_disabled
!ll&&!rl&&r
094471290
MC/DC50%1/2
$old_num < $feature_disabled and $version_num >= $feature_disabled
$old_num < $feature_disabled $version_num >= $feature_disabled
Truth table66%2/3
A and B
A= $old_num < $feature_disabledB= $version_num >= $feature_disabled
ABresult
0X0
100
111
699 if $old_num < $feature_disabled # code from before the feature
700 && $version_num >= $feature_disabled; # bumped to after the feature
701 }
702  
703 # drop experimental warnings, if any
704 10737 for my $warn_line ( _find_include( warnings => $doc, 'no' ) ) {
705 1071 my @old_args = _ppi_list_to_perl_list( $warn_line->arguments );
706 1071 ▶ next unless grep /\Aexperimental::/, @old_args;
Branch: 1 branch
BranchTrueFalseTotal
unless grep /\Aexperimental::/, @old_args 339 732 1071
707 my @new_args = grep {
708 732 ( my $feature = $_ ) =~ s/\Aexperimental:://;
709 825 !exists $feature_in_bundle->{enabled}{$feature};
710 }
711 grep /\Aexperimental::/, @old_args;
712 732 my @keep_args = grep !/\Aexperimental::/, @old_args;
713 732 ▶ next if @new_args == @old_args # nothing to remove
Branch: 1 branch
BranchTrueFalseTotal
if @new_args == @old_args or @new_args + @keep_args == @old_args 513 219 732
Condition66%2/3
@new_args == @old_args or @new_args + @keep_args == @old_args
l!l&&r!l&&!r
5130219
MC/DC50%1/2
@new_args == @old_args or @new_args + @keep_args == @old_args
@new_args == @old_args @new_args + @keep_args == @old_args
Truth table66%2/3
A or B
A= @new_args == @old_argsB= @new_args + @keep_args == @old_args
ABresult
1X1
011
000
714 || @new_args + @keep_args == @old_args;
715 219 ▶ _replace_stmt(
Branch: 1 branch
BranchTrueFalseTotal
@new_args || @keep_args ? : 30 189 219
Condition66%2/3
@new_args or @keep_args
l!l&&r!l&&!r
300189
MC/DC50%1/2
@new_args or @keep_args
@new_args @keep_args
Truth table66%2/3
A or B
A= @new_argsB= @keep_args
ABresult
1X1
011
000
716 $warn_line,
717 @new_args || @keep_args # replace old statement
718 30 ? "no warnings @{[ join ', ', map qq{'$_'}, @new_args, @keep_args]};"
719 : undef # or delete it entirely
720 );
721 }
722  
723 # update statements according to the result of the vote
724 10737 for my $status ( ENABLED, DISABLED ) {
725 21474 for my $stmt (
726 map Hash::Util::FieldHash::id_2obj($_),
727 21474 keys %{ $feature_votes{$status} }
728 )
729 {
730 20079 my @remove;
731 20079 my $votes = $feature_votes{$status}{$stmt};
732  
733 # check all features controlled by that statement
734 20079 for my $feature ( grep $_, keys %$votes ) {
735 next
736 if !$votes->{$feature}[0] # no deletion vote
737 9702 ▶ || $votes->{$feature}[1]; # at least one keep vote
Branch: 1 branch
BranchTrueFalseTotal
if not $votes->{$feature}[0] or $votes->{$feature}[1] 135 9567 9702
Condition66%2/3
not $votes->{$feature}[0] or $votes->{$feature}[1]
l!l&&r!l&&!r
01359567
MC/DC50%1/2
not $votes->{$feature}[0] or $votes->{$feature}[1]
not $votes->{$feature}[0] $votes->{$feature}[1]
Truth table66%2/3
not(A) or B
A= not $votes->{$feature}[0]B= $votes->{$feature}[1]
ABresult
1X1
011
000
738 9567 push @remove, $feature;
739 }
740 20079 ▶ if (@remove) {
Branch: 1 branch
BranchTrueFalseTotal
if (@remove) 9438 10641 20079
741 9438 ▶ my $verb = $status eq ENABLED ? 'use' : 'no';
Branch: 1 branch
BranchTrueFalseTotal
$status eq 'enabled' ? : 8706 732 9438
742 9438 my $module = $stmt->module;
743 my $features = join ', ', map qq{'$_'},
744 9438 _remove_items( $feature_votes{$status}{$stmt}{''}, \@remove );
745 9438 ▶ _replace_stmt( $stmt,
Branch: 1 branch
BranchTrueFalseTotal
$features ? : 186 9252 9438
746 $features ? "$verb $module $features;" : undef );
747 }
748 }
749 }
750  
751 # strict is automatically enabled with 5.12
752 10737 ▶ _drop_bare( use => strict => $doc ) if $version_num >= 5.012;
Branch: 1 branch
BranchTrueFalseTotal
if $version_num >= "5.012" 10230 507 10737
753  
754 # warnings are automatically enabled with 5.36
755 10737 ▶ _drop_bare( use => warnings => $doc ) if $version_num >= 5.036;
Branch: 1 branch
BranchTrueFalseTotal
if $version_num >= "5.036" 3300 7437 10737
756  
757 10737 return;
758 }
759  
760 10791 ▶sub _insert_version_stmt {
Subroutine _insert_version_stmt: called CC=17 SCAR=28.3
761 10791 my ( $self, $doc, $old_num ) = @_;
762 10791 ▶ $old_num //= 5.008;
Condition100%2/2
$old_num //= "5.008"
l!l
29767815
MC/DC100%1/1
$old_num //= "5.008"
$old_num
Truth table100%2/2
A
A= $old_num
Aresult
11
00
763 10791 my $version_stmt =
764 PPI::Document->new( \sprintf "use %s;\n", $self->version );
765 10791 ▶ my $insert_point = $doc->schild(0) // $doc->child(0);
Condition100%3/3
$doc->schild(0) // $doc->child(0)
l!l&&r!l&&!r
106835454
MC/DC100%2/2
$doc->schild(0) // $doc->child(0)
$doc->schild(0) $doc->child(0)
Truth table100%3/3
A // B
A= $doc->schild(0)B= $doc->child(0)
ABresult
1X1
011
000
766 10791 ▶ return unless defined $insert_point; # empty document
Branch: 1 branch
BranchTrueFalseTotal
unless defined $insert_point 54 10737 10791
767  
768 # record the indent before the next significant sibling
769 # (unless it's a version statement: it will be removed,
770 # and this version statement will replace it)
771 10737 my $indent;
772 10737 ▶ $indent = $insert_point->previous_sibling
Branch: 1 branch
BranchTrueFalseTotal
if $insert_point->previous_sibling and $insert_point->previous_sibling->isa("PPI::Token::Whitespace") and not $insert_point->isa("PPI::Statement::Include") && $insert_point->version 300 10437 10737
Condition100%9/9
$insert_point->previous_sibling and $insert_point->previous_sibling->isa("PPI::Token::Whitespace") and not $insert_point->isa("PPI::Statement::Include") && $insert_point->version
!ll&&!rl&&r
10143294300
$insert_point->previous_sibling and $insert_point->previous_sibling->isa("PPI::Token::Whitespace")
!ll&&!rl&&r
9996147594
$insert_point->isa('PPI::Statement::Include') && $insert_point->version
!ll&&!rl&&r
24654294
MC/DC100%4/4
$insert_point->previous_sibling and $insert_point->previous_sibling->isa("PPI::Token::Whitespace") and not $insert_point->isa("PPI::Statement::Include") && $insert_point->version
$insert_point->previous_sibling $insert_point->previous_sibling->isa("PPI::Token::Whitespace") $insert_point->isa('PPI::Statement::Include') $insert_point->version
Truth table100%5/5
A and B and not(C && D)
A= $insert_point->previous_siblingB= $insert_point->previous_sibling->isa("PPI::Token::Whitespace")C= $insert_point->isa('PPI::Statement::Include')D= $insert_point->version
ABCDresult
0XXX0
10XX0
11110
110X1
11101
773 if $insert_point->previous_sibling
774 && $insert_point->previous_sibling->isa('PPI::Token::Whitespace')
775 && !($insert_point->isa('PPI::Statement::Include') && $insert_point->version );
776  
777 # record individual features being enabled/disabled
778 10737 for my $module (qw( feature experimental )) {
779 21474 for my $use_feature ( _find_include( $module => $doc, 'use' ) ) {
780 13233 my @old_args = _ppi_list_to_perl_list( $use_feature->arguments );
781 13233 _add_feature_to_scope( $use_feature, $_, ENABLED ) for @old_args;
782 13233 $feature_votes{+ENABLED}{$use_feature}{''} = \@old_args;
783 }
784 21474 for my $no_feature ( _find_include( $module => $doc, 'no' ) ) {
785 6846 my @old_args = _ppi_list_to_perl_list( $no_feature->arguments );
786 6846 _add_feature_to_scope( $no_feature, $_, DISABLED ) for @old_args;
787 6846 $feature_votes{+DISABLED}{$no_feature}{''} = \@old_args;
788 }
789 }
790  
791 # put the use VERSION LINE at the top of the file
792 10737 ▶ if ( $insert_point->significant ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($insert_point->significant) { } 10683 54 10737
793 10683 $insert_point->insert_before( $_->remove ) for $version_stmt->elements;
794 10683 ▶ $insert_point->insert_before( $indent->clone ) if $indent;
Branch: 1 branch
BranchTrueFalseTotal
if $indent 300 10383 10683
795 }
796 else {
797 54 $doc->add_element( $_->remove ) for $version_stmt->elements;
798 }
799  
800 # cleanup features enabled or disabled by the new version
801 10737 _cleanup_bundled_features( $self, $doc, $old_num );
802 }
803  
804 3009 ▶sub _try_compile_file {
Subroutine _try_compile_file: called CC=7 SCAR=19.9
805 3009 my ( $file, $env ) = @_;
806 3009 ▶ $env //= {};
Condition50%1/2
$env //= {}
l!l
03009
MC/DC0%0/1
$env //= {}
$env
Truth table50%1/2
A
A= $env
Aresult
11
00
807  
808 # redirect STDERR for quietness
809 3009 my $tmperr = Path::Tiny->tempfile;
810 3009 ▶ open( \*OLDERR, '>&', \*STDERR ) or die "Can't dup STDERR: $!";
Branch: 1 branch
BranchTrueFalseTotal
open \*OLDERR, ">&", \*STDERR or die "Can't dup STDERR: $!" 3009 0 3009
811 3009 ▶ open( \*STDERR, '>', $tmperr ) or die "Can't re-open STDERR: $!";
Branch: 1 branch
BranchTrueFalseTotal
open \*STDERR, ">", $tmperr or die "Can't re-open STDERR: $!" 3009 0 3009
812  
813 # setup a local environment
814 3009 local %ENV = %ENV;
815 3009 $ENV{$_} = $env->{$_} for keys %$env;
816  
817 # try to compile the file
818 3009 my $status = system $^X, '-c', $file;
819 3009 my $exit = $status >> 8;
820  
821 # get STDERR back, and warn about errors while compiling
822 3009 ▶ open( \*STDERR, '>&', \*OLDERR ) or die "Can't restore STDERR: $!";
Branch: 1 branch
BranchTrueFalseTotal
open \*STDERR, ">&", \*OLDERR or die "Can't restore STDERR: $!" 3009 0 3009
823 3009 ▶ warn $tmperr->slurp if $exit;
Branch: 1 branch
BranchTrueFalseTotal
if $exit 795 2214 3009
824  
825 3009 return !$exit; # 0 means success
826 }
827  
828 # PUBLIC METHOS
829  
830 12081 ▶sub bump_ppi {
Subroutine bump_ppi: called CC=7 SCAR=19.5
Pod documented
831 12081 my ( $self, $doc ) = @_;
832 12081 $doc = $doc->clone;
833 12081 ▶ my $source = $doc->filename // 'input code';
Condition100%2/2
$doc->filename // "input code"
l!l
45807501
MC/DC100%1/1
$doc->filename // "input code"
$doc->filename
Truth table100%2/2
A
A= $doc->filename
Aresult
11
00
834  
835 # found at least one version statement
836 12081 ▶ if ( my @version_stmts = _version_stmts($doc) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@version_stmts) = _version_stmts($doc)) { } 4266 7815 12081
837  
838 # bail out if there's more than one `use VERSION`
839 4266 ▶ if ( @version_stmts > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@version_stmts > 1) { } 0 4266 4266
840 0 carp "Found multiple use VERSION statements in $source:"
841 . join ', ', map $_->version, @version_stmts;
842 }
843  
844 # drop the existing version statement
845 # and add the new one at the top
846 else {
847 4266 my ($use_v) = _version_stmts($doc); # there's only one
848 4266 my $old_num = version::->parse( $use_v->version )->numify;
849  
850 # record the features enabled and disabled by the bundle
851 4266 my $feature_in_old_bundle = _feature_in_bundle($old_num);
852 _add_feature_to_scope( $use_v, $_, ENABLED )
853 4266 for keys %{ $feature_in_old_bundle->{enabled} };
854 _add_feature_to_scope( $use_v, $_, DISABLED )
855 4266 for keys %{ $feature_in_old_bundle->{disabled} };
856  
857 4266 ▶ if ( $old_num <= $self->version_num ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($old_num <= $self->version_num) 2976 1290 4266
858 2976 _insert_version_stmt( $self, $doc, $old_num );
859 2976 _drop_statement( $use_v, !!1 );
860 }
861 }
862 }
863  
864 # no version statement found, add one
865 7815 else { _insert_version_stmt( $self, $doc ); }
866  
867 12081 return $doc;
868 }
869  
870 6948 ▶sub bump {
Subroutine bump: called CC=3 SCAR=11.0
Pod documented
871 6948 my ( $self, $code, $filename ) = @_;
872 6948 my $doc = PPI::Document->new( \$code, filename => $filename );
873 6948 ▶ $filename //= 'input code';
Condition100%2/2
$filename //= "input code"
l!l
34743474
MC/DC100%1/1
$filename //= "input code"
$filename
Truth table100%2/2
A
A= $filename
Aresult
11
00
874 6948 ▶ croak "Parsing of $filename failed" unless defined $doc;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $doc 0 6948 6948
875 6948 return $self->bump_ppi($doc)->serialize;
876 }
877  
878 3474 ▶sub bump_file {
Subroutine bump_file: called CC=2 SCAR=6.9
Pod documented
879 3474 my ( $self, $file ) = @_;
880 3474 $file = Path::Tiny->new($file); # in case it's not a Path::Tiny yet
881 3474 my $code = $file->slurp;
882 3474 my $bumped = $self->bump( $code, $file );
883 3474 ▶ if ( $bumped ne $code ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bumped ne $code) 3007 467 3474
884 3007 $file->append( { truncate => 1 }, $bumped );
885 3007 return !!1;
886 }
887 467 return !!0;
888 }
889  
890 # this one is private and returns an array ref with two values:
891 # the new PPI::Document, and the version it was actually bumped to
892 1350 ▶sub _bump_ppi_safely {
Subroutine _bump_ppi_safely: called CC=11 SCAR=24.1
893 1350 my ( $self, $doc, $options ) = @_;
894 1350 my $version_limit = $options->{version_limit};
895 1350 ▶ $version_limit &&= stable_version($version_limit);
Condition33%1/3
$version_limit &&= stable_version($version_limit)
!ll&&!rl&&r
135000
MC/DC0%0/2
$version_limit &&= stable_version($version_limit)
$version_limit stable_version($version_limit)
Truth table33%1/3
A &&= B
A= $version_limitB= stable_version($version_limit)
ABresult
0X0
100
111
896 1350 ▶ $version_limit //= do {
Condition33%1/3
$version_limit //= do { my(@versions) = map(eval { do { version_fmt($_->version) } }, _version_stmts($doc)); $versions[0] // "5.01" }
l!l&&r!l&&!r
013500
MC/DC0%0/2
$version_limit //= do { my(@versions) = map(eval { do { version_fmt($_->version) } }, _version_stmts($doc)); $versions[0] // "5.01" }
$version_limit do { my(@versions) = map(eval { do { version_fmt($_->version) } }, _version_stmts($doc)); $versions[0] // "5.01" }
Truth table33%1/3
A //= B
A= $version_limitB= do { my(@versions) = map(eval { do { version_fmt($_->version) } }, _version_stmts($doc)); $versions[0] // "5.01" }
ABresult
1X1
011
000
897 1350 my @versions = map eval { version_fmt( $_->version ) },
898 _version_stmts($doc);
899 1350 ▶ $versions[0] // 5.010;
Condition100%2/2
$versions[0] // "5.01"
l!l
2161134
MC/DC100%1/1
$versions[0] // "5.01"
$versions[0]
Truth table100%2/2
A
A= $versions[0]
Aresult
11
00
900 };
901  
902 # try compiling the file: if it fails, our safeguard won't work
903 1350 ▶ my $source = $doc->filename // 'input code';
Condition100%2/2
$doc->filename // "input code"
l!l
900450
MC/DC100%1/1
$doc->filename // "input code"
$doc->filename
Truth table100%2/2
A
A= $doc->filename
Aresult
11
00
904 1350 my $tmp = Path::Tiny->tempfile;
905 1350 $tmp->spew( $doc->serialize );
906 1350 ▶ unless ( _try_compile_file( $tmp, $options->{env} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_try_compile_file($tmp, $options->{"env"})) 216 1134 1350
907 216 warn "Can't bump Perl version safely for $source: it does not compile\n";
908 216 return [ $doc->clone, undef ]; # undef means "didn't compile"
909 }
910  
911 # try bumping down version until it compiles
912 1134 my $bumped_doc;
913 1134 my $version = $self->version_num;
914 1134 ▶ while ( $version >= $version_limit or $version = !!0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if () 1659 54 1713
Condition100%2/2
$version >= $version_limit or
l!l
165954
MC/DC100%1/1
$version >= $version_limit or
$version >= $version_limit
Truth table100%2/2
A
A= $version >= $version_limit
Aresult
11
00
915 1659 ▶ my $perv = $self->version_num eq $version
Branch: 1 branch
BranchTrueFalseTotal
$self->version_num eq $version ? : 1080 579 1659
916 ? $self # no need to create a new object
917 : Perl::Version::Bumper->new( version => $version );
918 1659 $bumped_doc = $perv->bump_ppi($doc);
919  
920 # try to compile the file
921 1659 $tmp = Path::Tiny->tempfile;
922 1659 $tmp->spew( $bumped_doc->serialize );
923 1659 ▶ last if _try_compile_file( $tmp, $options->{env} );
Branch: 1 branch
BranchTrueFalseTotal
if _try_compile_file($tmp, $options->{"env"}) 1080 579 1659
924  
925 # bump version down and repeat
926 579 $version = stable_version_dec($version);
927 }
928  
929 1134 ▶ return $version ? [ $bumped_doc, $version ] : [ $doc->clone, $version ];
Branch: 1 branch
BranchTrueFalseTotal
$version ? : 1080 54 1134
930 }
931  
932 450 ▶sub bump_ppi_safely {
Subroutine bump_ppi_safely: called CC=1 SCAR=0.0
Pod documented
933 450 my ( $self, $doc, $options ) = @_;
934 450 return $self->_bump_ppi_safely( $doc, $options )->[0];
935 }
936  
937 450 ▶sub bump_safely {
Subroutine bump_safely: called CC=3 SCAR=11.3
Pod documented
938 450 my ( $self, $code, $options ) = @_;
939 450 ▶ my $filename = $options->{filename} // 'input code';
Condition50%1/2
$options->{"filename"} // "input code"
l!l
0450
MC/DC0%0/1
$options->{"filename"} // "input code"
$options->{"filename"}
Truth table50%1/2
A
A= $options->{"filename"}
Aresult
11
00
940 450 my $doc = PPI::Document->new( \$code, filename => $filename );
941 450 ▶ croak "Parsing of $filename failed" unless defined $doc;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $doc 0 450 450
942 450 return $self->_bump_ppi_safely( $doc, $options )->[0]->serialize;
943 }
944  
945 450 ▶sub bump_file_safely {
Subroutine bump_file_safely: called CC=3 SCAR=11.0
Pod documented
946 450 my ( $self, $file, $options ) = @_;
947 450 my $doc = PPI::Document->new("$file"); # stringify any object
948 450 ▶ croak "Parsing of $file failed" unless defined $doc;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $doc 0 450 450
949 my ( $bumped_doc, $version ) =
950 450 @{ $self->_bump_ppi_safely( $doc, $options ) };
951 450 ▶ Path::Tiny->new($file)->append( { truncate => 1 }, $bumped_doc->serialize )
Branch: 1 branch
BranchTrueFalseTotal
if $version 360 90 450
952 if $version;
953 450 return $version;
954 }
955  
956 5 1;
957  
958 =pod
959  
960 =head1 NAME
961  
962 Perl::Version::Bumper - Update C<use VERSION> on any Perl code
963  
964 =head1 SYNOPSIS
965  
966 use Perl::Version::Bumper;
967  
968 my $perv = Perl::Version::Bumper->new( version => 'v5.36' );
969  
970 # bump a PPI::Document
971 my $bumped_ppi = $perv->bump_ppi($ppi_doc);
972  
973 # bump source code
974 my $bumped_code = $perv->bump($code);
975  
976 # bump the source of a file
977 my $success = $perv->bump_file($filename);
978  
979 # safe versions (check the result compiles)
980 my $bumped_ppi = $perv->bump_ppi_safely($ppi_doc);
981 my $bumped_code = $perv->bump_safely($code);
982 my $success = $perv->bump_file_safely( $filename, $version_limit );
983  
984 =head1 DESCRIPTION
985  
986 C<Perl::Version::Bumper> can update Perl code to make it declare it uses
987 a more recent version of the Perl language by way of C<use VERSION>.
988  
989 It takes care of removing unnecessary loading of L<feature> and
990 L<experimental> L<warnings>, and adds the C<use VERSION> line at the
991 top of the file (thus encouraging "line 1 semantics").
992  
993 It also manages the removal of "compatibility" modules when the feature
994 they provide a compatibility layer with is fully supported in the target
995 Perl version.
996  
997 If the code already declares a Perl version, it can only be bumped
998 to a higher version.
999  
1000 For more information about why you would want to use this module
1001 (or the associated program L<perl-version-bump>), please check
1002 L<Perl::Version::Bumper::Rationale>.
1003  
1004 The module L<exports|/EXPORTS> a few helper functions. These are mostly used
1005 by support tools for this distribution, and are not meant for general use.
1006  
1007 =head1 CONSTRUCTOR
1008  
1009 =head2 new
1010  
1011 my $perv = Perl::Version::Bumper->new( %attributes );
1012 my $perv = Perl::Version::Bumper->new( \%attributes );
1013  
1014 Return a new C<Perl::Version::Bumper> object.
1015  
1016 =head1 ATTRIBUTES
1017  
1018 =head2 version
1019  
1020 The target version to bump to.
1021  
1022 Defaults to the stable version less than or equal to the version of the
1023 currenly running C<perl>.
1024  
1025 The constructor accepts both forms of Perl versions, regular
1026 (e.g. C<v5.36>) and floating-point (e.g. C<5.036>), and will
1027 turn them into a string suitable for C<use VERSION>.
1028  
1029 To protect against simple mistakes (e.g. passing C<5.36> instead of
1030 C<v5.36>), the constructor does some sanity checking, and checks that
1031 the given version:
1032  
1033 =over 4
1034  
1035 =item *
1036  
1037 is parsable as a Perl version number,
1038  
1039 =item *
1040  
1041 is greater than or equal to C<v5.10>,
1042  
1043 =item *
1044  
1045 is lower than the version of the Perl currently running,
1046  
1047 =item *
1048  
1049 is a stable Perl version.
1050  
1051 =back
1052  
1053 In case any of the above checks fail, the constructor will die.
1054  
1055 The constructor will also silently drop any sub-version information
1056 (so C<v5.36.2> will be turned into C<v5.36>).
1057  
1058 =head1 CLASS METHODS
1059  
1060 =head2 feature_version
1061  
1062 Return the version (in numeric format) of the feature set recognized
1063 by this module. It is not possible to bump code over that version.
1064  
1065 The current value of C<feature_version> is: C<5.044>.
1066  
1067 =head2 feature_data
1068  
1069 Return a I<copy> of the internal data structure containing all the
1070 information about features. That should only be needed for testing
1071 and debugging.
1072  
1073 =head1 METHODS
1074  
1075 =head2 version_num
1076  
1077 Return the L</version> attribute as a number.
1078  
1079 =head2 bump_ppi
1080  
1081 my $bumped_ppi_doc = $perv->bump_ppi($ppi_doc);
1082  
1083 Take a L<PPI::Document> as input, and return a I<new> L<PPI::Document>
1084 with its declared version bumped to L</version>.
1085  
1086 =head2 bump
1087  
1088 my $bumped_code = $perv->bump($code);
1089  
1090 Take a string containing Perl code as input, bump the declared Perl
1091 version in the source code to L</version>, and return the new source
1092 code as a string.
1093  
1094 =head2 bump_file
1095  
1096 $perv->bump_file($filename);
1097  
1098 Bump the code of the file argument in-place.
1099  
1100 Return a boolean indicating if the file content was modified or not.
1101  
1102 =head1 SAFE METHODS
1103  
1104 The L</bump_ppi>, L</bump> and L</bump_file> methods previously described
1105 modify the source code they're given, but give I<no garanties> that the
1106 updated code will even compile.
1107  
1108 To address this issue, L</bump_ppi_safely>, L</bump_safely> and
1109 L</bump_file_safely> methods work as the regular methods, but will only
1110 produce code that actually compiles.
1111  
1112 If all attempts fail, the return value is identical to the input value.
1113  
1114 =head2 Example of a safe bump
1115  
1116 The following code uses L<multidimensional array emulation|perlvar/$;>:
1117  
1118 my %h; $h{ 1, 2 } = 3; # same as $foo{"1\x{1c}2"} = 3;
1119  
1120 L</bump> will produce the following when trying to update it to C<v5.40>:
1121  
1122 use v5.40;
1123 my %h; $h{ 1, 2 } = 3; # same as $foo{"1\x{1c}2"} = 3;
1124  
1125 Which fails to compile with the following error:
1126  
1127 Multidimensional hash lookup is disabled
1128  
1129 It's not possible to just bump this code up to C<v5.40> and expect it to
1130 work, because it uses multidimensional array emulation, and the feature
1131 that represents this (C<multidimensional>) was disabled in C<v5.36>.
1132 This code will in fact fail to compile with all version bundles greater
1133 or equal to C<v5.36>.
1134  
1135 A I<safe way> to try to bump this code to C<v5.40> is to try with
1136 C<v5.40>, detect it fails to compile, try again with C<v5.38> and
1137 C<v5.36>, which also fail, until we hit C<v5.34> which compiles just
1138 fine (because the C<multidimensional> feature is still enabled in that
1139 bundle). Leaving us with the following code:
1140  
1141 use v5.34;
1142 my %h; $h{ 1, 2 } = 3; # same as $foo{"1\x{1c}2"} = 3;
1143  
1144 The code needs to be updated to I<not> use multidimensional array emulation
1145 before it can I<safely> be bumped past version C<v5.34>.
1146  
1147 =head2 Process of a safe bump
1148  
1149 The process for a safe bump is to take some input, and try to compile it.
1150 If the compilation fails, return immediately.
1151  
1152 Otherwise, continue with the process: bump the content, and try to
1153 compile the result. Return as soon as compilation succeeds.
1154  
1155 If compilation fails, decrease the target Perl version number, bump
1156 the content to that version, and try to compile the result again. Keep
1157 decreasing the target version, all the way back to the currently
1158 declared version in the document, or L<version_limit>, whichever is more
1159 recent. Give up after the last compilation failure.
1160  
1161 =head2 Options for a safe bump
1162  
1163 All the methods below take one input argument (a L<PPI::Document>,
1164 a string of code or a filename) and one optional hash reference
1165 for options.
1166  
1167 The possible options are:
1168  
1169 =over 4
1170  
1171 =item version_limit
1172  
1173 The version at which to stop decreasing the target version.
1174 Defaults to C<v5.10>.
1175  
1176 =item env
1177  
1178 A hash reference of key/value pairs for environment variables
1179 to be set when trying to compile the bumped code.
1180  
1181 =back
1182  
1183 =head2 bump_ppi_safely
1184  
1185 my $bumped_ppi = $perv->bump_ppi_safely( $ppi_doc, \%options );
1186  
1187 Safely bump the source code in the given L<PPI::Document>.
1188  
1189 The return value is a new L<PPI::Document> containing the result of the
1190 "safe bump" (its content might be the same as the original if there's
1191 no safe way to bump the code).
1192  
1193 =head2 bump_safely
1194  
1195 my $bumped_code = $perv->bump_safely( $code, \%options );
1196 my ( $bumped_code, $new_version ) = $perv->bump_safely($code);
1197  
1198 Safely bump the source code given as a string.
1199  
1200 The return value is a string containing the new source code.
1201  
1202 =head2 bump_file_safely
1203  
1204 $perv->bump_file_safely( $filename, \%options );
1205  
1206 Safely bump the code in the file argument in-place. The file will
1207 not be modified if the code can't be bumped safely.
1208  
1209 The return value is C<undef> if the original didn't compile, false
1210 if all attempts to bump the file failed, and the actual (numerical)
1211 version number the file was bumped to in case of success.
1212  
1213 =head1 VERSION UPGRADE ALGORITHM
1214  
1215 For a given version number, a feature has three attributes:
1216  
1217 =over 4
1218  
1219 =item known
1220  
1221 the B<perl> I<binary> knows about the feature starting from that version.
1222  
1223 If it's not known, passing it to C<use feature> will I<die> during
1224 compilation with C<Feature "XXX" is not supported by Perl 5.x.y> (where
1225 5.x.y is the version of the binary C<perl> program).
1226  
1227 =item enabled
1228  
1229 the feature is enabled starting with the corresponding I<feature> bundle
1230 (i.e. C<use VERSION> will implicitely enable it).
1231  
1232 =item disabled
1233  
1234 the feature is disabled starting from the corresponding I<feature> bundle
1235 (i.e. C<use VERSION> will implicitely disable it).
1236  
1237 This is the case for so-called "unfeatures", i.e. constructs that were
1238 deemed undesirable and removed from the language (e.g. C<indirect>,
1239 C<bareword_filehandles>, etc.).
1240  
1241 =item removed
1242  
1243 the feature was removed starting from the given version.
1244  
1245 The only feature that was removed so far is C<array_base> (in Perl v5.30).
1246  
1247 =back
1248  
1249 If there is more than one C<use VERSION> line in the file, the algorithm
1250 will bail out. Otherwise, the previous C<use VERSION> line will be
1251 removed, and a new one added at the top of the file (line 1).
1252  
1253 The features that were enabled via C<use feature> and are part of the
1254 C<VERSION> feature bundle will be removed from the corresponding C<use
1255 feature> or C<use experimental> lines. The disabling of the corresponding
1256 C<experimental> warnings will be removed.
1257  
1258 "Unfeatures" are treated differently. Unfeatures are features that were
1259 created to represent historical Perl behaviour, and are considered enabled
1260 by default in all bundles until they are disabled at a later stage. If an
1261 unfeature is enabled, it is considered to be for documentation purposes
1262 (to indicate that the undesirable historical feature was used), and
1263 therefore not removed, even if the specified C<VERSION> enables it.
1264  
1265 The (un)features that were disabled via C<no feature> and are disabled
1266 as part of the C<VERSION> feature bundle will be removed from the
1267 corresponding C<use feature> or C<use experimental> lines.
1268  
1269 If compatibility modules (CPAN modules that provide support for the
1270 feature in older Perls) were loaded, they will removed if the feature
1271 is enabled in the feature bundle for C<VERSION>, or replaced by the
1272 corresponding C<use feature> if the feature is known by the corresponding
1273 C<perl> binary but not yet enabled by the feature bundle. (In the context
1274 of compatibility modules for unfeatures, the same consideration for
1275 documentation purposes apply.)
1276  
1277 When a feature is enabled (or disabled) in the context of a feature
1278 version bundle that's less than the version when the feature was known
1279 by Perl, the line won't be removed.
1280  
1281 For example this line:
1282  
1283 use feature 'signatures';
1284  
1285 will die with any perl before perl5.20.0, because the binary does not
1286 know about the feature itself.
1287  
1288 When writing code like this:
1289  
1290 use v5.10;
1291 use feature 'signatures';
1292  
1293 one is opting into a version of the Perl language that is not described
1294 by any specific feature bundle. However, any perl that knows about the
1295 C<signatures> feature will know how to run it.
1296  
1297 Bumping it to the feature bundle for v5.16, for example, is valid,
1298 and will work with any B<perl> that knows about the C<signatures> feature:
1299  
1300 use v5.16;
1301 use feature 'signatures';
1302  
1303 And so on until v5.36, when the C<signatures> feature was enabled by
1304 the corresponding version bundle:
1305  
1306 use v5.36;
1307  
1308 Finally, some features may imply extra edits:
1309  
1310 =over 4
1311  
1312 =item bitwise
1313  
1314 When the C<bitwise> feature is enabled, the behaviour of the bitwise
1315 operators (C<&>, C<|>, C<~> and C<^>) is modified. If the code makes use
1316 of one of them, and the code is moved from a version I<before> v5.28
1317 to a version greater or equal to v5.28, the C<bitwise> feature will
1318 be I<disabled>, and a comment will be added, asking the maintainer to
1319 review their use according to the C<bitwise> feature before removing it.
1320  
1321 =item signatures
1322  
1323 When signatures are implicitely enabled, any prototypes will be rewritten
1324 with the prototype attribute syntax. For example:
1325  
1326 sub foo ($@) { ... }
1327  
1328 will become:
1329  
1330 sub foo :prototype($@) { ... }
1331  
1332 =item fc
1333  
1334 Once C<fc> is implicitely enabled, All uses of C<CORE::fc> will be
1335 replaced by a bare C<fc>.
1336  
1337 =item apostrophe_as_package_separator
1338  
1339 When the use of apostrophe (C<'>) as package separator is implicitely
1340 disabled, every C<'> used as such will be replaced by C<::>.
1341  
1342 =back
1343  
1344 =head2 Feature/version data table
1345  
1346 The following table is used to generate the feature data hash.
1347  
1348 It is generated using the C<bin/build_feature_data.pl> script
1349 shipped with the distribution.
1350  
1351 The keys are:
1352  
1353 =over 4
1354  
1355 =item known
1356  
1357 when perl first learnt about the feature
1358  
1359 =item enabled
1360  
1361 when the feature was first enabled (may be before it was known)
1362  
1363 =item disabled
1364  
1365 when the feature was first disabled
1366  
1367 =item compat
1368  
1369 replacement modules for features to be deprecated / added
1370  
1371 =back
1372  
1373 Different features have different lifecycles:
1374  
1375 =over 4
1376  
1377 =item *
1378  
1379 New features (i.e. additional behaviour that didn't exist in Perl v5.8):
1380  
1381 =over 4
1382  
1383 =item *
1384  
1385 are C<known> in the Perl release that introduced them
1386  
1387 =item *
1388  
1389 are C<enabled> either in the same version (e.g. C<say>, C<state>)
1390 or after an "experimental" phase (e.g. C<signatures>, C<bitwise>)
1391  
1392 =item *
1393  
1394 once enabled, they are not meant to be C<disabled> in a later bundle.
1395  
1396 =back
1397  
1398 =item *
1399  
1400 Unfeatures, or backwards compatibility features (features that existed
1401 in older Perls, but were later deemed undesirable, and scheduled for
1402 being eventually disabled or removed):
1403  
1404 =over 4
1405  
1406 =item *
1407  
1408 are C<enabled> in the C<:default> bundle (they were part of the old
1409 Perl 5 behaviour) before they are even C<known> (a feature that
1410 represents them was added to Perl).
1411  
1412 =item *
1413  
1414 are meant to be manually disabled (with C<no feature>), until a
1415 later feature bundle eventually disables them by default.
1416  
1417 =back
1418  
1419 =back
1420  
1421 "compat" modules are CPAN modules meant to add support to the feature on
1422 perls where it's not available yet. They exist both for new features and
1423 backwards compatibility features. The number following the module name in
1424 the data structure below is the sum of 1 (if the module has an C<import>
1425 method) and -1 (if the module has an C<unimport> method).
1426  
1427 =cut
1428  
1429 5 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
1430 5 $FEATURE_DATA = << '=cut';
1431  
1432 =pod
1433  
1434 5.044 features known enabled disabled removed compat
1435 say 5.010 5.010 Perl6::Say 1 Say::Compat 1
1436 state 5.010 5.010
1437 switch 5.010 5.010 5.036
1438 unicode_strings 5.012 5.012
1439 array_base 5.016 5.010 5.016 5.030
1440 current_sub 5.016 5.016
1441 evalbytes 5.016 5.016
1442 fc 5.016 5.016
1443 unicode_eval 5.016 5.016
1444 lexical_subs 5.018 5.026
1445 postderef 5.020 5.024
1446 postderef_qq 5.020 5.024
1447 signatures 5.020 5.036
1448 bitwise 5.022 5.028
1449 refaliasing 5.022
1450 declared_refs 5.026
1451 indirect 5.032 5.010 5.036 indirect 0
1452 isa 5.032 5.036
1453 multidimensional 5.034 5.010 5.036 multidimensional 0
1454 bareword_filehandles 5.034 5.010 5.038 bareword::filehandles 0
1455 try 5.034 5.040 Feature::Compat::Try 1 Syntax::Feature::Try 0 Syntax::Keyword::Try 0
1456 defer 5.036 Feature::Compat::Defer 1 Syntax::Keyword::Defer 0
1457 extra_paired_delimiters 5.036
1458 module_true 5.038 5.038
1459 class 5.038 Feature::Compat::Class 1
1460 apostrophe_as_package_separator 5.042 5.010 5.042
1461 smartmatch 5.042 5.010 5.042
1462 keyword_all 5.042
1463 keyword_any 5.042
1464 enhanced_xx 5.044
1465  
1466 =cut
1467  
1468 }
1469  
1470 =head1 ADDITIONAL INFORMATION ABOUT PERL FEATURES AND CONSTRUCTS
1471  
1472 =head2 Official documentation
1473  
1474 =over 4
1475  
1476 =item L<feature>
1477  
1478 Perl pragma to enable new features.
1479  
1480 =item L<perlexperiment>
1481  
1482 A listing of experimental features in Perl.
1483  
1484 =item L<experimental>
1485  
1486 This pragma provides an easy and convenient way to enable or disable
1487 experimental features.
1488  
1489 =back
1490  
1491 =head2 CPAN Modules
1492  
1493 =over 4
1494  
1495 =item L<Syntax::Construct>
1496  
1497 For some new syntactic constructs, there is the L<feature pragma>.
1498 For the rest, there is L<Syntax::Construct>.::
1499  
1500 =item L<Perl::MinimumVersion>
1501  
1502 Find a minimum required version of C<perl> for Perl code.
1503  
1504 =item L<Perl::MinimumVersion::Fast>
1505  
1506 L<Perl::MinimumVersion::Fast> is an alternative fast & lightweight
1507 implementation of L<Perl::MinimumVersion>.
1508  
1509 =back
1510  
1511 =head2 Other
1512  
1513 =over 4
1514  
1515 =item L<https://sheet.shiar.nl/perl>
1516  
1517 The most significant features introduced for recent versions of the Perl
1518 scripting language.
1519  
1520 =back
1521  
1522 =head1 ACKNOWLEDGMENT
1523  
1524 This software was originally developed at Booking.com. With approval
1525 from Booking.com, this software was released as open source, for which
1526 the authors would like to express their gratitude.
1527  
1528 =head1 AUTHOR
1529  
1530 Philippe Bruhat (BooK) <book@cpan.org>
1531  
1532 =head1 COPYRIGHT
1533  
1534 Copyright 2024-2026 Philippe Bruhat (BooK), all rights reserved.
1535  
1536 =head1 LICENSE
1537  
1538 This program is free software; you can redistribute it and/or modify it
1539 under the same terms as Perl itself.
1540  
1541 =cut
↑ Summary Bumper/Helper/Version.pm »