From 611a7ec119f78c9f7e7bfe54ea72a885bf0ba7b5 Mon Sep 17 00:00:00 2001 From: Alexandr Evstigneev Date: Sat, 9 Feb 2019 21:51:26 +0300 Subject: [PATCH] Unreachable code cleanup and fixes --- bin/cpan2dist | 4 +- inc/bundle/IO/Zlib.pm | 1 - inc/bundle/Module/Load.pm | 3 +- lib/CPANPLUS/Configure.pm | 5 +- lib/CPANPLUS/Configure/Setup.pm | 2 - lib/CPANPLUS/Internals/Source.pm | 80 -------------------------------- lib/CPANPLUS/Shell/Default.pm | 2 +- test.pl | 15 ++++++ 8 files changed, 21 insertions(+), 91 deletions(-) create mode 100644 test.pl diff --git a/bin/cpan2dist b/bin/cpan2dist index 54552d8d..c51abf23 100644 --- a/bin/cpan2dist +++ b/bin/cpan2dist @@ -241,8 +241,8 @@ $cb->reload_indices() if $opts->{'flushcache'}; for my $name ( keys %$href ) { my $obj = $cb->parse_module( module => $name ) or ( - warn "Cannot make a module object out of ". - "'$name' -- skipping\n", + warn("Cannot make a module object out of ". + "'$name' -- skipping\n"), next ); if( my $pat = ignore_me( $obj ) ) { diff --git a/inc/bundle/IO/Zlib.pm b/inc/bundle/IO/Zlib.pm index 55534b4f..01aa9492 100644 --- a/inc/bundle/IO/Zlib.pm +++ b/inc/bundle/IO/Zlib.pm @@ -610,7 +610,6 @@ sub gzopen_external { } else { croak "IO::Zlib::gzopen_external: mode '$mode' is illegal"; } - return undef; } sub gzread_external { diff --git a/inc/bundle/Module/Load.pm b/inc/bundle/Module/Load.pm index 9e69f832..fdad639d 100644 --- a/inc/bundle/Module/Load.pm +++ b/inc/bundle/Module/Load.pm @@ -92,8 +92,7 @@ sub _load{ $import = $mod->can('import') ) and ( unshift(@_, $mod), - goto &$import, - return + goto &$import ) ); } diff --git a/lib/CPANPLUS/Configure.pm b/lib/CPANPLUS/Configure.pm index be4790ae..d8f12e9e 100644 --- a/lib/CPANPLUS/Configure.pm +++ b/lib/CPANPLUS/Configure.pm @@ -97,7 +97,7 @@ or not. Defaults to C. }; check( $tmpl, \%hash ) or ( - warn Params::Check->last_error, return + warn(Params::Check->last_error), return ); $Config ||= CPANPLUS::Config->new; @@ -150,7 +150,7 @@ Returns true on success, false on failure. }; check( $tmpl, \%hash ) or ( - warn Params::Check->last_error, return + warn(Params::Check->last_error), return ); ### if the base dir is changed, we have to rescan it @@ -449,7 +449,6 @@ sub options { return sort grep { !$seen{$_}++ } map { $_->$type->ls_accessors if $_->can($type) } $self->conf; - return; } =pod diff --git a/lib/CPANPLUS/Configure/Setup.pm b/lib/CPANPLUS/Configure/Setup.pm index 59546eb3..a2d8ba7a 100644 --- a/lib/CPANPLUS/Configure/Setup.pm +++ b/lib/CPANPLUS/Configure/Setup.pm @@ -154,8 +154,6 @@ Quitting setup, changes are saved to '%1' ### otherwise, present choice again redo PICK_SECTION; } - - return 1; } diff --git a/lib/CPANPLUS/Internals/Source.pm b/lib/CPANPLUS/Internals/Source.pm index 12ef577d..37f02d8f 100644 --- a/lib/CPANPLUS/Internals/Source.pm +++ b/lib/CPANPLUS/Internals/Source.pm @@ -825,86 +825,6 @@ sub __create_dslip_tree { my $conf = $self->configure_object; return {}; # Quick hack - - my $tmpl = { - path => { default => $conf->get_conf('base') }, - verbose => { default => $conf->get_conf('verbose') }, - uptodate => { default => 0 }, - }; - - my $args = check( $tmpl, \%hash ) or return; - - ### get the file name of the source ### - my $file = File::Spec->catfile($args->{path}, $conf->_get_source('dslip')); - - ### extract the file ### - my $ae = Archive::Extract->new( archive => $file ) or return; - my $out = STRIP_GZ_SUFFIX->($file); - - ### make sure to set the PREFER_BIN flag if desired ### - { local $Archive::Extract::PREFER_BIN = $conf->get_conf('prefer_bin'); - $ae->extract( to => $out ) or return; - } - - my $in = $self->_get_file_contents( file => $out ) or return; - - ### don't need it anymore ### - unlink $out; - - - ### get rid of the comments and the code ### - ### need a smarter parser, some people have this in their dslip info: - # [ - # 'Statistics::LTU', - # 'R', - # 'd', - # 'p', - # 'O', - # '?', - # 'Implements Linear Threshold Units', - # ...skipping... - # "\x{c4}dd \x{fc}ml\x{e4}\x{fc}ts t\x{f6} \x{eb}v\x{eb}r\x{ff}th\x{ef}ng!", - # 'BENNIE', - # '11' - # ], - ### also, older versions say: - ### $cols = [....] - ### and newer versions say: - ### $CPANPLUS::Modulelist::cols = [...] - ### split '$cols' and '$data' into 2 variables ### - ### use this regex to make sure dslips with ';' in them don't cause - ### parser errors - my ($ds_one, $ds_two) = ($in =~ m|.+}\s+ - (\$(?:CPAN::Modulelist::)?cols.*?) - (\$(?:CPAN::Modulelist::)?data.*) - |sx); - - ### eval them into existence ### - ### still not too fond of this solution - kane ### - my ($cols, $data); - { #local $@; can't use this, it's buggy -kane - - $cols = eval $ds_one; - error( loc("Error in eval of dslip source files: %1", $@) ) if $@; - - $data = eval $ds_two; - error( loc("Error in eval of dslip source files: %1", $@) ) if $@; - - } - - my $tree = {}; - my $primary = "modid"; - - ### this comes from CPAN::Modulelist - ### which is in 03modlist.data.gz - for (@$data){ - my %hash; - @hash{@$cols} = @$_; - $tree->{$hash{$primary}} = \%hash; - } - - return $tree; - } #__create_dslip_tree =pod diff --git a/lib/CPANPLUS/Shell/Default.pm b/lib/CPANPLUS/Shell/Default.pm index dccc5051..d84766fe 100644 --- a/lib/CPANPLUS/Shell/Default.pm +++ b/lib/CPANPLUS/Shell/Default.pm @@ -1205,7 +1205,7 @@ sub _print { my $old; my $fh; if( $file ) { $fh = FileHandle->new( ">$file" ) - or( warn loc("Could not open '%1': '%2'", $file, $!), + or( warn(loc("Could not open '%1': '%2'", $file, $!)), return ); $old = select $fh; diff --git a/test.pl b/test.pl new file mode 100644 index 00000000..c45f097d --- /dev/null +++ b/test.pl @@ -0,0 +1,15 @@ +use strict; +use warnings FATAL => 'all'; +use v5.10; + +sub some{ + goto SOME; + + my $var; + + SOME: + $var = 1; + say $var; +} + +some();