Skip to content

Commit a4b9c57

Browse files
committed
Add .editorconfig file; regularize leading tabs
- Added a .editorconfig file to help with consistency in formatting. As far as I can tell from the source, it's Unix linefeeds, tab indents, and four-space tabs. I got the four-space tabs from lib/Perl/MinimumVersion.pm:459--460: those lines don't indent correctly with two-space tabs. - In lib/Perl/MinimumVersion.pm, change the leading spaces to leading tabs for consistency.
1 parent bb341fe commit a4b9c57

File tree

2 files changed

+120
-111
lines changed

2 files changed

+120
-111
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root=true
2+
3+
[*]
4+
indent_style = tab
5+
indent_size = 4
6+
end_of_line = lf
7+
8+
[.git/*]
9+
indent_style = space # for commit messages

lib/Perl/MinimumVersion.pm

Lines changed: 111 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ BEGIN {
6868
%CHECKS = (
6969
_heredoc_indent => version->new('5.025.007'),
7070

71-
# _stacked_labels => version->new('5.014'),
71+
# _stacked_labels => version->new('5.014'),
7272

7373
_yada_yada_yada => version->new('5.012'),
7474
_pkg_name_version => version->new('5.012'),
@@ -97,8 +97,8 @@ BEGIN {
9797
_pragma_utf8 => version->new('5.008'),
9898
);
9999
@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'
102102
);
103103

104104
# Predefine some indexes needed by various check methods
@@ -418,12 +418,12 @@ sub _minimum_syntax_version {
418418
version => $v,
419419
element => _INSTANCE($obj, 'PPI::Element'),
420420
);
421-
if ($self->{_collect_all_reasons}) {
421+
if ($self->{_collect_all_reasons}) {
422422
push @{ $self->{_all_reasons} }, $current_reason;
423423
} else {
424424
$filter = $v;
425425
}
426-
}
426+
}
427427
}
428428

429429

@@ -433,7 +433,7 @@ sub _minimum_syntax_version {
433433
my @rules = sort {
434434
$CHECKS{$b} <=> $CHECKS{$a}
435435
} grep {
436-
not(exists $checks2skip{$_}) and $CHECKS{$_} > $filter
436+
not(exists $checks2skip{$_}) and $CHECKS{$_} > $filter
437437
} keys %CHECKS;
438438

439439
foreach my $rule ( @rules ) {
@@ -540,41 +540,41 @@ sub version_markers {
540540

541541
my %feature =
542542
(
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
562562
);
563563
my $feature_regexp = join('|', keys %feature);
564564

565565
#:5.14 means same as :5.12, but :5.14 is not defined in feature.pm in perl 5.12.
566566
sub _feature_bundle {
567-
my @versions;
568-
my ($version, $obj);
567+
my @versions;
568+
my ($version, $obj);
569569
shift->Document->find( sub {
570570
$_[1]->isa('PPI::Statement::Include') or return '';
571571
$_[1]->pragma eq 'feature' or return '';
572572
my @child = $_[1]->schildren;
573573
my @args = @child[1..$#child]; # skip 'use', 'feature' and ';'
574574
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/);
578578
#
579579
if ($v and $v > ($version || 0) ) {
580580
$version = $v;
@@ -589,78 +589,78 @@ sub _feature_bundle {
589589
# list copied from experimental.pm v0.021 itself
590590
my %experimental =
591591
(
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',
614614
);
615615
my $experimental_regexp = join('|', keys %experimental);
616616
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);
639639
}
640640

641641
my %SCHEDULED_BLOCK =
642642
(
643-
'INIT' => '5.006',
644-
'CHECK' => '5.006002',
645-
'UNITCHECK' => '5.010',
643+
'INIT' => '5.006',
644+
'CHECK' => '5.006002',
645+
'UNITCHECK' => '5.010',
646646
);
647647

648648
sub _scheduled_blocks
649649
{
650-
my @versions;
651-
my ($version, $obj);
650+
my @versions;
651+
my ($version, $obj);
652652

653653
shift->Document->find( sub {
654654
$_[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+
}
664664

665665
return '';
666666
} );
@@ -700,7 +700,7 @@ sub _regex {
700700
}
701701

702702
sub _each_argument {
703-
my ($version, $obj);
703+
my ($version, $obj);
704704
shift->Document->find( sub {
705705
$_[1]->isa('PPI::Token::Word') or return '';
706706
$_[1]->content =~ '^(each|keys|values)$' or return '';
@@ -750,7 +750,7 @@ sub _str_in_list {
750750

751751

752752
sub _binmode_2_arg {
753-
my ($version, $obj);
753+
my ($version, $obj);
754754
shift->Document->find_first( sub {
755755
my $main_element=$_[1];
756756
$main_element->isa('PPI::Token::Word') or return '';
@@ -762,22 +762,22 @@ sub _binmode_2_arg {
762762
return '' if is_package_declaration($main_element);
763763
my @arguments = parse_arg_list($main_element);
764764
if ( scalar @arguments == 2 ) {
765-
my $arg2=$arguments[1][0];
765+
my $arg2=$arguments[1][0];
766766
if ( $arg2->isa('PPI::Token::Quote')) { #check second argument
767767
my $str = $arg2->string;
768768
$str =~ s/^\s+//s;
769769
$str =~ s/\s+$//s;
770770
$str =~ s/:\s+/:/g;
771771
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;
774774
return 1;
775775
}
776776
}
777777
if (!$version) {
778-
$version = 5.006;
779-
$obj = $main_element;
780-
}
778+
$version = 5.006;
779+
$obj = $main_element;
780+
}
781781
}
782782
return '';
783783
} );
@@ -801,7 +801,7 @@ sub _while_readdir {
801801
}
802802
$e1->isa('PPI::Statement::Expression') or return '';
803803
my @children = $e1->schildren;
804-
$e1 = $children[0];
804+
$e1 = $children[0];
805805

806806
$e1->isa('PPI::Token::Word') or return '';
807807
$e1->content eq 'readdir' or return '';
@@ -833,8 +833,8 @@ sub _open_temp {
833833
$main_element->content eq 'open' or return '';
834834
my @arguments = parse_arg_list($main_element);
835835
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') {
838838
return 1;
839839
}
840840
}
@@ -852,8 +852,8 @@ sub _open_scalar {
852852
$main_element->content eq 'open' or return '';
853853
my @arguments = parse_arg_list($main_element);
854854
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 '\\') {
857857
return 1;
858858
}
859859
}
@@ -913,8 +913,8 @@ sub _yada_yada_yada {
913913
sub _state_declaration {
914914
shift->Document->find_first( sub {
915915
$_[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'
918918
} );
919919
}
920920

@@ -925,20 +925,20 @@ sub _stacked_labels {
925925

926926
my $next = $_[1]->snext_sibling || return '';
927927

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+
}
932932

933-
0;
934-
} );
933+
0;
934+
} );
935935
}
936936

937937
sub _internals_svreadonly {
938938
shift->Document->find_first( sub {
939939
$_[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'
942942
} );
943943
}
944944

0 commit comments

Comments
 (0)