]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Fixed problems reported by perlcritic
authorJari Matilainen <redacted>
Wed, 25 Nov 2015 10:42:09 +0000 (11:42 +0100)
committerJari Matilainen <redacted>
Wed, 25 Nov 2015 10:42:09 +0000 (11:42 +0100)
scripts/intercept.pl
scripts/notes.pl
scripts/notifyquit.pl
scripts/tabcompletenick.pl
scripts/timezones.pl

index edb882a9da273c589e34e69ec7625e5716e6757a..b798950f12b99b92208e2de5f761b71caf849b6b 100644 (file)
@@ -3,10 +3,13 @@
 use strict;
 use warnings;
 use Data::Dumper;
+use Carp qw( croak );
 use Irssi;
 
-our $VERSION = "0.1";
-our %IRSSI = (
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "0.1";
+%IRSSI = (
               authors     => "Jari Matilainen",
               contact     => 'vague!#irssi@freenode on irc',
               name        => "intercept",
@@ -50,7 +53,7 @@ sub load_uberprompt_failed {
   print "https://github.com/shabble/irssi-scripts/raw/master/"
       . "prompt_info/uberprompt.pl";
 
-  die "Script Load Failed: " . join(" ", @_);
+  croak "Script Load Failed: " . join(" ", @_);
 }
 
 sub sig_send_text {
index d1ebae2bf0b0f067d34323383ad64973de601a3e..364ccf40572585130e5f04dbcb96c8c76832faa3 100644 (file)
@@ -23,10 +23,11 @@ use vars qw($VERSION %IRSSI);
 $VERSION = '0.31';
 %IRSSI = (
     authors     => 'vague',
-    contact     => 'vague!#irssi\@freenode',
+    contact     => 'vague!#irssi@freenode',
     name        => 'notes',
     description => 'Keeps notes on users and displayes the note in /whois output if the host/nick matches',
     license     => 'GPL2',
+    changed     => "24 Nov 16:00:00 CET 2015",
 );
 
 my $notes;
index 087ee575db638bbb3a2c43ee7ef25c409eee9fe4..e2910aa58d06f2a4bb05587f7c438f0e7feb745f 100644 (file)
@@ -102,10 +102,14 @@ So, add them on quit/kick/part, and remove them after a tiemout.
 
 use strict;
 use warnings;
+use Irssi;
+use Carp qw( croak );
 use Data::Dumper;
 
-our $VERSION = "0.3";
-our %IRSSI = (
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "0.3";
+%IRSSI = (
               authors     => "Jari Matilainen",
               contact     => 'vague!#irssi@freenode on irc',
               name        => "notifyquit",
@@ -113,7 +117,7 @@ our %IRSSI = (
               license     => "Public Domain",
               url         => "http://gplus.to/vague",
               changed     => "24 Nov 16:00:00 CET 2015",
-             );
+         );
 
 my $active = 0;
 my $permit_pending = 0;
@@ -150,7 +154,7 @@ sub load_uberprompt_failed {
     print "https://github.com/shabble/irssi-scripts/raw/master/"
         . "prompt_info/uberprompt.pl";
 
-    die "Script Load Failed: " . join(" ", @_);
+    croak "Script Load Failed: " . join(" ", @_);
 }
 
 sub extract_nick {
@@ -224,7 +228,7 @@ sub sig_send_text {
                      win_item => $witem,
                     };
 
-                Irssi::signal_stop;
+                Irssi::signal_stop();
                 require_confirmation($text);
             }
         }
@@ -241,7 +245,7 @@ sub sig_gui_keypress {
     # Enter, y, or Y.
     if ($char =~ m/^y?$/i) {
         $permit_pending = 1;
-        Irssi::signal_stop;
+        Irssi::signal_stop();
         Irssi::signal_emit('send text',
                            $pending_input->{text},
                            $pending_input->{server},
@@ -252,7 +256,7 @@ sub sig_gui_keypress {
     } elsif ($char =~ m/^n?$/i or $key == 3 or $key == 7) {
         # we support n, N, Ctrl-C, and Ctrl-G for no.
 
-        Irssi::signal_stop;
+        Irssi::signal_stop();
         set_prompt('');
 
         $permit_pending = 0;
@@ -260,7 +264,7 @@ sub sig_gui_keypress {
         $pending_input  = {};
 
     } else {
-        Irssi::signal_stop;
+        Irssi::signal_stop();
         return;
     }
 }
@@ -421,14 +425,13 @@ sub app_init {
 }
 
 sub cmd_show_exceptions {
-
     foreach my $e (@match_exceptions) {
         print "Exception: $e";
     }
 }
 
 sub cmd_show_watchlist {
-    Irssi::print Dumper($watchlist);
+    Irssi::print(Dumper($watchlist));
 }
 
 sub sig_setup_changed {
index deca5af9e75c5afc131d203d74a1ac020463077e..a8c0295bf9daf73b4c66aac050171a634af8edba 100644 (file)
@@ -7,9 +7,13 @@
 #   from the start again
 # - /set completion_keep_publics decides how many nicks to remember
 
-use Irssi;
+use strict;
+use warnings;
+use Irssi::TextUI;
 use Data::Dumper;
 
+{ package Irssi::Nick; }
+
 my $VERSION = '1.0';
 my %IRSSI = (
     authors     => 'vague',
@@ -21,20 +25,20 @@ my %IRSSI = (
     changed     => "24 Nov 16:00:00 CET 2015",
 );
 
-my $lastspokehash = {};
+my $lastspokehash;
 my $expand_next = 0;
 
 Irssi::signal_add_first('gui key pressed', sub {
   my ($key) = @_;
-  my $prompt = Irssi::parse_special('$L');
-  my $pos = Irssi::gui_input_get_pos();
 
-  $server = Irssi::active_server();
-  $witem = Irssi::active_win()->{active};
+  return unless exists Irssi::active_win->{active} && Irssi::active_win->{active}->{type} eq "CHANNEL";
 
-  return unless $witem->{type} eq "CHANNEL";
+  my $prompt = Irssi::parse_special('$L');
+  my $pos = Irssi::gui_input_get_pos();
+  my $witem = Irssi::active_win()->{active};
+  my $server = Irssi::active_server();
 
-  my $arr = $lastspokehash{$server->{tag}}->{$witem->{name}};
+  my $arr = $lastspokehash->{$server->{tag}}->{$witem->{name}} || [];
 
   if(!$expand_next) {
     return unless $key == 9;
@@ -49,7 +53,7 @@ Irssi::signal_add_first('gui key pressed', sub {
       return;
     }
 
-    if($expand_next < scalar @{$arr}) {
+    if($expand_next < @$arr) {
       $expand_next++;
     } else {
       $expand_next = 0;
@@ -71,43 +75,44 @@ Irssi::signal_add_first('gui key pressed', sub {
 
 sub expando_lastspoke {
   my ($server, $witem) = @_;
-  $server = Irssi::active_server();
-  $witem = Irssi::active_win()->{active};
+  $server = Irssi::active_server() unless $server;
+  $witem = Irssi::active_win()->{active} unless $witem;
 
   return '' if $expand_next == 0;
   return '' unless ref($witem) eq 'Irssi::Irc::Channel';
-  my $arr = $lastspokehash{$server->{tag}}->{$witem->{name}};
-  return '' unless @{$arr};
-  return '' unless $expand_last <= $arr;
 
-  return @{$lastspokehash{$server->{tag}}->{$witem->{name}}}[$expand_next - 1];
+  my $arr = $lastspokehash->{$server->{tag}}->{$witem->{name}};
+  return '' unless @$arr;
+  return '' unless $expand_next <= @$arr;
+
+  return @{$lastspokehash->{$server->{tag}}->{$witem->{name}}}[$expand_next - 1];
 }
 
 sub act_public {
-  my ($server, $msg, $nick, $address, $witem) = @_;
+  my ($server, $msg, $nick, $address, $target) = @_;
 
-  return if $witem eq '';
+  return if $target eq '';
 
   my $i = 0;
-  my $arr = $lastspokehash{$server->{tag}}->{$witem};
-  foreach(@{$arr}) {
+  my $arr = $lastspokehash->{$server->{tag}}->{$target};
+  foreach(@$arr) {
     if($_ eq $nick) {
-      splice @{$arr}, $i, 1;
+      splice @$arr, $i, 1;
       last;
     }
     $i++;
   }
 
-  unshift @{$lastspokehash{$server->{tag}}->{$witem}}, $nick;
-  splice @{$lastspokehash{$server->{tag}}->{$witem}}, Irssi::settings_get_int('completion_keep_publics');
+  unshift @{$lastspokehash->{$server->{tag}}->{$target}}, $nick;
+  splice @{$lastspokehash->{$server->{tag}}->{$target}}, Irssi::settings_get_int('completion_keep_publics');
 }
 
 sub _part {
   my ($server, $channel, $nick) = @_;
 
   if(!$channel) {
-    foreach my $chan (keys %{$lastspokehash{$server->{tag}}}) {
-      my $arr = $lastspokehash{$server->{tag}}->{$chan};
+    foreach my $chan (keys %{$lastspokehash->{$server->{tag}}}) {
+      my $arr = $lastspokehash->{$server->{tag}}->{$chan};
       my $i = 0;
       foreach(@{$arr}) {
         if($_ eq $nick) {
@@ -120,7 +125,7 @@ sub _part {
     }
   }
   else {
-    my $arr = $lastspokehash{$server->{tag}}->{$channel};
+    my $arr = $lastspokehash->{$server->{tag}}->{$channel};
     my $i = 0;
     foreach(@{$arr}) {
       if($_ eq $nick) {
@@ -132,8 +137,7 @@ sub _part {
     }
   }
 
-  delete $lastspokehash{$server->{tag}}->{$channel} unless @{$lastspokehash{$server->{tag}}->{$channel}};
-  delete $lastspokehash{$server->{tag}} unless keys %{$lastspokehash{$server->{tag}}};
+  delete $lastspokehash->{$server->{tag}} unless keys %{$lastspokehash->{$server->{tag}}};
 }
 
 Irssi::signal_add_first('message quit', sub {
@@ -154,8 +158,8 @@ Irssi::signal_add_first('message kick', sub {
 Irssi::signal_add_first('message nick', sub {
   my ($server, $newnick, $oldnick, $address) = @_;
 
-  foreach my $chan (keys %{$lastspokehash{$server->{tag}}}) {
-    my $arr = $lastspokehash{$server->{tag}}->{$chan};
+  foreach my $chan (keys %{$lastspokehash->{$server->{tag}}}) {
+    my $arr = $lastspokehash->{$server->{tag}}->{$chan};
     my $i = 0;
     foreach(@{$arr}) {
       if($_ eq $oldnick) {
index 65e9ebe8b919544d98f53f457b141cc9f9319e02..0ca0ece3310815833491f24863d8be5cd006249a 100644 (file)
@@ -8,6 +8,14 @@
 # or add it to an existing one with
 # /statusbar window add timezones (window is an exaple, see /statusbar and /help statusbar for comprehensive help)
 
+use strict;
+use warnings;
+use Irssi;
+use DateTime;
+use Carp qw/croak/;
+
+use vars qw($VERSION %IRSSI);
+
 $VERSION = "0.2";
 %IRSSI = (
     authors     => "Jari Matilainen",
@@ -19,10 +27,6 @@ $VERSION = "0.2";
     changed     => "Tue 24 November 16:00:00 CET 2015",
 );
 
-use strict;
-use Irssi::TextUI;
-use DateTime;
-
 my $refresh_tag;
 
 sub timezones {
@@ -38,7 +42,7 @@ sub timezones {
     my ($nick, $timezone) = split /:/, $_;
     my $now;
     eval {
-      $now = DateTime->now(time_zone => "$timezone") or die $!;
+      $now = DateTime->now(time_zone => "$timezone") or croak $!;
     };
 
     if($@) {
git clone https://git.99rst.org/PROJECT