Procházet zdrojové kódy

Drop a signature whose every parameter is unused

Review on #362: a sub that reads none of its arguments has no use for a
signature of bare sigils, such as sub tags ($) or
sub read ( $, $ = {} ).  The 22 subs whose signature held only
placeholders now have none.  A signature that names any parameter keeps
its placeholders, because they hold that parameter's place.

Without a signature, perl no longer checks how many arguments these
subs get, so a call with too many no longer dies.  None of them read
@_.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
troglodyne-bot před 6 dny
rodič
revize
d9dec725e8

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

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

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

@@ -24,7 +24,7 @@ sub help { return 'https://perldoc.perl.org/functions/quotemeta.html' }
 
 our $posts;
 
-sub read ( $, $ = {} ) {
+sub read {
 
     # 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
@@ -77,7 +77,7 @@ sub delete ( $self, @posts ) {
     return 0;
 }
 
-sub tags ($) {
+sub tags {
     return ( uniq map { @{ $_->{tags} } } @$posts );
 }
 

+ 4 - 4
lib/Trog/Data/FlatFile.pm

@@ -118,7 +118,7 @@ sub read ( $self, $query = {} ) {
     return \@items;
 }
 
-sub _index ($) {
+sub _index {
     confess "Can't find datastore in $datastore !" unless -d $datastore;
     opendir( my $dh, $datastore ) or confess;
     my @index = grep { -f } map { "$datastore/$_" } readdir $dh;    ## no critic (ProhibitFiletest_f) -- listing names, nothing is opened
@@ -126,11 +126,11 @@ sub _index ($) {
     return sort { $b cmp $a } @index;
 }
 
-sub routes ($) {
+sub routes {
     return Trog::SQLite::TagIndex::routes();
 }
 
-sub aliases ($) {
+sub aliases {
     return Trog::SQLite::TagIndex::aliases();
 }
 
@@ -196,7 +196,7 @@ sub delete ( $, @posts ) {
     return 0;
 }
 
-sub tags ($) {
+sub tags {
     return Trog::SQLite::TagIndex::tags();
 }
 

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

@@ -356,7 +356,7 @@ whether it has seen it before.  See bin/migrate.pl.
 
 =cut
 
-sub versions_present ($) {
+sub versions_present {
     my $rows = _dbh()->selectall_arrayref( 'SELECT uuid, version FROM posts', { Slice => {} } ) // [];
 
     my %present;
@@ -386,7 +386,7 @@ How many posts there are, counting a post once however many versions it has.
 
 =cut
 
-sub count ($) {
+sub count {
     my ($count) = _dbh()->selectrow_array('SELECT COUNT(DISTINCT uuid) FROM posts');
     return $count // 0;
 }
@@ -491,7 +491,7 @@ Every tag in use, from the index the schema's triggers maintain.
 
 =cut
 
-sub tags ($) {
+sub tags {
     my $rows = _dbh()->selectall_arrayref( 'SELECT DISTINCT tag FROM post_tags ORDER BY tag', { Slice => {} } );
     return () unless ref $rows eq 'ARRAY';
     return map { $_->{tag} } @$rows;

+ 8 - 8
lib/Trog/DataModule.pm

@@ -86,12 +86,12 @@ Every tag known to the datastore, for building tag pickers.
 =cut
 
 #It is required that subclasses implement this
-sub lang ($)           { ... }
-sub help ($)           { ... }
-sub read ( $, $ = {} ) { ... }
-sub write ($)          { ... }
-sub count ($)          { ... }
-sub tags ($)           { ... }
+sub lang  { ... }
+sub help  { ... }
+sub read  { ... }
+sub write { ... }
+sub count { ... }
+sub tags  { ... }
 
 =head1 METHODS
 
@@ -607,7 +607,7 @@ what is no longer asked for.
 
 =cut
 
-sub index_fields ( $, @ ) { return 0 }
+sub index_fields { return 0 }
 
 =head2 relations_for($form)
 
@@ -989,7 +989,7 @@ You should override this, it is a stub here.
 
 =cut
 
-sub delete ($) { die 'stub' }
+sub delete { die 'stub' }
 
 =head2 routes() = HASH
 

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

@@ -2323,7 +2323,7 @@ about whether the account existed.
 
 =cut
 
-sub processed ($) {
+sub processed {
     return Trog::Routes::HTML::index(
         {
             title     => "Your request has been processed",

+ 3 - 3
lib/Trog/Routes/JSON.pm

@@ -81,16 +81,16 @@ sub _version () {
 }
 
 # Special case of a non data-structure JSON return
-sub version ($) {
+sub version {
     state $ret = [ 200, [ 'Content-type' => "application/json", ETag => 'version-' . _version() ], [ _version() ] ];
     return $ret;
 }
 
-sub catalog ($) {
+sub catalog {
     return _render( 200, { ETag => 'catalog-' . _version() }, %$cloned );
 }
 
-sub webmanifest ($) {
+sub webmanifest {
     state $headers = { ETag => 'manifest-' . _version() };
     my $theme_dir = Trog::Themes::get_dir();
     state %manifest = (