Browse Source

Merge pull request #362 from Troglodyne-Internet-Widgets/unused-code

Remove unused imports and variables, and enable both policies
George S. Baugh 1 week ago
parent
commit
d2bbe58ac1

+ 7 - 5
.perlcriticrc

@@ -102,12 +102,14 @@ exclude_functions = print
 [RequireQwForLiteralLists]
 [RequireQwForLiteralLists]
 #[ProhibitNoWarningsRedefine]
 #[ProhibitNoWarningsRedefine]
 [RequireFatalWarnings]
 [RequireFatalWarnings]
-#[ProhibitUnusedImports]
+[ProhibitUnusedImports]
 # Modules imported for a side effect rather than for a symbol, which the policy
 # Modules imported for a side effect rather than for a symbol, which the policy
 # cannot see.  `re` is here because every file says `use re '/aa'`.  Add your
 # cannot see.  `re` is here because every file says `use re '/aa'`.  Add your
 # own: IO::Prompter installs prompt() from a custom import rather than @EXPORT,
 # own: IO::Prompter installs prompt() from a custom import rather than @EXPORT,
 # and anything loaded by name from a string is invisible the same way.
 # and anything loaded by name from a string is invisible the same way.
-#allow = re
+# tCMS: Exporter, because use Exporter 'import' imports the method that perl
+# calls, which no line of the module names.
+allow = re Exporter
 # Off in a distribution that is only a library: it counts calls from bin/ and
 # Off in a distribution that is only a library: it counts calls from bin/ and
 # lib/, and every sub a library exists to offer is called from neither -- a
 # lib/, and every sub a library exists to offer is called from neither -- a
 # module with one public sub and no bin/ reports that sub, which is the policy
 # module with one public sub and no bin/ reports that sub, which is the policy
@@ -262,12 +264,12 @@ terminal_funcs = POSIX::_exit
 #[Variables::ProhibitReusedNames]
 #[Variables::ProhibitReusedNames]
 # Stricter than the core ProhibitUnusedVariables, which reports only a bare
 # Stricter than the core ProhibitUnusedVariables, which reports only a bare
 # `my $x;` and misses a variable that is assigned and never read.
 # `my $x;` and misses a variable that is assigned and never read.
-#[Variables::ProhibitUnusedVarsStricter]
+[Variables::ProhibitUnusedVarsStricter]
 # A method takes the arguments of its interface, whether it reads them or not.
 # A method takes the arguments of its interface, whether it reads them or not.
-#allow_unused_subroutine_arguments = 1
+allow_unused_subroutine_arguments = 1
 # Anything that returns a guard, which does its work by being held to the end of
 # Anything that returns a guard, which does its work by being held to the end of
 # its scope: a mock, a mocked file, a change of directory, a lock.
 # its scope: a mock, a mocked file, a change of directory, a lock.
-#allow_if_computed_by = Test::MockModule->new Test::MockFile->file
+allow_if_computed_by = Test::MockModule->new Test::MockFile->file
 [Variables::ProtectPrivateVars]
 [Variables::ProtectPrivateVars]
 [Variables::RequireLexicalLoopIterators]
 [Variables::RequireLexicalLoopIterators]
 #[Variables::RequireLocalizedPunctuationVars]
 #[Variables::RequireLocalizedPunctuationVars]

+ 0 - 1
bin/migrate.pl

@@ -4,7 +4,6 @@ use 5.040;
 use re '/aasx';
 use re '/aasx';
 use warnings FATAL => 'all';
 use warnings FATAL => 'all';
 
 
-use FindBin;
 use FindBin::libs;
 use FindBin::libs;
 
 
 use Getopt::Long qw{GetOptions};
 use Getopt::Long qw{GetOptions};

+ 1 - 1
bin/totp

@@ -38,7 +38,7 @@ my $domain = Trog::Config->get()->param('general.hostname');
 die "Must provide a user"                   unless $user;
 die "Must provide a user"                   unless $user;
 die "Must Set domain in configuration file" unless $domain;
 die "Must Set domain in configuration file" unless $domain;
 
 
-my ( $uri, $qr, $failure, $message, $totp ) = Trog::Auth::totp( $user, $domain );
+my ( $uri, undef, undef, undef, $totp ) = Trog::Auth::totp( $user, $domain );
 print "TOTP URI: $uri\n";
 print "TOTP URI: $uri\n";
 print "Secret: " . $totp->base32secret() . "\n";
 print "Secret: " . $totp->base32secret() . "\n";
 print "Current Auth code: " . $totp->expected_totp_code(time) . "\n";
 print "Current Auth code: " . $totp->expected_totp_code(time) . "\n";

+ 4 - 17
lib/TCMS.pm

@@ -4,21 +4,11 @@ use 5.040;
 use re '/aasx';
 use re '/aasx';
 use warnings FATAL => 'all';
 use warnings FATAL => 'all';
 
 
-use Carp         qw{confess};
-use Clone        qw{clone};
-use Date::Format qw{strftime};
-
-use Sys::Hostname();
-use HTTP::Body   ();
-use URL::Encode  ();
-use Text::Xslate ();
-use DateTime::Format::HTTP();
+use Carp  qw{confess};
+use Clone qw{clone};
+
 use CGI::Cookie ();
 use CGI::Cookie ();
-use File::Basename();
-use Time::HiRes qw{gettimeofday tv_interval};
-use List::Util;
 use URI();
 use URI();
-use Ref::Util qw{is_coderef is_hashref is_arrayref};
 
 
 #Grab our custom routes
 #Grab our custom routes
 use FindBin::libs;
 use FindBin::libs;
@@ -35,14 +25,12 @@ use Trog::Config;
 # Loaded here rather than where it is used, so that the vault key comes out of
 # Loaded here rather than where it is used, so that the vault key comes out of
 # the environment once, in the parent, before there is a worker to fork -- see
 # the environment once, in the parent, before there is a worker to fork -- see
 # Trog::Vault.
 # Trog::Vault.
-use Trog::Vault;
+use Trog::Vault;    ## no critic (ProhibitUnusedImports) -- loaded for what it does at load time, as above
 use Trog::Data;
 use Trog::Data;
 use Trog::Themes;
 use Trog::Themes;
 
 
 # Troglodyne philosophy - simple as possible
 # Troglodyne philosophy - simple as possible
 
 
-my $cur_query = {};
-
 # Build routes
 # Build routes
 sub build_routes {
 sub build_routes {
     my $conf   = Trog::Config::get();
     my $conf   = Trog::Config::get();
@@ -64,7 +52,6 @@ sub build_routes {
         }
         }
 
 
         my %cb;
         my %cb;
-        my $method   = $v->{method};
         my $callback = delete $v->{callback};
         my $callback = delete $v->{callback};
 
 
         #XXX For now we will discard the tPSGI object.  We might want it later.
         #XXX For now we will discard the tPSGI object.  We might want it later.

+ 1 - 1
lib/Trog/Component/EmojiPicker.pm

@@ -35,7 +35,7 @@ to be composed into a page by their caller.
 
 
 =cut
 =cut
 
 
-sub render (%args) {
+sub render {
     state %categorized;
     state %categorized;
 
 
     if ( !%categorized ) {
     if ( !%categorized ) {

+ 1 - 1
lib/Trog/Data.pm

@@ -20,7 +20,7 @@ Memoized: every call after the first returns the first handle, whatever it is pa
 
 
 =cut
 =cut
 
 
-sub new ( $class, $config ) {
+sub new ( $, $config ) {
     state $datamodule;
     state $datamodule;
     return $datamodule if $datamodule;
     return $datamodule if $datamodule;
 
 

+ 3 - 4
lib/Trog/Data/DUMMY.pm

@@ -10,8 +10,7 @@ use Fcntl qw{O_WRONLY O_CREAT O_EXCL};
 use JSON::MaybeXS;
 use JSON::MaybeXS;
 use File::Slurper;
 use File::Slurper;
 use List::Util qw{uniq};
 use List::Util qw{uniq};
-use Path::Tiny();
-use parent qw{Trog::DataModule};
+use parent     qw{Trog::DataModule};
 
 
 =head1 WARNING
 =head1 WARNING
 
 
@@ -25,7 +24,7 @@ sub help { return 'https://perldoc.perl.org/functions/quotemeta.html' }
 
 
 our $posts;
 our $posts;
 
 
-sub read ( $self, $query = {} ) {
+sub read {
 
 
     # Seed an empty datastore, as one operation rather than a test followed by
     # Seed an empty datastore, as one operation rather than a test followed by
     # a create.  O_EXCL means a file that appeared in between is left alone
     # a create.  O_EXCL means a file that appeared in between is left alone
@@ -78,7 +77,7 @@ sub delete ( $self, @posts ) {
     return 0;
     return 0;
 }
 }
 
 
-sub tags ($self) {
+sub tags {
     return ( uniq map { @{ $_->{tags} } } @$posts );
     return ( uniq map { @{ $_->{tags} } } @$posts );
 }
 }
 
 

+ 5 - 7
lib/Trog/Data/FlatFile.pm

@@ -11,8 +11,6 @@ use File::Path     ();
 use JSON::MaybeXS;
 use JSON::MaybeXS;
 use File::Slurper;
 use File::Slurper;
 use File::Slurper::Temp();
 use File::Slurper::Temp();
-use File::Copy;
-use Path::Tiny();
 use Capture::Tiny qw{capture_merged};
 use Capture::Tiny qw{capture_merged};
 
 
 use Trog::Log qw{:all};
 use Trog::Log qw{:all};
@@ -120,7 +118,7 @@ sub read ( $self, $query = {} ) {
     return \@items;
     return \@items;
 }
 }
 
 
-sub _index ($self) {
+sub _index {
     confess "Can't find datastore in $datastore !" unless -d $datastore;
     confess "Can't find datastore in $datastore !" unless -d $datastore;
     opendir( my $dh, $datastore ) or confess;
     opendir( my $dh, $datastore ) or confess;
     my @index = grep { -f } map { "$datastore/$_" } readdir $dh;    ## no critic (ProhibitFiletest_f) -- listing names, nothing is opened
     my @index = grep { -f } map { "$datastore/$_" } readdir $dh;    ## no critic (ProhibitFiletest_f) -- listing names, nothing is opened
@@ -128,11 +126,11 @@ sub _index ($self) {
     return sort { $b cmp $a } @index;
     return sort { $b cmp $a } @index;
 }
 }
 
 
-sub routes ($self) {
+sub routes {
     return Trog::SQLite::TagIndex::routes();
     return Trog::SQLite::TagIndex::routes();
 }
 }
 
 
-sub aliases ($self) {
+sub aliases {
     return Trog::SQLite::TagIndex::aliases();
     return Trog::SQLite::TagIndex::aliases();
 }
 }
 
 
@@ -189,7 +187,7 @@ sub count ($self) {
     return scalar(@index);
     return scalar(@index);
 }
 }
 
 
-sub delete ( $self, @posts ) {
+sub delete ( $, @posts ) {
     foreach my $update (@posts) {
     foreach my $update (@posts) {
         unlink "$datastore/$update->{id}" or confess;
         unlink "$datastore/$update->{id}" or confess;
         Trog::SQLite::TagIndex::remove_post($update);
         Trog::SQLite::TagIndex::remove_post($update);
@@ -198,7 +196,7 @@ sub delete ( $self, @posts ) {
     return 0;
     return 0;
 }
 }
 
 
-sub tags ($self) {
+sub tags {
     return Trog::SQLite::TagIndex::tags();
     return Trog::SQLite::TagIndex::tags();
 }
 }
 
 

+ 7 - 7
lib/Trog/Data/SQLite.pm

@@ -85,7 +85,7 @@ that Trog::DataModule::_dedup_versions() would have computed by hand.
 
 
 =cut
 =cut
 
 
-sub read ( $self, $query = {} ) {
+sub read ( $, $query = {} ) {
     my ( $sql, @bind ) = _build_query($query) or return [];
     my ( $sql, @bind ) = _build_query($query) or return [];
 
 
     my $rows = _dbh()->selectall_arrayref( $sql, { Slice => {} }, @bind );
     my $rows = _dbh()->selectall_arrayref( $sql, { Slice => {} }, @bind );
@@ -318,7 +318,7 @@ and taking minutes, since SQLite otherwise commits once per row.
 
 
 =cut
 =cut
 
 
-sub write ( $self, $data ) {
+sub write ( $, $data ) {
     my $dbh = _dbh();
     my $dbh = _dbh();
 
 
     Trog::SQLite::transaction( $dbh, sub { _insert( $dbh, $data ) } );
     Trog::SQLite::transaction( $dbh, sub { _insert( $dbh, $data ) } );
@@ -356,7 +356,7 @@ whether it has seen it before.  See bin/migrate.pl.
 
 
 =cut
 =cut
 
 
-sub versions_present ($self) {
+sub versions_present {
     my $rows = _dbh()->selectall_arrayref( 'SELECT uuid, version FROM posts', { Slice => {} } ) // [];
     my $rows = _dbh()->selectall_arrayref( 'SELECT uuid, version FROM posts', { Slice => {} } ) // [];
 
 
     my %present;
     my %present;
@@ -371,7 +371,7 @@ and the search index with them.
 
 
 =cut
 =cut
 
 
-sub delete ( $self, @posts ) {
+sub delete ( $, @posts ) {
     my $dbh    = _dbh();
     my $dbh    = _dbh();
     my $delete = $dbh->prepare('DELETE FROM posts WHERE uuid = ?');
     my $delete = $dbh->prepare('DELETE FROM posts WHERE uuid = ?');
 
 
@@ -386,7 +386,7 @@ How many posts there are, counting a post once however many versions it has.
 
 
 =cut
 =cut
 
 
-sub count ($self) {
+sub count {
     my ($count) = _dbh()->selectrow_array('SELECT COUNT(DISTINCT uuid) FROM posts');
     my ($count) = _dbh()->selectrow_array('SELECT COUNT(DISTINCT uuid) FROM posts');
     return $count // 0;
     return $count // 0;
 }
 }
@@ -423,7 +423,7 @@ our $index_prefix = 'posts_custom_';
 # all, and it is what stops "index this field" quietly indexing the blob.
 # all, and it is what stops "index this field" quietly indexing the blob.
 our %reserved = map { $_ => 1 } qw{id post_data uuid version created title user author form aclname visibility local_href data};
 our %reserved = map { $_ => 1 } qw{id post_data uuid version created title user author form aclname visibility local_href data};
 
 
-sub index_fields ( $self, @fields ) {
+sub index_fields ( $, @fields ) {
     my $dbh = _dbh();
     my $dbh = _dbh();
 
 
     my %want;
     my %want;
@@ -491,7 +491,7 @@ Every tag in use, from the index the schema's triggers maintain.
 
 
 =cut
 =cut
 
 
-sub tags ($self) {
+sub tags {
     my $rows = _dbh()->selectall_arrayref( 'SELECT DISTINCT tag FROM post_tags ORDER BY tag', { Slice => {} } );
     my $rows = _dbh()->selectall_arrayref( 'SELECT DISTINCT tag FROM post_tags ORDER BY tag', { Slice => {} } );
     return () unless ref $rows eq 'ARRAY';
     return () unless ref $rows eq 'ARRAY';
     return map { $_->{tag} } @$rows;
     return map { $_->{tag} } @$rows;

+ 11 - 13
lib/Trog/DataModule.pm

@@ -8,7 +8,6 @@ use FindBin::libs;
 
 
 use List::Util;
 use List::Util;
 use File::Copy;
 use File::Copy;
-use Path::Tiny();
 use Ref::Util();
 use Ref::Util();
 use File::Basename qw{basename};
 use File::Basename qw{basename};
 use File::Slurper();
 use File::Slurper();
@@ -87,12 +86,12 @@ Every tag known to the datastore, for building tag pickers.
 =cut
 =cut
 
 
 #It is required that subclasses implement this
 #It is required that subclasses implement this
-sub lang  ($self)                { ... }
-sub help  ($self)                { ... }
-sub read  ( $self, $query = {} ) { ... }
-sub write ($self)                { ... }
-sub count ($self)                { ... }
-sub tags  ($self)                { ... }
+sub lang  { ... }
+sub help  { ... }
+sub read  { ... }
+sub write { ... }
+sub count { ... }
+sub tags  { ... }
 
 
 =head1 METHODS
 =head1 METHODS
 
 
@@ -132,7 +131,7 @@ sub get ( $self, %request ) {
     return @filtered;
     return @filtered;
 }
 }
 
 
-sub _fixup ( $self, @filtered ) {
+sub _fixup ( $, @filtered ) {
 
 
     my %user2display;
     my %user2display;
 
 
@@ -205,7 +204,7 @@ holds one of its acls, or the post is public or unlisted.  Callers holding the
 
 
 =cut
 =cut
 
 
-sub filter ( $self, $query, @filtered ) {
+sub filter ( $, $query, @filtered ) {
     $query->{acls}         //= [];
     $query->{acls}         //= [];
     $query->{tags}         //= [];
     $query->{tags}         //= [];
     $query->{exclude_tags} //= [];
     $query->{exclude_tags} //= [];
@@ -266,7 +265,7 @@ present to page at all; limit defaults to 25 when computing the offset.
 
 
 =cut
 =cut
 
 
-sub paginate ( $self, $query, @filtered ) {
+sub paginate ( $, $query, @filtered ) {
     return @filtered unless $query->{page} && $query->{limit};
     return @filtered unless $query->{page} && $query->{limit};
 
 
     my $offset = int( $query->{limit} // 25 );
     my $offset = int( $query->{limit} // 25 );
@@ -608,7 +607,7 @@ what is no longer asked for.
 
 
 =cut
 =cut
 
 
-sub index_fields ( $self, @fields ) { return 0 }
+sub index_fields { return 0 }
 
 
 =head2 relations_for($form)
 =head2 relations_for($form)
 
 
@@ -964,7 +963,6 @@ my %seen_files;
 sub _handle_upload ( $file, $uuid, $private = 0 ) {
 sub _handle_upload ( $file, $uuid, $private = 0 ) {
     my $fname;
     my $fname;
     if ( ref $file ne 'HASH' ) {
     if ( ref $file ne 'HASH' ) {
-        use Data::Dumper;
         $file =~ s/\\/\//g;
         $file =~ s/\\/\//g;
         $fname = basename($file);
         $fname = basename($file);
         FATAL("Did not expect bogus file before its real counterpart!") unless $seen_files{$fname};
         FATAL("Did not expect bogus file before its real counterpart!") unless $seen_files{$fname};
@@ -991,7 +989,7 @@ You should override this, it is a stub here.
 
 
 =cut
 =cut
 
 
-sub delete ($self) { die 'stub' }
+sub delete { die 'stub' }
 
 
 =head2 routes() = HASH
 =head2 routes() = HASH
 
 

+ 1 - 1
lib/Trog/DataSource.pm

@@ -163,7 +163,7 @@ the same created, so what this really does for that page is sort it by name.
 
 
 =cut
 =cut
 
 
-sub order ( $query, @posts ) {
+sub order ( $, @posts ) {
     return sort { ( $b->{created} // 0 ) <=> ( $a->{created} // 0 ) || ( $a->{title} // '' ) cmp ( $b->{title} // '' ) || ( $a->{id} // '' ) cmp ( $b->{id} // '' ) } @posts;
     return sort { ( $b->{created} // 0 ) <=> ( $a->{created} // 0 ) || ( $a->{title} // '' ) cmp ( $b->{title} // '' ) || ( $a->{id} // '' ) cmp ( $b->{id} // '' ) } @posts;
 }
 }
 
 

+ 4 - 5
lib/Trog/DataSource/DirIndex.pm

@@ -4,10 +4,9 @@ use 5.040;
 use re '/aasx';
 use re '/aasx';
 use warnings FATAL => 'all';
 use warnings FATAL => 'all';
 
 
-use Cwd            ();
-use Digest::SHA    qw{sha256_hex};
-use File::Basename ();
-use URI::Escape    ();
+use Cwd         ();
+use Digest::SHA qw{sha256_hex};
+use URI::Escape ();
 
 
 use Trog::DataSource ();
 use Trog::DataSource ();
 use Trog::Utils      ();
 use Trog::Utils      ();
@@ -322,7 +321,7 @@ whatever happened to be touched least recently.
 
 
 =cut
 =cut
 
 
-sub order ( $query, @posts ) {
+sub order ( $, @posts ) {
     return sort { ( $b->{is_dir} // 0 ) <=> ( $a->{is_dir} // 0 ) || lc( $a->{name} // '' ) cmp lc( $b->{name} // '' ) || ( $a->{name} // '' ) cmp ( $b->{name} // '' ) } @posts;
     return sort { ( $b->{is_dir} // 0 ) <=> ( $a->{is_dir} // 0 ) || lc( $a->{name} // '' ) cmp lc( $b->{name} // '' ) || ( $a->{name} // '' ) cmp ( $b->{name} // '' ) } @posts;
 }
 }
 
 

+ 0 - 1
lib/Trog/DataSource/ProvisionedVirt.pm

@@ -7,7 +7,6 @@ use warnings FATAL => 'all';
 use parent qw{Trog::DataSource::Virt};
 use parent qw{Trog::DataSource::Virt};
 
 
 use Cwd                 ();
 use Cwd                 ();
-use File::Basename      ();
 use File::Path          ();
 use File::Path          ();
 use File::Slurper       ();
 use File::Slurper       ();
 use File::Slurper::Temp ();
 use File::Slurper::Temp ();

+ 1 - 1
lib/Trog/DataSource/Virt.pm

@@ -158,7 +158,7 @@ one that tells you the connection is broken.
 
 
 =cut
 =cut
 
 
-sub posts ( $series, $query ) {
+sub posts ( $series, $ ) {
     my $hypervisors = $series->{ $series->{'x-tcms-datasource-relation'} // 'hypervisors' };
     my $hypervisors = $series->{ $series->{'x-tcms-datasource-relation'} // 'hypervisors' };
     return () unless ref $hypervisors eq 'ARRAY';
     return () unless ref $hypervisors eq 'ARRAY';
 
 

+ 1 - 1
lib/Trog/Enrich/Invoice.pm

@@ -22,7 +22,7 @@ denomination is taken from the first one that has any.
 
 
 =cut
 =cut
 
 
-sub enrich ( $post, $query ) {
+sub enrich ( $post, $ ) {
     return () unless ref $post->{data} eq 'ARRAY';
     return () unless ref $post->{data} eq 'ARRAY';
 
 
     my $denomination;
     my $denomination;

+ 0 - 1
lib/Trog/Log.pm

@@ -7,7 +7,6 @@ use warnings FATAL => 'all';
 use POSIX qw{strftime};
 use POSIX qw{strftime};
 use Module::Runtime();
 use Module::Runtime();
 use Log::Dispatch;
 use Log::Dispatch;
-use Log::Dispatch::DBI;
 use Log::Dispatch::Screen;
 use Log::Dispatch::Screen;
 use Log::Dispatch::FileRotate;
 use Log::Dispatch::FileRotate;
 use File::Basename qw{dirname};
 use File::Basename qw{dirname};

+ 1 - 1
lib/Trog/Log/DBI.pm

@@ -83,7 +83,7 @@ sub log_message {
     # Rip apart the message.  If it's got any extended info, lets grab that too.
     # Rip apart the message.  If it's got any extended info, lets grab that too.
     my $msg = $params{message};
     my $msg = $params{message};
     my $message;
     my $message;
-    my ( $date, $uuid, $ip, $user, $method, $code, $bytes, $route ) = $msg =~ m!^([\w|\-|:]+)[ ]\[INFO\]:[ ]RequestId[ ]([\w|\-]+)[ ]From[ ]([\w|\.|:]+)[ ]\|(\w+)\|[ ](\w+)[ ](\d+)[ ](\d+)[ ](\N+)!;
+    my ( $date, $uuid, $ip, $user, $method, $code, undef, $route ) = $msg =~ m!^([\w|\-|:]+)[ ]\[INFO\]:[ ]RequestId[ ]([\w|\-]+)[ ]From[ ]([\w|\.|:]+)[ ]\|(\w+)\|[ ](\w+)[ ](\d+)[ ](\d+)[ ](\N+)!;
 
 
     # Otherwise, let's mark it down in the "messages" table.  This will be deferred until the final write.
     # Otherwise, let's mark it down in the "messages" table.  This will be deferred until the final write.
     if ( !$date ) {
     if ( !$date ) {

+ 0 - 1
lib/Trog/Log/Metrics.pm

@@ -4,7 +4,6 @@ use 5.040;
 use re '/aasx';
 use re '/aasx';
 use warnings FATAL => 'all';
 use warnings FATAL => 'all';
 
 
-use Trog::SQLite;
 use Trog::Log;
 use Trog::Log;
 
 
 =head1 Trog::Log::Metrics
 =head1 Trog::Log::Metrics

+ 1 - 1
lib/Trog/Renderer.pm

@@ -43,7 +43,7 @@ The idea is that components will be concatenated to other rendered templates unt
 
 
 =cut
 =cut
 
 
-sub render ( $class, %options ) {
+sub render ( $, %options ) {
     local $@;
     local $@;
     my $renderer;
     my $renderer;
     return _yeet( $renderer, "Renderer requires a valid content type to be passed", %options ) unless $options{contenttype};
     return _yeet( $renderer, "Renderer requires a valid content type to be passed", %options ) unless $options{contenttype};

+ 0 - 2
lib/Trog/Renderer/email.pm

@@ -6,8 +6,6 @@ use warnings FATAL => 'all';
 
 
 use parent qw{Trog::Renderer::Base};
 use parent qw{Trog::Renderer::Base};
 
 
-use Text::Xslate;
-use Trog::Themes;
 use Trog::Renderer::html;
 use Trog::Renderer::html;
 
 
 =head1 Trog::Renderer::email
 =head1 Trog::Renderer::email

+ 0 - 4
lib/Trog/Renderer/text.pm

@@ -6,10 +6,6 @@ use warnings FATAL => 'all';
 
 
 use parent qw{Trog::Renderer::Base};
 use parent qw{Trog::Renderer::Base};
 
 
-use Text::Xslate;
-
-use Trog::Themes;
-
 =head1 Trog::Renderer::text
 =head1 Trog::Renderer::text
 
 
 Render plain text.  Can be used for email as well.
 Render plain text.  Can be used for email as well.

+ 1 - 10
lib/Trog/Routes/HTML.pm

@@ -23,7 +23,6 @@ use Digest::SHA qw{sha256_hex};
 use JSON::MaybeXS();
 use JSON::MaybeXS();
 use IO::Compress::Gzip;
 use IO::Compress::Gzip;
 use Path::Tiny();
 use Path::Tiny();
-use File::Basename qw{dirname};
 use URI();
 use URI();
 use URI::Escape();
 use URI::Escape();
 
 
@@ -34,7 +33,6 @@ use Trog::Utils;
 use Trog::Config;
 use Trog::Config;
 use Trog::Auth;
 use Trog::Auth;
 use Trog::Data;
 use Trog::Data;
-use Trog::FileHandler;
 use Trog::Themes;
 use Trog::Themes;
 use Trog::Renderer;
 use Trog::Renderer;
 use Trog::Email;
 use Trog::Email;
@@ -666,7 +664,6 @@ sub login ($query) {
     my $btnmsg   = $hasusers ? "Log In" : "Register";
     my $btnmsg   = $hasusers ? "Log In" : "Register";
 
 
     my $headers;
     my $headers;
-    my $has_totp = 0;
     if ( $query->{username} && $query->{password} ) {
     if ( $query->{username} && $query->{password} ) {
         if ( !$hasusers ) {
         if ( !$hasusers ) {
 
 
@@ -1241,9 +1238,6 @@ sub post_save ($qq) {
 
 
     my $to = delete $query->{to};
     my $to = delete $query->{to};
 
 
-    #Copy this down since it will be deleted later
-    my $acls = $query->{acls};
-
     $query->{tags} = Trog::Utils::coerce_array( $query->{tags} );
     $query->{tags} = Trog::Utils::coerce_array( $query->{tags} );
 
 
     # Support data with multiple pages like presentations
     # Support data with multiple pages like presentations
@@ -1699,9 +1693,6 @@ sub posts ( $query, $direct = 0 ) {
 
 
     return _rss( $query, $ph, \@posts ) if $fmt eq 'rss';
     return _rss( $query, $ph, \@posts ) if $fmt eq 'rss';
 
 
-    #XXX Is used by the sitemap, maybe just fix there?
-    my @post_aliases = map { $_->{local_href} } _get_series();
-
     # List the available headers/footers
     # List the available headers/footers
     my $headers = Trog::Themes::themed_templates_in_dir( "headers", 'text/html', 1 );
     my $headers = Trog::Themes::themed_templates_in_dir( "headers", 'text/html', 1 );
     my $footers = Trog::Themes::themed_templates_in_dir( "footers", 'text/html', 1 );
     my $footers = Trog::Themes::themed_templates_in_dir( "footers", 'text/html', 1 );
@@ -2332,7 +2323,7 @@ about whether the account existed.
 
 
 =cut
 =cut
 
 
-sub processed ($query) {
+sub processed {
     return Trog::Routes::HTML::index(
     return Trog::Routes::HTML::index(
         {
         {
             title     => "Your request has been processed",
             title     => "Your request has been processed",

+ 4 - 8
lib/Trog/Routes/JSON.pm

@@ -5,12 +5,10 @@ use re '/aasx';
 use warnings FATAL => 'all';
 use warnings FATAL => 'all';
 
 
 use Clone qw{clone};
 use Clone qw{clone};
-use JSON::MaybeXS();
 
 
 use Scalar::Util();
 use Scalar::Util();
 
 
 use Trog::Utils();
 use Trog::Utils();
-use Trog::Config();
 use Trog::Auth();
 use Trog::Auth();
 use Trog::Routes::HTML();
 use Trog::Routes::HTML();
 
 
@@ -77,24 +75,22 @@ foreach my $r ( keys(%$cloned) ) {
     delete $cloned->{$r}{callback};
     delete $cloned->{$r}{callback};
 }
 }
 
 
-my $enc = JSON::MaybeXS->new( utf8 => 1 );
-
 # Note to authors, don't forget to update this
 # Note to authors, don't forget to update this
 sub _version () {
 sub _version () {
     return '1.0';
     return '1.0';
 }
 }
 
 
 # Special case of a non data-structure JSON return
 # Special case of a non data-structure JSON return
-sub version ($query) {
+sub version {
     state $ret = [ 200, [ 'Content-type' => "application/json", ETag => 'version-' . _version() ], [ _version() ] ];
     state $ret = [ 200, [ 'Content-type' => "application/json", ETag => 'version-' . _version() ], [ _version() ] ];
     return $ret;
     return $ret;
 }
 }
 
 
-sub catalog ($query) {
+sub catalog {
     return _render( 200, { ETag => 'catalog-' . _version() }, %$cloned );
     return _render( 200, { ETag => 'catalog-' . _version() }, %$cloned );
 }
 }
 
 
-sub webmanifest ($query) {
+sub webmanifest {
     state $headers = { ETag => 'manifest-' . _version() };
     state $headers = { ETag => 'manifest-' . _version() };
     my $theme_dir = Trog::Themes::get_dir();
     my $theme_dir = Trog::Themes::get_dir();
     state %manifest = (
     state %manifest = (
@@ -155,7 +151,7 @@ sub requests_per ($query) {
 
 
 sub _render ( $code, $headers, %data ) {
 sub _render ( $code, $headers, %data ) {
     return Trog::Renderer->render(
     return Trog::Renderer->render(
-        code        => 200,
+        code        => $code,
         data        => \%data,
         data        => \%data,
         template    => 'bogus.tx',
         template    => 'bogus.tx',
         contenttype => 'application/json',
         contenttype => 'application/json',

+ 1 - 11
lib/Trog/Routes/TXT.pm

@@ -4,17 +4,7 @@ use 5.040;
 use re '/aasx';
 use re '/aasx';
 use warnings FATAL => 'all';
 use warnings FATAL => 'all';
 
 
-use Clone qw{clone};
-use JSON::MaybeXS();
-
-use Scalar::Util();
-
-use Trog::Utils();
 use Trog::Config();
 use Trog::Config();
-use Trog::Auth();
-use Trog::Routes::HTML();
-
-use Trog::Log::Metrics();
 
 
 my $conf = Trog::Config::get();
 my $conf = Trog::Config::get();
 
 
@@ -74,7 +64,7 @@ sub zone ($query) {
 
 
 sub _render ( $code, $headers, %data ) {
 sub _render ( $code, $headers, %data ) {
     return Trog::Renderer->render(
     return Trog::Renderer->render(
-        code        => 200,
+        code        => $code,
         data        => \%data,
         data        => \%data,
         template    => 'zone.tx',
         template    => 'zone.tx',
         contenttype => 'text/plain',
         contenttype => 'text/plain',

+ 0 - 4
lib/Trog/Utils.pm

@@ -5,15 +5,11 @@ use re '/aasx';
 use warnings FATAL => 'all';
 use warnings FATAL => 'all';
 
 
 use UUID;
 use UUID;
-use HTTP::Tiny::UNIX();
 use Plack::MIME;
 use Plack::MIME;
 use Mojo::File;
 use Mojo::File;
 use File::LibMagic;
 use File::LibMagic;
 use Ref::Util qw{is_hashref};
 use Ref::Util qw{is_hashref};
 
 
-use Trog::Log qw{WARN};
-use Trog::Config();
-
 =head1 Trog::Utils
 =head1 Trog::Utils
 
 
 Odds and ends which are needed in more than one place and belong to no
 Odds and ends which are needed in more than one place and belong to no

+ 0 - 1
t/Trog-Auth-libravatar.t

@@ -4,7 +4,6 @@ use warnings FATAL => 'all';
 
 
 use Test::More;
 use Test::More;
 use Test::MockModule qw{strict};
 use Test::MockModule qw{strict};
-use FindBin;
 
 
 use FindBin::libs;
 use FindBin::libs;
 
 

+ 1 - 1
t/Trog-Auth-totp-mandatory.t

@@ -82,7 +82,7 @@ subtest 'and cannot go anywhere but /totp until they enrol' => sub {
     # Nothing to enrol, and nothing to protect.
     # Nothing to enrol, and nothing to protect.
     is( TCMS::needs_enrolment( '', \%page ), 0, 'a logged out visitor is left alone' );
     is( TCMS::needs_enrolment( '', \%page ), 0, 'a logged out visitor is left alone' );
 
 
-    my ( $uri, $qr, $failure, $message ) = Trog::Auth::totp( 'bob', 'totp.example.com' );
+    my ( $uri, undef, undef, $message ) = Trog::Auth::totp( 'bob', 'totp.example.com' );
     ok( $uri, 'enrolling gives them a URI' ) or diag($message);
     ok( $uri, 'enrolling gives them a URI' ) or diag($message);
     is( Trog::Auth::has_totp('bob'), 1, 'and they are enrolled' );
     is( Trog::Auth::has_totp('bob'), 1, 'and they are enrolled' );
 
 

+ 1 - 2
t/Trog-Component-page.t

@@ -3,8 +3,7 @@ use re '/aasx';
 use warnings FATAL => 'all';
 use warnings FATAL => 'all';
 
 
 use Test::More;
 use Test::More;
-use Test::MockModule qw{strict};
-use Test::Fatal      qw{exception};
+use Test::Fatal qw{exception};
 use FindBin;
 use FindBin;
 
 
 use FindBin::libs;
 use FindBin::libs;

+ 0 - 1
t/Trog-Component.t

@@ -4,7 +4,6 @@ use warnings FATAL => 'all';
 
 
 use Test::More;
 use Test::More;
 use Test::Fatal qw{exception};
 use Test::Fatal qw{exception};
-use FindBin;
 
 
 use FindBin::libs;
 use FindBin::libs;
 
 

+ 0 - 1
t/Trog-Config.t

@@ -7,7 +7,6 @@ use Cwd();
 use File::Path();
 use File::Path();
 use File::Temp();
 use File::Temp();
 use Path::Tiny();
 use Path::Tiny();
-use FindBin;
 
 
 use FindBin::libs;
 use FindBin::libs;
 
 

+ 0 - 1
t/Trog-Data.t

@@ -7,7 +7,6 @@ use Test::MockModule;
 use Config::Simple ();
 use Config::Simple ();
 use File::Temp     ();
 use File::Temp     ();
 use Path::Tiny     ();
 use Path::Tiny     ();
-use FindBin;
 
 
 use FindBin::libs;
 use FindBin::libs;
 
 

+ 0 - 1
t/Trog-DataModule-schema.t

@@ -9,7 +9,6 @@ use Test::Fatal qw{exception};
 use JSON::MaybeXS();
 use JSON::MaybeXS();
 use Path::Tiny();
 use Path::Tiny();
 use URI::Escape();
 use URI::Escape();
-use FindBin;
 use feature qw{signatures};
 use feature qw{signatures};
 no warnings qw{experimental::signatures};
 no warnings qw{experimental::signatures};
 
 

+ 3 - 4
t/Trog-DataSource-ProvisionedVirt.t

@@ -13,7 +13,6 @@ use FindBin::libs;
 
 
 use Test::More;
 use Test::More;
 use Test::MockModule qw{strict};
 use Test::MockModule qw{strict};
-use Test::Fatal      qw{exception};
 
 
 our ( $REPO, $ROOT, $OLDCWD );
 our ( $REPO, $ROOT, $OLDCWD );
 
 
@@ -246,7 +245,7 @@ subtest 'a stored passphrase, and a code instead of one' => sub {
 
 
     # And now the point of all of it: a code, spent, exchanged for what was
     # And now the point of all of it: a code, spent, exchanged for what was
     # stored.  Enrol first -- a code is only meaningful for somebody enrolled.
     # stored.  Enrol first -- a code is only meaningful for somebody enrolled.
-    my ( $uri, $qr, $failure, $message, $totp ) = Trog::Auth::totp( 'admin', 'example.com' );
+    my ( $uri, undef, undef, $message, $totp ) = Trog::Auth::totp( 'admin', 'example.com' );
     ok( $uri, 'the user is enrolled' ) or diag($message);
     ok( $uri, 'the user is enrolled' ) or diag($message);
     my $code = $totp->expected_totp_code( time() );
     my $code = $totp->expected_totp_code( time() );
 
 
@@ -294,7 +293,7 @@ subtest 'the sudo password on the hypervisor' => sub {
     is( $post->{passphrase_remembered}, 1, 'after which the passphrase is stored' );
     is( $post->{passphrase_remembered}, 1, 'after which the passphrase is stored' );
     is( $post->{sudo_remembered},       1, 'and so is the sudo password' );
     is( $post->{sudo_remembered},       1, 'and so is the sudo password' );
 
 
-    my ( $uri, $qr, $failure, $message, $totp ) = Trog::Auth::totp( 'admin', 'example.com' );
+    my ( undef, undef, undef, undef, $totp ) = Trog::Auth::totp( 'admin', 'example.com' );
     require Trog::SQLite;
     require Trog::SQLite;
     Trog::SQLite::dbh( 'schema/auth.schema', 'config/auth.db' )->do("DELETE FROM totp_spent WHERE username='admin'");
     Trog::SQLite::dbh( 'schema/auth.schema', 'config/auth.db' )->do("DELETE FROM totp_spent WHERE username='admin'");
 
 
@@ -350,7 +349,7 @@ subtest 'and when the vault key has gone' => sub {
 
 
     # Posted at directly, as somebody would from a page drawn a moment before
     # Posted at directly, as somebody would from a page drawn a moment before
     # the key went away.
     # the key went away.
-    my ( $uri, $qr, $failure, $message, $totp ) = Trog::Auth::totp( 'admin', 'example.com' );
+    my ( undef, undef, undef, undef, $totp ) = Trog::Auth::totp( 'admin', 'example.com' );
 
 
     # The subtest above spent this window's codes.  Standing here for thirty
     # The subtest above spent this window's codes.  Standing here for thirty
     # seconds would say the same thing and cost thirty seconds.
     # seconds would say the same thing and cost thirty seconds.

+ 0 - 1
t/Trog-DataSource.t

@@ -9,7 +9,6 @@ use 5.040;
 use re '/aasx';
 use re '/aasx';
 use warnings FATAL => 'all';
 use warnings FATAL => 'all';
 
 
-use FindBin;
 use FindBin::libs;
 use FindBin::libs;
 
 
 use Test::More;
 use Test::More;

+ 0 - 1
t/Trog-Log-Syslog.t

@@ -9,7 +9,6 @@ use File::Temp  qw{tempdir};
 use IO::Socket::UNIX;
 use IO::Socket::UNIX;
 use Socket qw{SOCK_DGRAM};
 use Socket qw{SOCK_DGRAM};
 use Log::Dispatch;
 use Log::Dispatch;
-use FindBin;
 
 
 use FindBin::libs;
 use FindBin::libs;
 
 

+ 0 - 1
t/Trog-Routes-HTML-config.t

@@ -7,7 +7,6 @@ use Cwd();
 use File::Path();
 use File::Path();
 use File::Temp();
 use File::Temp();
 use Path::Tiny();
 use Path::Tiny();
-use FindBin;
 
 
 use FindBin::libs;
 use FindBin::libs;
 
 

+ 0 - 1
t/Trog-Routes-HTML-post-wizard-browser.t

@@ -29,7 +29,6 @@ use 5.040;
 use re '/aasx';
 use re '/aasx';
 use warnings FATAL => 'all';
 use warnings FATAL => 'all';
 
 
-use FindBin;
 use FindBin::libs;
 use FindBin::libs;
 
 
 use Test::More;
 use Test::More;

+ 5 - 5
t/Trog-Routes-HTML-series-lifecycle.t

@@ -406,7 +406,7 @@ subtest 'the sandbox is what we are actually running against' => sub {
 subtest 'registering the first admin bootstraps the install' => sub {
 subtest 'registering the first admin bootstraps the install' => sub {
     ok( !-f 'config/has_users', 'no users yet, so login() is in register mode' );
     ok( !-f 'config/has_users', 'no users yet, so login() is in register mode' );
 
 
-    my ( $code, $body, $err, $headers ) = _render(
+    my ( $code, undef, $err, $headers ) = _render(
         _anon(
         _anon(
             route         => '/login',
             route         => '/login',
             method        => 'POST',
             method        => 'POST',
@@ -565,7 +565,7 @@ subtest 'a datasource-backed series searches and paginates' => sub {
     require Test::MockModule;
     require Test::MockModule;
     require Trog::DataSource::Virt;
     require Trog::DataSource::Virt;
 
 
-    my ( $code, $body, $err ) = _render(
+    my ( $code, undef, $err ) = _render(
         _admin(
         _admin(
             route          => '/admin/wyzzerdd/save',
             route          => '/admin/wyzzerdd/save',
             method         => 'POST',
             method         => 'POST',
@@ -581,7 +581,7 @@ subtest 'a datasource-backed series searches and paginates' => sub {
     is( $code, 200, 'the datasource-backed type was created' ) or diag($err);
     is( $code, 200, 'the datasource-backed type was created' ) or diag($err);
 
 
     _reindex();
     _reindex();
-    my $series = _make_series( qw{spec_guests specguests spec_guests.tx}, 'Spec Guests Series', no_topbar => 1 ) or return;
+    _make_series( qw{spec_guests specguests spec_guests.tx}, 'Spec Guests Series', no_topbar => 1 ) or return;
 
 
     # Twelve guests, every one stamped with the same created -- which is what
     # Twelve guests, every one stamped with the same created -- which is what
     # libvirt guests really are, and precisely what the cursor paginator cannot
     # libvirt guests really are, and precisely what the cursor paginator cannot
@@ -852,7 +852,7 @@ subtest 'the wizard offers the types that exist, and can reopen one' => sub {
 };
 };
 
 
 subtest 'a field can be declared indexed' => sub {
 subtest 'a field can be declared indexed' => sub {
-    my ( $code, $body, $err ) = _render(
+    my ( $code, undef, $err ) = _render(
         _admin(
         _admin(
             route          => '/admin/wyzzerdd/save',
             route          => '/admin/wyzzerdd/save',
             method         => 'POST',
             method         => 'POST',
@@ -922,7 +922,7 @@ subtest 'a field can be declared indexed' => sub {
 };
 };
 
 
 subtest 'a field can be declared editors-only' => sub {
 subtest 'a field can be declared editors-only' => sub {
-    my ( $code, $body, $err ) = _render(
+    my ( $code, undef, $err ) = _render(
         _admin(
         _admin(
             route               => '/admin/wyzzerdd/save',
             route               => '/admin/wyzzerdd/save',
             method              => 'POST',
             method              => 'POST',

+ 0 - 1
t/Trog-Themes-themed-templates.t

@@ -5,7 +5,6 @@ use warnings FATAL => 'all';
 use Test::More;
 use Test::More;
 use Test::MockModule qw{strict};
 use Test::MockModule qw{strict};
 use Path::Tiny();
 use Path::Tiny();
-use FindBin;
 
 
 use FindBin::libs;
 use FindBin::libs;
 
 

+ 4 - 5
t/Trog-Vault.t

@@ -116,7 +116,6 @@ subtest 'and not without the key it was sealed under' => sub {
     my $dbh = Trog::SQLite::dbh( 'schema/auth.schema', 'config/auth.db' );
     my $dbh = Trog::SQLite::dbh( 'schema/auth.schema', 'config/auth.db' );
 
 
     # A different installation's key, which is what a stolen database meets.
     # A different installation's key, which is what a stolen database meets.
-    my $theirs = Trog::Vault::key();
     {
     {
         no warnings qw{once};
         no warnings qw{once};
         local $Trog::Vault::master = Crypt::PRNG::random_bytes(32);
         local $Trog::Vault::master = Crypt::PRNG::random_bytes(32);
@@ -150,10 +149,10 @@ subtest 'the listing never shows a value' => sub {
 
 
 subtest 'a name is a name' => sub {
 subtest 'a name is a name' => sub {
     foreach my $bad ( '../../etc/passwd', 'has spaces', '', 'a' x 100, '.hidden' ) {
     foreach my $bad ( '../../etc/passwd', 'has spaces', '', 'a' x 100, '.hidden' ) {
-        my ( $ok, $why ) = Trog::Vault::set( 'bob', $bad, 'nope' );
+        my ( $ok, undef ) = Trog::Vault::set( 'bob', $bad, 'nope' );
         is( $ok, 0, "'$bad' is refused as a name" );
         is( $ok, 0, "'$bad' is refused as a name" );
     }
     }
-    my ( $ok, $why ) = Trog::Vault::set( 'bob', 'fine', '' );
+    my ( $ok, undef ) = Trog::Vault::set( 'bob', 'fine', '' );
     is( $ok, 0, 'and an empty secret is not a secret' );
     is( $ok, 0, 'and an empty secret is not a secret' );
 };
 };
 
 
@@ -215,7 +214,7 @@ subtest 'the other two places a key can be' => sub {
 };
 };
 
 
 subtest 'a code is worth one thing' => sub {
 subtest 'a code is worth one thing' => sub {
-    my ( $uri, $qr, $failure, $message, $totp ) = Trog::Auth::totp( 'bob', 'vault.example.com' );
+    my ( $uri, undef, undef, $message, $totp ) = Trog::Auth::totp( 'bob', 'vault.example.com' );
     ok( $uri, 'bob is enrolled' ) or diag($message);
     ok( $uri, 'bob is enrolled' ) or diag($message);
 
 
     my $now  = time();
     my $now  = time();
@@ -285,7 +284,7 @@ subtest 'passwords are argon2id, and become it' => sub {
 };
 };
 
 
 subtest 'logging in spends a code' => sub {
 subtest 'logging in spends a code' => sub {
-    my ( $uri, $qr, $failure, $message, $totp ) = Trog::Auth::totp( 'bob', 'vault.example.com' );
+    my ( undef, undef, undef, undef, $totp ) = Trog::Auth::totp( 'bob', 'vault.example.com' );
 
 
     # The subtest above spent the code for the window we are standing in, and
     # The subtest above spent the code for the window we are standing in, and
     # the counter only walks forwards.  Standing here for thirty seconds would
     # the counter only walks forwards.  Standing here for thirty seconds would