about summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-01-05 23:23:35 +0000
committerEric Wong <e@yhbt.net>2020-01-06 10:21:00 +0000
commit55b707d788ce13696e4411389583e720ea6dab01 (patch)
tree19fcea9f3da92c0183fdb5845c79aaefbe1d53c4
parent42f390c5e4d8e6619d234a43aa5397c9977cf070 (diff)
downloadpublic-inbox-55b707d788ce13696e4411389583e720ea6dab01.tar.gz
There's a bunch of leftover "require" and "use" statements we no
longer need and can get rid of, along with some excessive
imports via "use".

IO::Handle usage isn't always obvious, so add comments
describing why a package loads it.  Along the same lines,
document the tmpdir support as the reason we depend on
File::Temp 0.19, even though every Perl 5.10.1+ user has it.

While we're at it, favor "use" over "require", since it it gives
us extra compile-time checking.
-rw-r--r--Makefile.PL2
-rw-r--r--lib/PublicInbox/DS.pm5
-rw-r--r--lib/PublicInbox/Daemon.pm2
-rw-r--r--lib/PublicInbox/Emergency.pm2
-rw-r--r--lib/PublicInbox/ExtMsg.pm1
-rw-r--r--lib/PublicInbox/Filter/RubyLang.pm1
-rw-r--r--lib/PublicInbox/Git.pm2
-rw-r--r--lib/PublicInbox/GitHTTPBackend.pm2
-rw-r--r--lib/PublicInbox/HTTP.pm3
-rw-r--r--lib/PublicInbox/HTTPD.pm4
-rw-r--r--lib/PublicInbox/Import.pm2
-rw-r--r--lib/PublicInbox/Listener.pm2
-rw-r--r--lib/PublicInbox/MboxGz.pm1
-rw-r--r--lib/PublicInbox/NNTPD.pm2
-rw-r--r--lib/PublicInbox/Search.pm2
-rw-r--r--lib/PublicInbox/SearchIdx.pm2
-rw-r--r--lib/PublicInbox/SearchView.pm6
-rw-r--r--lib/PublicInbox/SolverGit.pm2
-rw-r--r--lib/PublicInbox/Spawn.pm1
-rw-r--r--lib/PublicInbox/TLS.pm2
-rw-r--r--lib/PublicInbox/Tmpfile.pm2
-rw-r--r--lib/PublicInbox/V2Writable.pm2
-rw-r--r--lib/PublicInbox/ViewDiff.pm2
-rw-r--r--lib/PublicInbox/WatchMaildir.pm2
-rw-r--r--lib/PublicInbox/WwwAtomStream.pm2
-rw-r--r--lib/PublicInbox/Xapcmd.pm2
-rwxr-xr-xscript/public-inbox-convert2
-rwxr-xr-xscript/public-inbox-edit8
-rwxr-xr-xscript/public-inbox-init4
-rwxr-xr-xscript/public-inbox-nntpd4
-rw-r--r--t/cgi.t2
-rw-r--r--t/feed.t2
32 files changed, 31 insertions, 49 deletions
diff --git a/Makefile.PL b/Makefile.PL
index b8c05cf7..3492d965 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -137,7 +137,7 @@ WriteMakefile(
                 # All Perl installs I know about have these, but RH-based
                 # distros make them separate even though 'perl' pulls them in
                 'File::Path' => 0,
-                'File::Temp' => '0.19',
+                'File::Temp' => '0.19', # for ->tmpdir support
                 'Getopt::Long' => 0,
                 'Exporter' => 0,
                 # ExtUtils::MakeMaker # this file won't run w/o it...
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 8f17f7fb..09dc3992 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -35,9 +35,8 @@ use fields ('sock',              # underlying socket
             'wbuf_off',  # offset into first element of wbuf to start writing at
             );
 
-use Errno  qw(EAGAIN EINVAL);
-use Carp   qw(croak confess carp);
-require File::Spec;
+use Errno qw(EAGAIN EINVAL);
+use Carp qw(confess carp);
 
 my $nextq; # queue for next_tick
 my $WaitPids; # list of [ pid, callback, callback_arg ]
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 9db472a1..292bc339 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -6,7 +6,7 @@ package PublicInbox::Daemon;
 use strict;
 use warnings;
 use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
-use IO::Handle;
+use IO::Handle; # ->autoflush
 use IO::Socket;
 use POSIX qw(WNOHANG :signal_h);
 use Socket qw(IPPROTO_TCP SOL_SOCKET);
diff --git a/lib/PublicInbox/Emergency.pm b/lib/PublicInbox/Emergency.pm
index 5ce75a79..8c0cc184 100644
--- a/lib/PublicInbox/Emergency.pm
+++ b/lib/PublicInbox/Emergency.pm
@@ -7,7 +7,7 @@ use strict;
 use warnings;
 use Fcntl qw(:DEFAULT SEEK_SET);
 use Sys::Hostname qw(hostname);
-use IO::Handle;
+use IO::Handle; # ->flush, ->autoflush
 
 sub new {
         my ($class, $dir) = @_;
diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm
index 549e4495..49fc1ac5 100644
--- a/lib/PublicInbox/ExtMsg.pm
+++ b/lib/PublicInbox/ExtMsg.pm
@@ -9,7 +9,6 @@ package PublicInbox::ExtMsg;
 use strict;
 use warnings;
 use PublicInbox::Hval qw(ascii_html prurl);
-use PublicInbox::MID qw/mid2path/;
 use PublicInbox::WwwStream;
 our $MIN_PARTIAL_LEN = 16;
 
diff --git a/lib/PublicInbox/Filter/RubyLang.pm b/lib/PublicInbox/Filter/RubyLang.pm
index 094ac1c2..3a8dd881 100644
--- a/lib/PublicInbox/Filter/RubyLang.pm
+++ b/lib/PublicInbox/Filter/RubyLang.pm
@@ -22,7 +22,6 @@ sub new {
                 $altid ||= $ibx->{altid}->[0];
         }
         if ($altid) {
-                require PublicInbox::MID; # mid_clean
                 require PublicInbox::AltId;
                 $self->{-altid} = PublicInbox::AltId->new($ibx, $altid, 1);
         }
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 8d587469..6a527f82 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -10,7 +10,7 @@ package PublicInbox::Git;
 use strict;
 use warnings;
 use POSIX qw(dup2);
-require IO::Handle;
+use IO::Handle; # ->autoflush
 use PublicInbox::Spawn qw(spawn popen_rd);
 use PublicInbox::Tmpfile;
 use base qw(Exporter);
diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm
index d1132fb7..81ff23fc 100644
--- a/lib/PublicInbox/GitHTTPBackend.pm
+++ b/lib/PublicInbox/GitHTTPBackend.pm
@@ -7,7 +7,7 @@ package PublicInbox::GitHTTPBackend;
 use strict;
 use warnings;
 use Fcntl qw(:seek);
-use IO::Handle;
+use IO::Handle; # ->flush
 use HTTP::Date qw(time2str);
 use PublicInbox::Qspawn;
 use PublicInbox::Tmpfile;
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index d2f04ba5..1346901a 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -15,9 +15,10 @@ use fields qw(httpd env input_left remote_addr remote_port forward alive);
 use bytes (); # only for bytes::length
 use Fcntl qw(:seek);
 use Plack::HTTPParser qw(parse_http_request); # XS or pure Perl
+use Plack::Util;
 use HTTP::Status qw(status_message);
 use HTTP::Date qw(time2str);
-use IO::Handle;
+use IO::Handle; # ->write
 use PublicInbox::DS qw(msg_more);
 use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);
 use PublicInbox::Tmpfile;
diff --git a/lib/PublicInbox/HTTPD.pm b/lib/PublicInbox/HTTPD.pm
index 47f5a01a..1331a91e 100644
--- a/lib/PublicInbox/HTTPD.pm
+++ b/lib/PublicInbox/HTTPD.pm
@@ -7,8 +7,8 @@ package PublicInbox::HTTPD;
 use strict;
 use warnings;
 use Plack::Util;
-require PublicInbox::HTTPD::Async;
-require PublicInbox::Daemon;
+use PublicInbox::HTTPD::Async;
+use PublicInbox::Daemon;
 
 sub pi_httpd_async { PublicInbox::HTTPD::Async->new(@_) }
 
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 20669ab9..572e9bb9 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -10,7 +10,7 @@ use strict;
 use warnings;
 use base qw(PublicInbox::Lock);
 use PublicInbox::Spawn qw(spawn);
-use PublicInbox::MID qw(mids mid_mime mid2path);
+use PublicInbox::MID qw(mids mid2path);
 use PublicInbox::Address;
 use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
 use PublicInbox::ContentId qw(content_digest);
diff --git a/lib/PublicInbox/Listener.pm b/lib/PublicInbox/Listener.pm
index 821c3458..928d9301 100644
--- a/lib/PublicInbox/Listener.pm
+++ b/lib/PublicInbox/Listener.pm
@@ -8,7 +8,7 @@ use warnings;
 use base 'PublicInbox::DS';
 use Socket qw(SOL_SOCKET SO_KEEPALIVE IPPROTO_TCP TCP_NODELAY);
 use fields qw(post_accept);
-require IO::Handle;
+use IO::Handle;
 use PublicInbox::Syscall qw(EPOLLIN EPOLLEXCLUSIVE EPOLLET);
 use Errno qw(EAGAIN ECONNABORTED EPERM);
 
diff --git a/lib/PublicInbox/MboxGz.pm b/lib/PublicInbox/MboxGz.pm
index 2b873451..08e3c846 100644
--- a/lib/PublicInbox/MboxGz.pm
+++ b/lib/PublicInbox/MboxGz.pm
@@ -6,7 +6,6 @@ use warnings;
 use Email::Simple;
 use PublicInbox::Hval qw/to_filename/;
 use PublicInbox::Mbox;
-use IO::Compress::Gzip;
 use Compress::Raw::Zlib qw(Z_FINISH Z_OK);
 my %OPT = (-WindowBits => 15 + 16, -AppendOutput => 1);
 
diff --git a/lib/PublicInbox/NNTPD.pm b/lib/PublicInbox/NNTPD.pm
index 0f79f8f9..925691bc 100644
--- a/lib/PublicInbox/NNTPD.pm
+++ b/lib/PublicInbox/NNTPD.pm
@@ -7,7 +7,7 @@ package PublicInbox::NNTPD;
 use strict;
 use warnings;
 use Sys::Hostname;
-require PublicInbox::Config;
+use PublicInbox::Config;
 
 sub new {
         my ($class) = @_;
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index aff3d48b..5c9dccb5 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -13,8 +13,6 @@ use constant YYYYMMDD => 1; # Date: header for searching in the WWW UI
 use constant DT => 2; # Date: YYYYMMDDHHMMSS
 
 use PublicInbox::SearchMsg;
-use PublicInbox::MIME;
-use PublicInbox::MID qw/id_compress/;
 use PublicInbox::Over;
 my $QP_FLAGS;
 our %X = map { $_ => 0 } qw(BoolWeight Database Enquire
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 0d983aab..f14809d2 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -12,7 +12,7 @@ use warnings;
 use base qw(PublicInbox::Search PublicInbox::Lock);
 use PublicInbox::MIME;
 use PublicInbox::InboxWritable;
-use PublicInbox::MID qw/mid_clean id_compress mid_mime mids_for_index/;
+use PublicInbox::MID qw/mid_clean mid_mime mids_for_index/;
 use PublicInbox::MsgIter;
 use Carp qw(croak);
 use POSIX qw(strftime);
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm
index 6587d37f..0d2e71fd 100644
--- a/lib/PublicInbox/SearchView.pm
+++ b/lib/PublicInbox/SearchView.pm
@@ -10,10 +10,7 @@ use PublicInbox::SearchMsg;
 use PublicInbox::Hval qw/ascii_html obfuscate_addrs/;
 use PublicInbox::View;
 use PublicInbox::WwwAtomStream;
-use PublicInbox::MID qw(MID_ESC);
-use PublicInbox::MIME;
-require PublicInbox::Git;
-require PublicInbox::SearchThread;
+use PublicInbox::SearchThread;
 our $LIM = 200;
 my %rmap_inc;
 
@@ -350,7 +347,6 @@ package PublicInbox::SearchQuery;
 use strict;
 use warnings;
 use URI::Escape qw(uri_escape);
-use PublicInbox::Hval;
 use PublicInbox::MID qw(MID_ESC);
 
 sub new {
diff --git a/lib/PublicInbox/SolverGit.pm b/lib/PublicInbox/SolverGit.pm
index 5ac27988..8629f0da 100644
--- a/lib/PublicInbox/SolverGit.pm
+++ b/lib/PublicInbox/SolverGit.pm
@@ -11,7 +11,7 @@ package PublicInbox::SolverGit;
 use strict;
 use warnings;
 use 5.010_001;
-use File::Temp 0.19 ();
+use File::Temp 0.19 (); # 0.19 for ->newdir
 use Fcntl qw(SEEK_SET);
 use PublicInbox::Git qw(git_unquote git_quote);
 use PublicInbox::MsgIter qw(msg_iter msg_part_text);
diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm
index 6eea2b9c..1c74a596 100644
--- a/lib/PublicInbox/Spawn.pm
+++ b/lib/PublicInbox/Spawn.pm
@@ -15,7 +15,6 @@ use strict;
 use warnings;
 use base qw(Exporter);
 use Symbol qw(gensym);
-use IO::Handle;
 use PublicInbox::ProcessPipe;
 our @EXPORT_OK = qw/which spawn popen_rd/;
 sub RLIMITS () { qw(RLIMIT_CPU RLIMIT_CORE RLIMIT_DATA) }
diff --git a/lib/PublicInbox/TLS.pm b/lib/PublicInbox/TLS.pm
index 0b9a55df..1bbb229a 100644
--- a/lib/PublicInbox/TLS.pm
+++ b/lib/PublicInbox/TLS.pm
@@ -5,8 +5,6 @@
 package PublicInbox::TLS;
 use strict;
 use IO::Socket::SSL;
-require Carp;
-use Errno qw(EAGAIN);
 use PublicInbox::Syscall qw(EPOLLIN EPOLLOUT);
 
 sub err () { $SSL_ERROR }
diff --git a/lib/PublicInbox/Tmpfile.pm b/lib/PublicInbox/Tmpfile.pm
index 28e87f88..05f359d8 100644
--- a/lib/PublicInbox/Tmpfile.pm
+++ b/lib/PublicInbox/Tmpfile.pm
@@ -7,7 +7,7 @@ use base qw(Exporter);
 our @EXPORT = qw(tmpfile);
 use Fcntl qw(:DEFAULT);
 use Errno qw(EEXIST);
-require File::Spec;
+use File::Spec;
 
 # use tmpfile instead of open(..., '+>', undef) so we can get an
 # unlinked filename which makes sense when viewed with lsof
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index c614e20c..6021de44 100644
--- a/lib/PublicInbox/V2Writable.pm
+++ b/lib/PublicInbox/V2Writable.pm
@@ -18,7 +18,7 @@ use PublicInbox::OverIdx;
 use PublicInbox::Msgmap;
 use PublicInbox::Spawn qw(spawn);
 use PublicInbox::SearchIdx;
-use IO::Handle;
+use IO::Handle; # ->autoflush
 use File::Temp qw(tempfile);
 
 # an estimate of the post-packed size to the raw uncompressed size
diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm
index 4d72eb48..10d71004 100644
--- a/lib/PublicInbox/ViewDiff.pm
+++ b/lib/PublicInbox/ViewDiff.pm
@@ -12,7 +12,7 @@ use warnings;
 use base qw(Exporter);
 our @EXPORT_OK = qw(flush_diff);
 use URI::Escape qw(uri_escape_utf8);
-use PublicInbox::Hval qw(ascii_html to_attr from_attr);
+use PublicInbox::Hval qw(ascii_html to_attr);
 use PublicInbox::Git qw(git_unquote);
 
 # keep track of state so we can avoid redundant HTML tags for
diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index 7803b58a..8a8c1262 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -9,7 +9,7 @@ use warnings;
 use PublicInbox::MIME;
 use PublicInbox::Spawn qw(spawn);
 use PublicInbox::InboxWritable;
-use File::Temp 0.19 ();
+use File::Temp 0.19 (); # 0.19 for ->newdir
 use PublicInbox::Filter::Base qw(REJECT);
 use PublicInbox::Spamcheck;
 *maildir_path_load = *PublicInbox::InboxWritable::maildir_path_load;
diff --git a/lib/PublicInbox/WwwAtomStream.pm b/lib/PublicInbox/WwwAtomStream.pm
index 84060cfa..9430dd97 100644
--- a/lib/PublicInbox/WwwAtomStream.pm
+++ b/lib/PublicInbox/WwwAtomStream.pm
@@ -13,7 +13,7 @@ use POSIX qw(strftime);
 use Digest::SHA qw(sha1_hex);
 use PublicInbox::Address;
 use PublicInbox::Hval qw(ascii_html);
-use PublicInbox::MID qw/mid_clean mid_escape/;
+use PublicInbox::MID qw(mid_escape);
 use PublicInbox::MsgTime qw(msg_timestamp);
 
 # called by PSGI server after getline:
diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm
index 544242a3..4871378e 100644
--- a/lib/PublicInbox/Xapcmd.pm
+++ b/lib/PublicInbox/Xapcmd.pm
@@ -6,7 +6,7 @@ use warnings;
 use PublicInbox::Spawn qw(which spawn);
 use PublicInbox::Over;
 use PublicInbox::SearchIdx;
-use File::Temp ();
+use File::Temp 0.19 (); # ->newdir
 use File::Path qw(remove_tree);
 use File::Basename qw(dirname);
 use POSIX ();
diff --git a/script/public-inbox-convert b/script/public-inbox-convert
index 9bee5e7a..633c4cf8 100755
--- a/script/public-inbox-convert
+++ b/script/public-inbox-convert
@@ -4,11 +4,9 @@
 use strict;
 use warnings;
 use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
-use PublicInbox::MIME;
 use PublicInbox::InboxWritable;
 use PublicInbox::Config;
 use PublicInbox::V2Writable;
-use PublicInbox::Import;
 use PublicInbox::Spawn qw(spawn);
 use Cwd 'abs_path';
 use File::Copy 'cp'; # preserves permissions:
diff --git a/script/public-inbox-edit b/script/public-inbox-edit
index 2a9f0531..e408c7bc 100755
--- a/script/public-inbox-edit
+++ b/script/public-inbox-edit
@@ -8,13 +8,13 @@ use strict;
 use warnings;
 use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
 use PublicInbox::AdminEdit;
-use File::Temp 0.19 ();
+use File::Temp 0.19 (); # 0.19 for TMPDIR
 use PublicInbox::ContentId qw(content_id);
 use PublicInbox::MID qw(mid_clean mids);
 PublicInbox::Admin::check_require('-index');
-require PublicInbox::MIME;
-require PublicInbox::InboxWritable;
-require PublicInbox::Import;
+use PublicInbox::MIME;
+use PublicInbox::InboxWritable;
+use PublicInbox::Import;
 
 my $usage = "$0 -m MESSAGE_ID [--all] [INBOX_DIRS]";
 my $opt = { verbose => 1, all => 0, -min_inbox_version => 2, raw => 0 };
diff --git a/script/public-inbox-init b/script/public-inbox-init
index da683657..34c93b47 100755
--- a/script/public-inbox-init
+++ b/script/public-inbox-init
@@ -14,8 +14,8 @@ EOF
 use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
 use PublicInbox::Admin;
 PublicInbox::Admin::require_or_die('-base');
-require PublicInbox::Config;
-require PublicInbox::InboxWritable;
+use PublicInbox::Config;
+use PublicInbox::InboxWritable;
 use File::Temp qw/tempfile/;
 use PublicInbox::Lock;
 use File::Basename qw/dirname/;
diff --git a/script/public-inbox-nntpd b/script/public-inbox-nntpd
index 3c4be191..27c33f04 100755
--- a/script/public-inbox-nntpd
+++ b/script/public-inbox-nntpd
@@ -5,9 +5,9 @@
 # Standalone NNTP server for public-inbox.
 use strict;
 use warnings;
-require PublicInbox::Daemon;
+use PublicInbox::Daemon;
 use PublicInbox::NNTP; # need to call import
-require PublicInbox::NNTPD;
+use PublicInbox::NNTPD;
 my $nntpd = PublicInbox::NNTPD->new;
 PublicInbox::Daemon::run('0.0.0.0:119',
         sub { $nntpd->refresh_groups }, # refresh
diff --git a/t/cgi.t b/t/cgi.t
index 90543a7a..9f67d5c0 100644
--- a/t/cgi.t
+++ b/t/cgi.t
@@ -32,8 +32,6 @@ EOF
         close $fh or die "close: $!\n";
 }
 
-use_ok 'PublicInbox::Git';
-use_ok 'PublicInbox::Import';
 use_ok 'PublicInbox::Inbox';
 use_ok 'PublicInbox::InboxWritable';
 use_ok 'PublicInbox::Config';
diff --git a/t/feed.t b/t/feed.t
index b2a94487..ec8a5a42 100644
--- a/t/feed.t
+++ b/t/feed.t
@@ -5,9 +5,7 @@ use warnings;
 use Test::More;
 use Email::MIME;
 use PublicInbox::Feed;
-use PublicInbox::Git;
 use PublicInbox::Import;
-use PublicInbox::Config;
 use PublicInbox::Inbox;
 my $have_xml_feed = eval { require XML::Feed; 1 };
 use PublicInbox::TestCommon;