@@ -68,7 +68,7 @@ BEGIN {
68
68
%CHECKS = (
69
69
_heredoc_indent => version-> new(' 5.025.007' ),
70
70
71
- # _stacked_labels => version->new('5.014'),
71
+ # _stacked_labels => version->new('5.014'),
72
72
73
73
_yada_yada_yada => version-> new(' 5.012' ),
74
74
_pkg_name_version => version-> new(' 5.012' ),
@@ -97,8 +97,8 @@ BEGIN {
97
97
_pragma_utf8 => version-> new(' 5.008' ),
98
98
);
99
99
@CHECKS_RV = ( # subs that return version
100
- ' _feature_bundle' ,' _regex' ,' _each_argument' ,' _binmode_2_arg' ,
101
- ' _scheduled_blocks' , ' _experimental_bundle'
100
+ ' _feature_bundle' ,' _regex' ,' _each_argument' ,' _binmode_2_arg' ,
101
+ ' _scheduled_blocks' , ' _experimental_bundle'
102
102
);
103
103
104
104
# Predefine some indexes needed by various check methods
@@ -418,12 +418,12 @@ sub _minimum_syntax_version {
418
418
version => $v ,
419
419
element => _INSTANCE($obj , ' PPI::Element' ),
420
420
);
421
- if ($self -> {_collect_all_reasons }) {
421
+ if ($self -> {_collect_all_reasons }) {
422
422
push @{ $self -> {_all_reasons } }, $current_reason ;
423
423
} else {
424
424
$filter = $v ;
425
425
}
426
- }
426
+ }
427
427
}
428
428
429
429
@@ -433,7 +433,7 @@ sub _minimum_syntax_version {
433
433
my @rules = sort {
434
434
$CHECKS {$b } <=> $CHECKS {$a }
435
435
} grep {
436
- not (exists $checks2skip {$_ }) and $CHECKS {$_ } > $filter
436
+ not (exists $checks2skip {$_ }) and $CHECKS {$_ } > $filter
437
437
} keys %CHECKS ;
438
438
439
439
foreach my $rule ( @rules ) {
@@ -540,41 +540,41 @@ sub version_markers {
540
540
541
541
my %feature =
542
542
(
543
- ' say' => ' 5.10' ,
544
- ' smartmatch' => ' 5.10' ,
545
- ' state' => ' 5.10' ,
546
- ' switch' => ' 5.10' ,
547
- ' unicode_strings' => ' 5.14' ,
548
- ' unicode_eval' => ' 5.16' ,
549
- ' evalbytes' => ' 5.16' ,
550
- ' current_sub' => ' 5.16' ,
551
- ' array_base' => ' 5.16' , # defined only in 5.16
552
- ' fc' => ' 5.16' ,
553
- ' lexical_subs' => ' 5.18' ,
554
- ' postderef' => ' 5.20' ,
555
- ' postderef_qq' => ' 5.20' ,
556
- ' signatures' => ' 5.20' ,
557
- ' refaliasing' => ' 5.22' ,
558
- ' bitwise' => ' 5.22' ,
559
- ' declared_refs' => ' 5.26' ,
560
- ' isa' => ' 5.32' ,
561
- ' indirect' => ' 5.32' , # defined only in 5.32
543
+ ' say' => ' 5.10' ,
544
+ ' smartmatch' => ' 5.10' ,
545
+ ' state' => ' 5.10' ,
546
+ ' switch' => ' 5.10' ,
547
+ ' unicode_strings' => ' 5.14' ,
548
+ ' unicode_eval' => ' 5.16' ,
549
+ ' evalbytes' => ' 5.16' ,
550
+ ' current_sub' => ' 5.16' ,
551
+ ' array_base' => ' 5.16' , # defined only in 5.16
552
+ ' fc' => ' 5.16' ,
553
+ ' lexical_subs' => ' 5.18' ,
554
+ ' postderef' => ' 5.20' ,
555
+ ' postderef_qq' => ' 5.20' ,
556
+ ' signatures' => ' 5.20' ,
557
+ ' refaliasing' => ' 5.22' ,
558
+ ' bitwise' => ' 5.22' ,
559
+ ' declared_refs' => ' 5.26' ,
560
+ ' isa' => ' 5.32' ,
561
+ ' indirect' => ' 5.32' , # defined only in 5.32
562
562
);
563
563
my $feature_regexp = join (' |' , keys %feature );
564
564
565
565
# :5.14 means same as :5.12, but :5.14 is not defined in feature.pm in perl 5.12.
566
566
sub _feature_bundle {
567
- my @versions ;
568
- my ($version , $obj );
567
+ my @versions ;
568
+ my ($version , $obj );
569
569
shift -> Document-> find( sub {
570
570
$_ [1]-> isa(' PPI::Statement::Include' ) or return ' ' ;
571
571
$_ [1]-> pragma eq ' feature' or return ' ' ;
572
572
my @child = $_ [1]-> schildren;
573
573
my @args = @child [1..$#child ]; # skip 'use', 'feature' and ';'
574
574
foreach my $arg (@args ) {
575
- my $v = 0;
576
- $v = $1 if ($arg -> content =~ / :(5\.\d +)(?:\.\d +)?/ );
577
- $v = max($v , $feature {$1 }) if ($arg -> content =~ / \b ($feature_regexp )\b / );
575
+ my $v = 0;
576
+ $v = $1 if ($arg -> content =~ / :(5\.\d +)(?:\.\d +)?/ );
577
+ $v = max($v , $feature {$1 }) if ($arg -> content =~ / \b ($feature_regexp )\b / );
578
578
#
579
579
if ($v and $v > ($version || 0) ) {
580
580
$version = $v ;
@@ -589,78 +589,78 @@ sub _feature_bundle {
589
589
# list copied from experimental.pm v0.021 itself
590
590
my %experimental =
591
591
(
592
- array_base => ' 5' ,
593
- autoderef => ' 5.14' ,
594
- bitwise => ' 5.22' ,
595
- const_attr => ' 5.22' ,
596
- current_sub => ' 5.16' ,
597
- declared_refs => ' 5.26' ,
598
- evalbytes => ' 5.16' ,
599
- fc => ' 5.16' ,
600
- isa => ' 5.32' ,
601
- lexical_topic => ' 5.10' ,
602
- lexical_subs => ' 5.18' ,
603
- postderef => ' 5.20' ,
604
- postderef_qq => ' 5.20' ,
605
- refaliasing => ' 5.22' ,
606
- regex_sets => ' 5.18' ,
607
- say => ' 5.10' ,
608
- smartmatch => ' 5.10' ,
609
- signatures => ' 5.20' ,
610
- state => ' 5.10' ,
611
- switch => ' 5.10' ,
612
- unicode_eval => ' 5.16' ,
613
- unicode_strings => ' 5.12' ,
592
+ array_base => ' 5' ,
593
+ autoderef => ' 5.14' ,
594
+ bitwise => ' 5.22' ,
595
+ const_attr => ' 5.22' ,
596
+ current_sub => ' 5.16' ,
597
+ declared_refs => ' 5.26' ,
598
+ evalbytes => ' 5.16' ,
599
+ fc => ' 5.16' ,
600
+ isa => ' 5.32' ,
601
+ lexical_topic => ' 5.10' ,
602
+ lexical_subs => ' 5.18' ,
603
+ postderef => ' 5.20' ,
604
+ postderef_qq => ' 5.20' ,
605
+ refaliasing => ' 5.22' ,
606
+ regex_sets => ' 5.18' ,
607
+ say => ' 5.10' ,
608
+ smartmatch => ' 5.10' ,
609
+ signatures => ' 5.20' ,
610
+ state => ' 5.10' ,
611
+ switch => ' 5.10' ,
612
+ unicode_eval => ' 5.16' ,
613
+ unicode_strings => ' 5.12' ,
614
614
);
615
615
my $experimental_regexp = join (' |' , keys %experimental );
616
616
sub _experimental_bundle {
617
- my ($version , $obj );
618
-
619
- shift -> Document-> find( sub {
620
- return ' ' unless $_ [1]-> isa(' PPI::Statement::Include' )
621
- and $_ [1]-> pragma eq ' experimental' ;
622
-
623
- my @child = $_ [1]-> schildren;
624
- my @args = @child [1..$#child ]; # skip 'use', 'experimental' and ';'
625
- foreach my $arg (@args ) {
626
- my $v = 0;
627
- $v = $1 if ($arg -> content =~ / :(5\.\d +)(?:\.\d +)?/ );
628
- $v = max($v , $experimental {$1 }) if ($arg -> content =~ / \b ($experimental_regexp )\b / );
629
-
630
- if ($v and $v > ($version || 0) ) {
631
- $version = $v ;
632
- $obj = $_ [1];
633
- }
634
- }
635
- return ' ' ;
636
- } );
637
-
638
- return (defined ($version )?" $version .0" :undef , $obj );
617
+ my ($version , $obj );
618
+
619
+ shift -> Document-> find( sub {
620
+ return ' ' unless $_ [1]-> isa(' PPI::Statement::Include' )
621
+ and $_ [1]-> pragma eq ' experimental' ;
622
+
623
+ my @child = $_ [1]-> schildren;
624
+ my @args = @child [1..$#child ]; # skip 'use', 'experimental' and ';'
625
+ foreach my $arg (@args ) {
626
+ my $v = 0;
627
+ $v = $1 if ($arg -> content =~ / :(5\.\d +)(?:\.\d +)?/ );
628
+ $v = max($v , $experimental {$1 }) if ($arg -> content =~ / \b ($experimental_regexp )\b / );
629
+
630
+ if ($v and $v > ($version || 0) ) {
631
+ $version = $v ;
632
+ $obj = $_ [1];
633
+ }
634
+ }
635
+ return ' ' ;
636
+ } );
637
+
638
+ return (defined ($version )?" $version .0" :undef , $obj );
639
639
}
640
640
641
641
my %SCHEDULED_BLOCK =
642
642
(
643
- ' INIT' => ' 5.006' ,
644
- ' CHECK' => ' 5.006002' ,
645
- ' UNITCHECK' => ' 5.010' ,
643
+ ' INIT' => ' 5.006' ,
644
+ ' CHECK' => ' 5.006002' ,
645
+ ' UNITCHECK' => ' 5.010' ,
646
646
);
647
647
648
648
sub _scheduled_blocks
649
649
{
650
- my @versions ;
651
- my ($version , $obj );
650
+ my @versions ;
651
+ my ($version , $obj );
652
652
653
653
shift -> Document-> find( sub {
654
654
$_ [1]-> isa(' PPI::Statement::Scheduled' ) or return ' ' ;
655
- ($_ [1]-> children)[0]-> isa(' PPI::Token::Word' ) or return ' ' ;
656
- my $function = (($_ [1]-> children)[0])-> content;
657
- exists ( $SCHEDULED_BLOCK { $function }) or return ' ' ;
658
-
659
- my $v = $SCHEDULED_BLOCK { ($_ [1]-> children)[0]-> content };
660
- if ($v and $v > ($version || 0) ) {
661
- $version = $v ;
662
- $obj = $_ [1];
663
- }
655
+ ($_ [1]-> children)[0]-> isa(' PPI::Token::Word' ) or return ' ' ;
656
+ my $function = (($_ [1]-> children)[0])-> content;
657
+ exists ( $SCHEDULED_BLOCK { $function }) or return ' ' ;
658
+
659
+ my $v = $SCHEDULED_BLOCK { ($_ [1]-> children)[0]-> content };
660
+ if ($v and $v > ($version || 0) ) {
661
+ $version = $v ;
662
+ $obj = $_ [1];
663
+ }
664
664
665
665
return ' ' ;
666
666
} );
@@ -700,7 +700,7 @@ sub _regex {
700
700
}
701
701
702
702
sub _each_argument {
703
- my ($version , $obj );
703
+ my ($version , $obj );
704
704
shift -> Document-> find( sub {
705
705
$_ [1]-> isa(' PPI::Token::Word' ) or return ' ' ;
706
706
$_ [1]-> content =~ ' ^(each|keys|values)$' or return ' ' ;
@@ -750,7 +750,7 @@ sub _str_in_list {
750
750
751
751
752
752
sub _binmode_2_arg {
753
- my ($version , $obj );
753
+ my ($version , $obj );
754
754
shift -> Document-> find_first( sub {
755
755
my $main_element =$_ [1];
756
756
$main_element -> isa(' PPI::Token::Word' ) or return ' ' ;
@@ -762,22 +762,22 @@ sub _binmode_2_arg {
762
762
return ' ' if is_package_declaration($main_element );
763
763
my @arguments = parse_arg_list($main_element );
764
764
if ( scalar @arguments == 2 ) {
765
- my $arg2 =$arguments [1][0];
765
+ my $arg2 =$arguments [1][0];
766
766
if ( $arg2 -> isa(' PPI::Token::Quote' )) { # check second argument
767
767
my $str = $arg2 -> string;
768
768
$str =~ s / ^\s +// s ;
769
769
$str =~ s /\s +$// s ;
770
770
$str =~ s / :\s +/ :/ g ;
771
771
if ( !_str_in_list( $str => qw/ :raw :crlf/ ) and $str !~ / [\$\@\% ]/ ) {
772
- $version = 5.008;
773
- $obj = $main_element ;
772
+ $version = 5.008;
773
+ $obj = $main_element ;
774
774
return 1;
775
775
}
776
776
}
777
777
if (!$version ) {
778
- $version = 5.006;
779
- $obj = $main_element ;
780
- }
778
+ $version = 5.006;
779
+ $obj = $main_element ;
780
+ }
781
781
}
782
782
return ' ' ;
783
783
} );
@@ -801,7 +801,7 @@ sub _while_readdir {
801
801
}
802
802
$e1 -> isa(' PPI::Statement::Expression' ) or return ' ' ;
803
803
my @children = $e1 -> schildren;
804
- $e1 = $children [0];
804
+ $e1 = $children [0];
805
805
806
806
$e1 -> isa(' PPI::Token::Word' ) or return ' ' ;
807
807
$e1 -> content eq ' readdir' or return ' ' ;
@@ -833,8 +833,8 @@ sub _open_temp {
833
833
$main_element -> content eq ' open' or return ' ' ;
834
834
my @arguments = parse_arg_list($main_element );
835
835
if ( scalar @arguments == 3 and scalar (@{$arguments [2]}) == 1) {
836
- my $arg3 = $arguments [2][0];
837
- if ($arg3 -> isa(' PPI::Token::Word' ) and $arg3 -> content eq ' undef' ) {
836
+ my $arg3 = $arguments [2][0];
837
+ if ($arg3 -> isa(' PPI::Token::Word' ) and $arg3 -> content eq ' undef' ) {
838
838
return 1;
839
839
}
840
840
}
@@ -852,8 +852,8 @@ sub _open_scalar {
852
852
$main_element -> content eq ' open' or return ' ' ;
853
853
my @arguments = parse_arg_list($main_element );
854
854
if ( scalar @arguments == 3) {
855
- my $arg3 = $arguments [2][0];
856
- if ($arg3 -> isa(' PPI::Token::Cast' ) and $arg3 -> content eq ' \\ ' ) {
855
+ my $arg3 = $arguments [2][0];
856
+ if ($arg3 -> isa(' PPI::Token::Cast' ) and $arg3 -> content eq ' \\ ' ) {
857
857
return 1;
858
858
}
859
859
}
@@ -913,8 +913,8 @@ sub _yada_yada_yada {
913
913
sub _state_declaration {
914
914
shift -> Document-> find_first( sub {
915
915
$_ [1]-> isa(' PPI::Statement::Variable' )
916
- and ($_ [1]-> children)[0]-> isa(' PPI::Token::Word' )
917
- and ($_ [1]-> children)[0]-> content eq ' state'
916
+ and ($_ [1]-> children)[0]-> isa(' PPI::Token::Word' )
917
+ and ($_ [1]-> children)[0]-> content eq ' state'
918
918
} );
919
919
}
920
920
@@ -925,20 +925,20 @@ sub _stacked_labels {
925
925
926
926
my $next = $_ [1]-> snext_sibling || return ' ' ;
927
927
928
- if ( $next -> isa(' PPI::Statement::Compound' )
929
- && $next -> schild(0)-> isa(' PPI::Token::Label' )) {
930
- return 1;
931
- }
928
+ if ( $next -> isa(' PPI::Statement::Compound' )
929
+ && $next -> schild(0)-> isa(' PPI::Token::Label' )) {
930
+ return 1;
931
+ }
932
932
933
- 0;
934
- } );
933
+ 0;
934
+ } );
935
935
}
936
936
937
937
sub _internals_svreadonly {
938
938
shift -> Document-> find_first( sub {
939
939
$_ [1]-> isa(' PPI::Statement' )
940
- and ($_ [1]-> children)[0]-> isa(' PPI::Token::Word' )
941
- and ($_ [1]-> children)[0]-> content eq ' Internals::SvREADONLY'
940
+ and ($_ [1]-> children)[0]-> isa(' PPI::Token::Word' )
941
+ and ($_ [1]-> children)[0]-> content eq ' Internals::SvREADONLY'
942
942
} );
943
943
}
944
944
0 commit comments