Эх сурвалжийг харах

Address the simple perlcritic findings

Everything perlcritic reports for bin/ and lib/ is now clean except the
-f/-w filetest, exec and simple-substring policies, which were out of scope
here.

- Shebangs on the five scripts still saying #!/usr/bin/perl now match what
  logicLAB::RequireSheBang asks for.

- Every file gets "use re '/aa'" rather than the flag on each of the 83
  regexes individually.  It goes in all 45, not just the twelve that have a
  regex today, so that adding one later doesn't reintroduce the violation.
  Note that our .perlcriticrc sets strict=1 on
  RegularExpressions::RequireDefault, so /a does not satisfy it -- it wants
  ASCII-safe, not just ASCII-restrict -- and the policy accepts the pragma in
  place of the modifier.  Nearly all of these regexes match structural things
  (routes, module names, MIME types, file extensions) where ASCII is what was
  meant anyway.  The one real narrowing is the log parser in Trog::Log::DBI:
  a non-ASCII username no longer matches \w+ and its request drops out of the
  metrics db.  It already did that for byte strings, which is what the logger
  actually emits, so this makes the existing behavior consistent rather than
  introducing it.

- Declared 'use v5.36' in all 45 files that had no version.  Chose 5.36
  because that is where signatures stopped being experimental, and 30 files
  were already written against them.  The bundle implies strict, warnings,
  signatures and state, so the boilerplate asking for those individually is
  gone; Routes::HTML keeps the 'once' half of its no-warnings line, which the
  bundle does not cover.  Checked first that nothing in the tree relies on
  indirect object syntax, multidimensional hash subscripts, string bitwise
  ops or a sub named say/isa, all of which the bundle would have broken.
  Makefile.PL now advertises the same floor.

- migrate6.pl writes through File::Slurper::Temp, per .preferred_modules.ini
  wanting the rename-into-place behavior for write_binary.  Added to PREREQ_PM.

- Dropped a commented-out $sopts{player} assignment in Routes::HTML and the
  useless @extra_series initializations in migrate2/3.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CJ2NAMQyytncwHKSmD5dFe
George Baugh 1 сар өмнө
parent
commit
694e3189f2

+ 5 - 0
Makefile.PL

@@ -5,6 +5,10 @@ use ExtUtils::MakeMaker;
 
 WriteMakefile(
   VERSION   => '0.01',
+
+  # Every module and script declares 'use v5.36' -- signatures without the
+  # experimental warning is what we build on.
+  MIN_PERL_VERSION => '5.036000',
   META_MERGE        => {
     "meta-spec" => { version => 2 },
     resources => {
@@ -30,6 +34,7 @@ WriteMakefile(
     'File::Basename'         => '0',
     'File::Copy'             => '0',
     'File::Slurper'          => '0',
+    'File::Slurper::Temp'    => '0',
     'File::Touch'            => '0',
     'File::Path'             => '0',
     'HTML::SocialMeta'       => '0',

+ 3 - 3
bin/build_index.pl

@@ -1,7 +1,7 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use lib 'lib';
 use Trog::Data;

+ 3 - 3
bin/favicon_mongler.pl

@@ -1,7 +1,7 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use Cwd            ();
 use File::Basename ();

+ 3 - 3
bin/migrate.pl

@@ -1,9 +1,9 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #Migrate tCMS1 data to tCMS2 flat file data model
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use JSON::MaybeXS;
 use File::Slurper();

+ 4 - 4
bin/migrate2.pl

@@ -1,7 +1,7 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 # Migrate early on tcms3 flatfile sites to 'all posts are series code' (august 2021) code
 
@@ -58,7 +58,7 @@ sub uuid { return UUID::Tiny::create_uuid_as_string( UUID::Tiny::UUID_V1, UUID::
 
 # Modify these variables to suit your installation.
 my $user         = 'george';
-my @extra_series = ();
+my @extra_series;
 
 my $conf        = Trog::Config::get();
 my $search_info = Trog::Data->new($conf);

+ 4 - 4
bin/migrate3.pl

@@ -1,7 +1,7 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 # Migrate early on tcms3 flatfile sites to store rather than compute much data (dec 2021) code
 
@@ -55,7 +55,7 @@ sub uuid { return UUID::Tiny::create_uuid_as_string( UUID::Tiny::UUID_V1, UUID::
 
 # Modify these variables to suit your installation.
 my $user         = 'george';
-my @extra_series = ();
+my @extra_series;
 
 my $conf        = Trog::Config::get();
 my $search_info = Trog::Data->new($conf);

+ 2 - 2
bin/migrate4.pl

@@ -2,8 +2,8 @@
 
 # Migrate to 2FA
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use FindBin;
 

+ 2 - 2
bin/migrate5.pl

@@ -2,8 +2,8 @@
 
 # Password reset code
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use FindBin;
 

+ 7 - 3
bin/migrate6.pl

@@ -2,8 +2,8 @@
 
 # Display names
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use FindBin;
 
@@ -55,6 +55,7 @@ $dbh->do("ALTER TABLE user ADD COLUMN display_name TEXT DEFAULT NULL;");
 use Trog::Auth;
 use JSON::MaybeXS;
 use File::Slurper;
+use File::Slurper::Temp;
 use URI::Escape;
 use Data::Dumper;
 
@@ -82,7 +83,10 @@ while ( my $entry = readdir $dh ) {
 
     print "Writing changes to $fname\n";
     my $encoded = JSON::MaybeXS::encode_json($decoded);
-    File::Slurper::write_binary( $fname, $encoded );
+    # Temp:: rather than plain File::Slurper -- it writes to a tempfile and
+    # renames over the target, so a crash partway can't leave a half written
+    # post behind.
+    File::Slurper::Temp::write_binary( $fname, $encoded );
 
     # Next, waste and rebuild the posts index for these user posts
     $global_changes = 1;

+ 2 - 2
bin/tcms-hostname

@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use FindBin::libs;
 

+ 2 - 2
bin/tcms-useradd

@@ -2,8 +2,8 @@
 
 package tcms::useradd;
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use FindBin::libs;
 use Getopt::Long;

+ 2 - 2
bin/tcmslogin

@@ -2,8 +2,8 @@
 
 package tcms::login;
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use FindBin::libs;
 use Getopt::Long;

+ 2 - 2
bin/totp

@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use FindBin::libs;
 

+ 2 - 5
lib/TCMS.pm

@@ -1,10 +1,7 @@
 package TCMS;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use Carp qw{confess};
 use Clone        qw{clone};

+ 2 - 5
lib/Theme.pm

@@ -1,10 +1,7 @@
 package Theme;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures};
+use v5.36;
+use re '/aa';
 
 =head1 Theme
 

+ 2 - 5
lib/Trog/Auth.pm

@@ -1,10 +1,7 @@
 package Trog::Auth;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use FindBin::libs;
 

+ 2 - 5
lib/Trog/Component/EmojiPicker.pm

@@ -1,10 +1,7 @@
 package Trog::Component::EmojiPicker;
 
-use strict;
-use warnings;
-
-no warnings qw{experimental};
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use JSON::MaybeXS;
 use Trog::Renderer;

+ 2 - 3
lib/Trog/Config.pm

@@ -1,8 +1,7 @@
 package Trog::Config;
 
-use strict;
-use warnings;
-use feature qw{state};
+use v5.36;
+use re '/aa';
 
 use FindBin::libs;
 

+ 2 - 5
lib/Trog/Data.pm

@@ -1,10 +1,7 @@
 package Trog::Data;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 #It's just a factory
 

+ 2 - 5
lib/Trog/Data/DUMMY.pm

@@ -1,10 +1,7 @@
 package Trog::Data::DUMMY;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures};
+use v5.36;
+use re '/aa';
 
 use Carp qw{confess};
 use JSON::MaybeXS;

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

@@ -1,10 +1,7 @@
 package Trog::Data::FlatFile;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures};
+use v5.36;
+use re '/aa';
 
 use Carp qw{confess};
 use JSON::MaybeXS;

+ 2 - 4
lib/Trog/DataModule.pm

@@ -1,7 +1,7 @@
 package Trog::DataModule;
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use FindBin::libs;
 
@@ -20,8 +20,6 @@ use Trog::Log qw{:all};
 use Trog::Utils;
 use Trog::Auth();
 
-no warnings 'experimental';
-use feature qw{signatures state};
 
 =head1 QUERY FORMAT
 

+ 2 - 5
lib/Trog/DataSource/Virt.pm

@@ -1,10 +1,7 @@
 package Trog::DataSource::Virt;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use File::Path();
 use Sys::Hostname::FQDN();

+ 2 - 5
lib/Trog/Email.pm

@@ -1,10 +1,7 @@
 package Trog::Email;
 
-use strict;
-use warnings;
-
-no warnings qw{experimental};
-use feature qw{signatures};
+use v5.36;
+use re '/aa';
 
 use Email::MIME;
 use Email::Sender::Simple;

+ 2 - 5
lib/Trog/Enrich/Invoice.pm

@@ -1,10 +1,7 @@
 package Trog::Enrich::Invoice;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures};
+use v5.36;
+use re '/aa';
 
 use List::Util();
 

+ 2 - 5
lib/Trog/FileHandler.pm

@@ -1,10 +1,7 @@
 package Trog::FileHandler;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures};
+use v5.36;
+use re '/aa';
 
 use POSIX qw{strftime};
 use IO::Compress::Gzip;

+ 2 - 2
lib/Trog/Log.pm

@@ -1,7 +1,7 @@
 package Trog::Log;
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use POSIX qw{strftime};
 use Log::Dispatch;

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

@@ -1,7 +1,7 @@
 package Trog::Log::DBI;
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
 use parent qw{Log::Dispatch::DBI};
 

+ 2 - 5
lib/Trog/Log/Metrics.pm

@@ -1,10 +1,7 @@
 package Trog::Log::Metrics;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use Trog::SQLite;
 use Trog::Log;

+ 2 - 5
lib/Trog/Renderer.pm

@@ -1,10 +1,7 @@
 package Trog::Renderer;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use Carp::Always;
 

+ 2 - 5
lib/Trog/Renderer/Base.pm

@@ -1,10 +1,7 @@
 package Trog::Renderer::Base;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use Encode qw{encode_utf8};
 use IO::Compress::Gzip;

+ 2 - 5
lib/Trog/Renderer/blob.pm

@@ -1,10 +1,7 @@
 package Trog::Renderer::blob;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 =head1 Trog::Renderer::blob
 

+ 2 - 5
lib/Trog/Renderer/css.pm

@@ -1,10 +1,7 @@
 package Trog::Renderer::css;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use parent qw{Trog::Renderer::Base};
 

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

@@ -1,10 +1,7 @@
 package Trog::Renderer::email;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use parent qw{Trog::Renderer::Base};
 

+ 2 - 5
lib/Trog/Renderer/html.pm

@@ -1,10 +1,7 @@
 package Trog::Renderer::html;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use parent qw{Trog::Renderer::Base};
 

+ 2 - 5
lib/Trog/Renderer/javascript.pm

@@ -1,10 +1,7 @@
 package Trog::Renderer::javascript;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use parent qw{Trog::Renderer::Base};
 

+ 2 - 5
lib/Trog/Renderer/json.pm

@@ -1,10 +1,7 @@
 package Trog::Renderer::json;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use JSON::MaybeXS;
 

+ 2 - 5
lib/Trog/Renderer/text.pm

@@ -1,10 +1,7 @@
 package Trog::Renderer::text;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use parent qw{Trog::Renderer::Base};
 

+ 3 - 6
lib/Trog/Routes/HTML.pm

@@ -1,10 +1,9 @@
 package Trog::Routes::HTML;
 
-use strict;
-use warnings;
+use v5.36;
+use re '/aa';
 
-no warnings qw{experimental once};
-use feature qw{signatures state};
+no warnings qw{once};
 
 use POSIX qw{strftime};
 use Errno qw{ENOENT};
@@ -466,8 +465,6 @@ sub _build_social_meta ( $query, $title ) {
     $sopts{image}     = $image                  if $image;
     $sopts{fb_app_id} = $Theme::fb_app_id       if $Theme::fb_app_id;
     if ( $query->{primary_post} && $query->{primary_post}{is_video} ) {
-
-        #$sopts{player} = "$primary_route?embed=1";
         $sopts{player} = "https://$query->{domain}/$query->{primary_post}{href}";
 
         #XXX don't hardcode this

+ 2 - 5
lib/Trog/Routes/JSON.pm

@@ -1,10 +1,7 @@
 package Trog::Routes::JSON;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use Clone qw{clone};
 use JSON::MaybeXS();

+ 2 - 5
lib/Trog/Routes/TXT.pm

@@ -1,10 +1,7 @@
 package Trog::Routes::JSON;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use Clone qw{clone};
 use JSON::MaybeXS();

+ 2 - 5
lib/Trog/SQLite.pm

@@ -1,10 +1,7 @@
 package Trog::SQLite;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use POSIX qw{floor};
 

+ 2 - 5
lib/Trog/SQLite/TagIndex.pm

@@ -1,10 +1,7 @@
 package Trog::SQLite::TagIndex;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures};
+use v5.36;
+use re '/aa';
 
 use URI::Escape;
 use List::Util qw{uniq};

+ 2 - 5
lib/Trog/Themes.pm

@@ -1,10 +1,7 @@
 package Trog::Themes;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use FindBin::libs;
 

+ 2 - 5
lib/Trog/Utils.pm

@@ -1,10 +1,7 @@
 package Trog::Utils;
 
-use strict;
-use warnings;
-
-no warnings 'experimental';
-use feature qw{signatures state};
+use v5.36;
+use re '/aa';
 
 use UUID;
 use HTTP::Tiny::UNIX();

+ 2 - 5
lib/Trog/Vars.pm

@@ -1,10 +1,7 @@
 package Trog::Vars;
 
-use strict;
-use warnings;
-
-use feature qw{signatures};
-no warnings qw{experimental};
+use v5.36;
+use re '/aa';
 
 =head1 Trog::Vars