Skip Menu |

This queue is for tickets about the Pod-Usage CPAN distribution.

Maintainer(s)' notes

Please use Github for all future tickets, patches and pull requests: https://github.com/Dual-Life/Pod-Usage

Thanks to Nicolas R (ATOOMIC) for setting up everything there!

Report information
The Basics
Id: 133185
Status: resolved
Priority: 0/
Queue: Pod-Usage

People
Owner: Nobody in particular
Requestors: nicolas [...] atoomic.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [PATCH] Avoid indirect calls
Attached to this message is a patch to replace indirect calls by direct calls. You can view the patch online at https://github.com/atoomic/Pod-Usage/pull/2/files You can view a CI workflow with these changes on top of v1.70 from: https://github.com/atoomic/Pod-Usage/actions/runs/213864143
Subject: 0001-Avoid-indirect-calls.patch
From d152893f26cb687d72d735a8a0df8c5e0a524d7b Mon Sep 17 00:00:00 2001 From: Nicolas R <nicolas@atoomic.org> Date: Tue, 18 Aug 2020 09:32:26 -0600 Subject: [PATCH] Avoid indirect calls Prefer direct calls over indirect calls. Remove indirect calls from documenation. --- lib/Pod/Usage.pm | 2 +- t/inc/Pod/InputObjects.pm | 26 ++++++++++++-------------- t/inc/Pod/Parser.pm | 19 +++++++++---------- t/inc/Pod/PlainText.pm | 2 +- t/inc/Pod/Select.pm | 4 ++-- t/pod/pod2usage.t | 2 +- t/pod/testp2pt.pl | 2 +- 7 files changed, 27 insertions(+), 30 deletions(-) diff --git a/lib/Pod/Usage.pm b/lib/Pod/Usage.pm index fe5e555..938c4d7 100644 --- a/lib/Pod/Usage.pm +++ b/lib/Pod/Usage.pm @@ -109,7 +109,7 @@ sub pod2usage { } ## Now create a pod reader and constrain it to the desired sections. - my $parser = new Pod::Usage(USAGE_OPTIONS => \%opts); + my $parser = Pod::Usage->new(USAGE_OPTIONS => \%opts); if ($opts{'-verbose'} == 0) { $parser->select('(?:SYNOPSIS|USAGE)\s*'); } diff --git a/t/inc/Pod/InputObjects.pm b/t/inc/Pod/InputObjects.pm index c19d4c5..a4c5b3e 100644 --- a/t/inc/Pod/InputObjects.pm +++ b/t/inc/Pod/InputObjects.pm @@ -111,9 +111,9 @@ methods/attributes: =head2 B<new()> my $pod_input1 = Pod::InputSource->new(-handle => $filehandle); - my $pod_input2 = new Pod::InputSource(-handle => $filehandle, - -name => $name); - my $pod_input3 = new Pod::InputSource(-handle => \*STDIN); + my $pod_input2 = Pod::InputSource->new(-handle => $filehandle, + -name => $name); + my $pod_input3 = Pod::InputSource->new(-handle => \*STDIN); my $pod_input4 = Pod::InputSource->new(-handle => \*STDIN, -name => "(STDIN)"); @@ -236,8 +236,8 @@ It has the following methods/attributes: my $pod_para1 = Pod::Paragraph->new(-text => $text); my $pod_para2 = Pod::Paragraph->new(-name => $cmd, -text => $text); - my $pod_para3 = new Pod::Paragraph(-text => $text); - my $pod_para4 = new Pod::Paragraph(-name => $cmd, + my $pod_para3 = Pod::Paragraph->new(-text => $text); + my $pod_para4 = Pod::Paragraph-<new(-name => $cmd, -text => $text); my $pod_para5 = Pod::Paragraph->new(-name => $cmd, -text => $text, @@ -426,15 +426,15 @@ It has the following methods/attributes: my $pod_seq1 = Pod::InteriorSequence->new(-name => $cmd -ldelim => $delimiter); - my $pod_seq2 = new Pod::InteriorSequence(-name => $cmd, + my $pod_seq2 = Pod::InteriorSequence->new(-name => $cmd, -ldelim => $delimiter); - my $pod_seq3 = new Pod::InteriorSequence(-name => $cmd, + my $pod_seq3 = Pod::InteriorSequence->new(-name => $cmd, -ldelim => $delimiter, -file => $filename, -line => $line_number); - my $pod_seq4 = new Pod::InteriorSequence(-name => $cmd, $ptree); - my $pod_seq5 = new Pod::InteriorSequence($cmd, $ptree); + my $pod_seq4 = Pod::InteriorSequence->new(-name => $cmd, $ptree); + my $pod_seq5 = Pod::InteriorSequence->new($cmd, $ptree); This is a class method that constructs a C<Pod::InteriorSequence> object and returns a reference to the new interior sequence object. It should @@ -481,11 +481,11 @@ sub new { }; ## Initialize contents if they havent been already - my $ptree = $self->{'-ptree'} || new Pod::ParseTree(); + my $ptree = $self->{'-ptree'} || Pod::ParseTree->new(); if ( ref $ptree =~ /^(ARRAY)?$/ ) { ## We have an array-ref, or a normal scalar. Pass it as an ## an argument to the ptree-constructor - $ptree = new Pod::ParseTree($1 ? [$ptree] : $ptree); + $ptree = Pod::ParseTree->new($1 ? [$ptree] : $ptree); } $self->{'-ptree'} = $ptree; @@ -740,9 +740,7 @@ itself contain a parse-tree (since interior sequences may be nested). =head2 Pod::ParseTree-E<gt>B<new()> my $ptree1 = Pod::ParseTree->new; - my $ptree2 = new Pod::ParseTree; - my $ptree4 = Pod::ParseTree->new($array_ref); - my $ptree3 = new Pod::ParseTree($array_ref); + my $ptree2 = Pod::ParseTree->new($array_ref); This is a class method that constructs a C<Pod::Parse_tree> object and returns a reference to the new parse-tree. If a single-argument is given, diff --git a/t/inc/Pod/Parser.pm b/t/inc/Pod/Parser.pm index 4b4fecf..473ab1b 100644 --- a/t/inc/Pod/Parser.pm +++ b/t/inc/Pod/Parser.pm @@ -67,7 +67,7 @@ Pod::Parser - base class for creating POD filters and translators ## Create a parser object and have it parse file whose name was ## given on the command-line (use STDIN if no files were given). - $parser = new MyParser(); + $parser = MyParser->new(); $parser->parse_from_filehandle(\*STDIN) if (@ARGV == 0); for (@ARGV) { $parser->parse_from_file($_); } @@ -212,7 +212,7 @@ use Exporter; BEGIN { if ($] < 5.006) { require Symbol; - import Symbol; + Symbol->import; } } @ISA = qw(Exporter); @@ -416,8 +416,7 @@ subclass objects as well as base class objects, provided you use any of the following constructor invocation styles: my $parser1 = MyParser->new(); - my $parser2 = new MyParser(); - my $parser3 = $parser2->new(); + my $parser2 = $parser1->new(); where C<MyParser> is some subclass of B<Pod::Parser>. @@ -434,7 +433,7 @@ associative array (or hash-table) my be passed to the B<new()> constructor, as in: my $parser1 = MyParser->new( MYDATA => $value1, MOREDATA => $value2 ); - my $parser2 = new MyParser( -myflag => 1 ); + my $parser2 = MyParser->new( -myflag => 1 ); All arguments passed to the B<new()> constructor will be treated as key/value pairs in a hash-table. The newly constructed object will be @@ -977,7 +976,7 @@ sub parse_paragraph { } } ## Save the attributes indicating how the command was specified. - $pod_para = new Pod::Paragraph( + $pod_para = Pod::Paragraph->new( -name => $cmd, -text => $text, -prefix => $pfx, @@ -1563,7 +1562,7 @@ sub _push_input_stream { $myData{_INFILE} = '(unknown)' unless (defined $myData{_INFILE}); $myData{_INPUT} = $in_fh; my $input_top = $myData{_TOP_STREAM} - = new Pod::InputSource( + = Pod::InputSource->new( -name => $myData{_INFILE}, -handle => $in_fh, -was_cutting => $myData{_CUTTING} @@ -1712,7 +1711,7 @@ following: package main; ... - my $parser = new MyPodParserTree(...); + my $parser = MyPodParserTree->new(...); $parser->parse_from_file(...); my $paragraphs_ref = $parser->{'-paragraphs'}; @@ -1727,7 +1726,7 @@ interface for all parse-tree nodes. The result would look something like: sub begin_pod { my $self = shift; - $self->{'-ptree'} = new Pod::ParseTree; ## initialize parse-tree + $self->{'-ptree'} = Pod::ParseTree->new(); ## initialize parse-tree } sub parse_tree { @@ -1759,7 +1758,7 @@ interface for all parse-tree nodes. The result would look something like: package main; ... - my $parser = new MyPodParserTree2(...); + my $parser = MyPodParserTree2->new(...); $parser->parse_from_file(...); my $ptree = $parser->parse_tree; ... diff --git a/t/inc/Pod/PlainText.pm b/t/inc/Pod/PlainText.pm index e8dc001..5b7ade7 100644 --- a/t/inc/Pod/PlainText.pm +++ b/t/inc/Pod/PlainText.pm @@ -34,7 +34,7 @@ $VERSION = '2.06'; BEGIN { if ($] < 5.006) { require Symbol; - import Symbol; + Symbol->import; } } diff --git a/t/inc/Pod/Select.pm b/t/inc/Pod/Select.pm index 148b5d1..8d671ea 100644 --- a/t/inc/Pod/Select.pm +++ b/t/inc/Pod/Select.pm @@ -44,7 +44,7 @@ or use Pod::Select; ## Create a parser object for selecting POD sections from the input - $parser = new Pod::Select(); + $parser = Pod::Select->new(); ## Select all the POD sections for each file in @filelist ## and print the result to tmp.out. @@ -575,7 +575,7 @@ filenames are given). sub podselect { my(@argv) = @_; my %defaults = (); - my $pod_parser = new Pod::Select(%defaults); + my $pod_parser = Pod::Select->new(%defaults); my $num_inputs = 0; my $output = '>&STDOUT'; my %opts; diff --git a/t/pod/pod2usage.t b/t/pod/pod2usage.t index cf2c31b..fb2c42c 100644 --- a/t/pod/pod2usage.t +++ b/t/pod/pod2usage.t @@ -3,7 +3,7 @@ BEGIN { my $THISDIR = dirname $0; unshift @INC, $THISDIR; require "testp2pt.pl"; - import TestPodIncPlainText; + TestPodIncPlainText->import; } my %options = map { $_ => 1 } @ARGV; ## convert cmdline to options-hash diff --git a/t/pod/testp2pt.pl b/t/pod/testp2pt.pl index 1ba8022..f33fd4a 100644 --- a/t/pod/testp2pt.pl +++ b/t/pod/testp2pt.pl @@ -10,7 +10,7 @@ BEGIN { my $THISDIR = abs_path(dirname $0); unshift @INC, $THISDIR; require "testcmp.pl"; - import TestCompare; + TestCompare->import; # RT#130418: previous use of dirname() was failing on VMS $PARENTDIR = File::Spec->catdir($THISDIR, File::Spec->updir()); push @INC, map { File::Spec->catdir($_, 'lib') } ($PARENTDIR, $THISDIR); -- 2.24.3 (Apple Git-128)