Browse Source

fix unused import detection and remove unused imports

Byron Jones 6 years ago
parent
commit
ab71d22a6e

+ 0 - 1
dev-inline-svg

@@ -4,7 +4,6 @@ use warnings;
 use local::lib;
 use v5.10;
 
-use Cwd qw( abs_path );
 use File::Find qw( find );
 use FindBin qw( $RealBin );
 use Mojo::File ();

+ 2 - 0
dev-precommit

@@ -224,6 +224,8 @@ sub find_unused_imports {
         }
     );
 
+    $input = join("\n", grep { !/^use\s/ } split(/\n/, $input));
+
     my @issues;
     foreach my $module (sort keys %modules) {
         next if $input =~ /\b$module(?:->|::)/;

+ 0 - 1
dev-server

@@ -4,7 +4,6 @@ use strict;
 use warnings;
 use v5.10;
 
-use File::Glob qw( bsd_glob );
 use Mojo::Server::Morbo ();
 use Time::HiRes qw( sleep );
 

+ 1 - 1
lib/LogBot/Config.pm

@@ -7,7 +7,7 @@ use warnings;
 use FindBin qw( $RealBin );
 use lib "$RealBin/lib";
 
-use File::Basename qw( basename dirname );
+use File::Basename qw( basename );
 use File::Path qw( make_path );
 use LogBot::Util qw( normalise_channel path_for squash_error timestamp );
 use Try::Tiny qw( catch try );

+ 0 - 1
lib/LogBot/Database.pm

@@ -7,7 +7,6 @@ use warnings;
 use FindBin qw( $RealBin );
 use lib "$RealBin/lib";
 
-use DBD::SQLite ();
 use DBD::SQLite::Constants qw( :file_open );
 use DBI ();
 use LogBot::Util qw( file_for squash_error timestamp );

+ 1 - 2
lib/LogBot/Util.pm

@@ -21,9 +21,8 @@ use parent 'Exporter';
 
 use Data::Dumper qw( Dumper );
 use DateTime ();
-use File::Basename qw( basename dirname );
+use File::Basename qw( basename );
 use File::Path qw( make_path );
-use FindBin qw( $RealBin );
 use List::Util qw( any );
 use POSIX qw( ceil floor );
 use Readonly;

+ 1 - 2
lib/LogBot/Web/Channel.pm

@@ -6,9 +6,8 @@ use warnings;
 
 use DateTime ();
 use Encode qw( decode );
-use List::Util qw( any );
 use LogBot::Database qw( dbh execute_with_timeout );
-use LogBot::Util qw( event_to_short_string nick_is_bot normalise_channel time_to_ymd );
+use LogBot::Util qw( event_to_short_string );
 use LogBot::Web::Util qw( preprocess_event );
 
 sub _get_logs {

+ 1 - 1
lib/LogBot/Web/Stats.pm

@@ -7,7 +7,7 @@ use warnings;
 use DateTime ();
 use JSON::XS qw( decode_json );
 use LogBot::Database qw( dbh );
-use LogBot::Util qw( commify file_for plural pretty_size slurp time_ago time_to_datetimestr );
+use LogBot::Util qw( commify file_for plural slurp time_to_datetimestr );
 use LogBot::Web::Util qw( irc_host );
 use Time::Duration qw( ago );
 

+ 0 - 1
lib/LogBot/Web/Util.pm

@@ -8,7 +8,6 @@ use Date::Parse qw( str2time );
 use DateTime ();
 use Digest::xxHash qw( xxhash32 );
 use Encode qw ( decode );
-use List::Util qw( any );
 use LogBot::Database qw( dbh );
 use LogBot::Util qw( nick_is_bot normalise_channel time_to_ymd ymd_to_time );
 use Mojo::Path ();

+ 2 - 5
logbot-consumer

@@ -12,14 +12,11 @@ use lib "$RealBin/lib";
 
 BEGIN { $ENV{TZ} = 'UTC' }
 
-use Data::Dumper qw( Dumper );
 use Encode qw( encode );
 use LogBot::Config qw( find_config load_config reload_config );
-use LogBot::Database qw( dbh dbh_disconnect execute_with_retry );
+use LogBot::Database qw( dbh execute_with_retry );
 use LogBot::JobQueue ();
-use LogBot::Util qw( event_to_string logbot_init squash_error timestamp );
-use Time::HiRes qw( sleep );
-use Try::Tiny qw( catch try );
+use LogBot::Util qw( event_to_string logbot_init timestamp );
 
 my $config = load_config(find_config(shift)) // die "syntax: logbot-consumer <config file>\n";
 logbot_init($config);

+ 2 - 3
logbot-nightly

@@ -14,12 +14,11 @@ BEGIN {
 }
 
 use DateTime ();
-use File::Path qw( make_path );
-use JSON ();
+use JSON     ();
 use JSON::XS qw( encode_json );
 use LogBot::Config qw( find_config load_all_configs load_config reload_config save_config );
 use LogBot::Database qw( dbh replace_sql_placeholders );
-use LogBot::Util qw( file_for logbot_init nick_is_bot path_for round spurt );
+use LogBot::Util qw( file_for logbot_init nick_is_bot round spurt );
 use LogBot::Web::Util qw( nick_hash );
 use Readonly;
 

+ 2 - 2
logbot-web

@@ -18,9 +18,9 @@ BEGIN { $ENV{TZ} = 'UTC' }
 
 use DateTime ();
 use IO::Compress::Gzip qw( gzip );
-use LogBot::Config qw( config_filename find_config load_all_configs load_config reload_config );
+use LogBot::Config qw( find_config load_all_configs load_config reload_config );
 use LogBot::MemCache ();
-use LogBot::Util qw( normalise_channel slurp spurt time_to_ymd ymd_to_time );
+use LogBot::Util qw( time_to_ymd );
 use LogBot::Web::Channel ();
 use LogBot::Web::Index   ();
 use LogBot::Web::List    ();