fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-08-30 08:40 am

[dw-free] enforce strictness

[commit: http://hg.dwscoalition.org/dw-free/rev/e1b59dbfb947]

http://bugs.dwscoalition.org/show_bug.cgi?id=2807

Use strict.

Patch by [personal profile] kareila.

Files modified:
  • bin/maint/clean_caches.pl
  • bin/maint/generic.pl
  • bin/maint/statspics.pl
  • bin/upgrading/update-db-general.pl
  • cgi-bin/JSON/Converter.pm
  • cgi-bin/LJ/CProd/Birthdays.pm
  • cgi-bin/LJ/CProd/ControlStrip.pm
  • cgi-bin/LJ/CProd/Feeds.pm
  • cgi-bin/LJ/CProd/FriendsFriends.pm
  • cgi-bin/LJ/CProd/Polls.pm
  • cgi-bin/LJ/CProd/UserPic.pm
  • cgi-bin/LJ/Constants.pm
  • cgi-bin/LJ/DBUtil.pm
  • cgi-bin/LJ/JSUtil.pm
  • cgi-bin/LJ/Widget/IPPU.pm
  • cgi-bin/crumbs.pl
  • cgi-bin/emailcheck.pl
  • cgi-bin/lj-bml-blocks.pl
  • cgi-bin/lj-bml-init.pl
  • cgi-bin/ljdefaults.pl
  • cgi-bin/modperl_subs.pl
  • cgi-bin/propparse.pl
  • t/use-strict.t
--------------------------------------------------------------------------------
diff -r 9477663e2e77 -r e1b59dbfb947 bin/maint/clean_caches.pl
--- a/bin/maint/clean_caches.pl	Sat Aug 28 19:24:43 2010 +0800
+++ b/bin/maint/clean_caches.pl	Mon Aug 30 16:40:13 2010 +0800
@@ -12,6 +12,10 @@
 # modifications are provided under the GNU General Public License.
 # A copy of that license can be found in the LICENSE file included as
 # part of this distribution.
+
+use strict;
+
+my %maint;
 
 $maint{'clean_caches'} = sub
 {
@@ -164,7 +168,7 @@
 
         my $dbcm = LJ::get_cluster_master($cid);
         unless ($dbcm) {
-            print "    cluster down: $clusterid\n";
+            print "    cluster down: $cid\n";
             next;
         }
 
@@ -279,7 +283,7 @@
 
         my $dbcm = LJ::get_cluster_master($cid);
         unless ($dbcm) {
-            print "    cluster down: $clusterid\n";
+            print "    cluster down: $cid\n";
             next;
         }
 
diff -r 9477663e2e77 -r e1b59dbfb947 bin/maint/generic.pl
--- a/bin/maint/generic.pl	Sat Aug 28 19:24:43 2010 +0800
+++ b/bin/maint/generic.pl	Mon Aug 30 16:40:13 2010 +0800
@@ -13,6 +13,9 @@
 # A copy of that license can be found in the LICENSE file included as
 # part of this distribution.
 
+use strict;
+
+my %maint;
 
 $maint{joinmail} = sub {
     # this needs to be resumeable, so that it can run once every 10 or 15 minutes to digest things
diff -r 9477663e2e77 -r e1b59dbfb947 bin/maint/statspics.pl
--- a/bin/maint/statspics.pl	Sat Aug 28 19:24:43 2010 +0800
+++ b/bin/maint/statspics.pl	Mon Aug 30 16:40:13 2010 +0800
@@ -13,7 +13,10 @@
 # A copy of that license can be found in the LICENSE file included as
 # part of this distribution.
 
+use strict;
 use GD::Graph::bars;
+
+my %maint;
 
 $maint{'genstatspics'} = sub
 {
diff -r 9477663e2e77 -r e1b59dbfb947 bin/upgrading/update-db-general.pl
--- a/bin/upgrading/update-db-general.pl	Sat Aug 28 19:24:43 2010 +0800
+++ b/bin/upgrading/update-db-general.pl	Mon Aug 30 16:40:13 2010 +0800
@@ -13,6 +13,8 @@
 #
 # database schema & data info
 #
+
+use strict;
 
 mark_clustered(@LJ::USER_TABLES);
 
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/JSON/Converter.pm
--- a/cgi-bin/JSON/Converter.pm	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/JSON/Converter.pm	Mon Aug 30 16:40:13 2010 +0800
@@ -14,6 +14,7 @@ package JSON::Converter;
 package JSON::Converter;
 ##############################################################################
 
+use strict;
 use Carp;
 
 $JSON::Converter::VERSION = 1.00;
@@ -169,19 +170,19 @@ sub valueToJson {
 }
 
 
-%esc = (
-    "\n" => '\n',
-    "\r" => '\r',
-    "\t" => '\t',
-    "\f" => '\f',
-    "\b" => '\b',
-    "\"" => '\"',
-    "\\" => '\\\\',
-);
-
-
 sub _stringfy {
     my $arg = shift;
+
+    my %esc = (
+        "\n" => '\n',
+        "\r" => '\r',
+        "\t" => '\t',
+        "\f" => '\f',
+        "\b" => '\b',
+        "\"" => '\"',
+        "\\" => '\\\\',
+    );
+
     $arg =~ s/([\\"\n\r\t\f\b])/$esc{$1}/eg;
     $arg =~ s/([\x00-\x07\x0b\x0e-\x1f])/'\\u00' . unpack('H2',$1)/eg;
     return '"' . $arg . '"';
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/LJ/CProd/Birthdays.pm
--- a/cgi-bin/LJ/CProd/Birthdays.pm	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/LJ/CProd/Birthdays.pm	Mon Aug 30 16:40:13 2010 +0800
@@ -13,6 +13,7 @@
 
 package LJ::CProd::Birthdays;
 use base 'LJ::CProd';
+use strict;
 
 sub applicable {
     my ($class, $u) = @_;
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/LJ/CProd/ControlStrip.pm
--- a/cgi-bin/LJ/CProd/ControlStrip.pm	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/LJ/CProd/ControlStrip.pm	Mon Aug 30 16:40:13 2010 +0800
@@ -13,6 +13,7 @@
 
 package LJ::CProd::ControlStrip;
 use base 'LJ::CProd';
+use strict;
 
 sub applicable {
     my ($class, $u) = @_;
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/LJ/CProd/Feeds.pm
--- a/cgi-bin/LJ/CProd/Feeds.pm	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/LJ/CProd/Feeds.pm	Mon Aug 30 16:40:13 2010 +0800
@@ -13,6 +13,7 @@
 
 package LJ::CProd::Feeds;
 use base 'LJ::CProd';
+use strict;
 
 sub applicable {
     my ($class, $u) = @_;
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/LJ/CProd/FriendsFriends.pm
--- a/cgi-bin/LJ/CProd/FriendsFriends.pm	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/LJ/CProd/FriendsFriends.pm	Mon Aug 30 16:40:13 2010 +0800
@@ -13,6 +13,7 @@
 
 package LJ::CProd::FriendsFriends;
 use base 'LJ::CProd';
+use strict;
 
 sub applicable {
     my ($class, $u) = @_;
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/LJ/CProd/Polls.pm
--- a/cgi-bin/LJ/CProd/Polls.pm	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/LJ/CProd/Polls.pm	Mon Aug 30 16:40:13 2010 +0800
@@ -13,6 +13,7 @@
 
 package LJ::CProd::Polls;
 use base 'LJ::CProd';
+use strict;
 
 sub applicable {
     my ($class, $u) = @_;
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/LJ/CProd/UserPic.pm
--- a/cgi-bin/LJ/CProd/UserPic.pm	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/LJ/CProd/UserPic.pm	Mon Aug 30 16:40:13 2010 +0800
@@ -13,6 +13,7 @@
 
 package LJ::CProd::UserPic;
 use base 'LJ::CProd';
+use strict;
 
 sub applicable {
     my ($class, $u) = @_;
@@ -22,7 +23,7 @@ sub applicable {
 
 sub render {
     my ($class, $u, $version) = @_;
-    $ml_key = $class->get_ml($version);
+    my $ml_key = $class->get_ml($version);
     my $link = $class->clickthru_link('cprod.userpic.link', $version);
     my $user = LJ::ljuser($u);
     my $empty = '<div style="overflow: hidden; padding: 5px; width: 100px;
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/LJ/Constants.pm
--- a/cgi-bin/LJ/Constants.pm	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/LJ/Constants.pm	Mon Aug 30 16:40:13 2010 +0800
@@ -16,6 +16,7 @@
 # still can do LJ::BMAX_NAME, etc
 
 package LJ;
+use strict;
 
 use constant ENDOFTIME => 2147483647;
 $LJ::EndOfTime = 2147483647;  # for string interpolation
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/LJ/DBUtil.pm
--- a/cgi-bin/LJ/DBUtil.pm	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/LJ/DBUtil.pm	Mon Aug 30 16:40:13 2010 +0800
@@ -12,6 +12,7 @@
 # part of this distribution.
 
 package LJ::DBUtil;
+use strict;
 
 use lib "$LJ::HOME/cgi-bin";
 require "ljlib.pl";
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/LJ/JSUtil.pm
--- a/cgi-bin/LJ/JSUtil.pm	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/LJ/JSUtil.pm	Mon Aug 30 16:40:13 2010 +0800
@@ -12,6 +12,7 @@
 # part of this distribution.
 
 package LJ::JSUtil;
+use strict;
 
 #<LJFUNC>
 # name: LJ::JSUtil::autocomplete
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/LJ/Widget/IPPU.pm
--- a/cgi-bin/LJ/Widget/IPPU.pm	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/LJ/Widget/IPPU.pm	Mon Aug 30 16:40:13 2010 +0800
@@ -14,6 +14,7 @@
 # base class for in page popup widgets
 package LJ::Widget::IPPU;
 use base 'LJ::Widget';
+use strict;
 
 # load all subclasses
 LJ::ModuleLoader->autouse_subclasses("LJ::Widget::IPPU");
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/crumbs.pl
--- a/cgi-bin/crumbs.pl	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/crumbs.pl	Mon Aug 30 16:40:13 2010 +0800
@@ -15,6 +15,7 @@
 #
 # Stores all global crumbs and builds the crumbs hash
 
+use strict;
 use Errno qw(ENOENT);
 
 %LJ::CRUMBS = (
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/emailcheck.pl
--- a/cgi-bin/emailcheck.pl	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/emailcheck.pl	Mon Aug 30 16:40:13 2010 +0800
@@ -17,6 +17,7 @@
 #
 
 package LJ;
+use strict;
 
 # <LJFUNC>
 # name: LJ::check_email
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/lj-bml-blocks.pl
--- a/cgi-bin/lj-bml-blocks.pl	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/lj-bml-blocks.pl	Mon Aug 30 16:40:13 2010 +0800
@@ -13,7 +13,7 @@
 # A copy of that license can be found in the LICENSE file included as
 # part of this distribution.
 
-
+use strict;
 use lib "$LJ::HOME/cgi-bin";
 use LJ::Config;
 LJ::Config->load;
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/lj-bml-init.pl
--- a/cgi-bin/lj-bml-init.pl	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/lj-bml-init.pl	Mon Aug 30 16:40:13 2010 +0800
@@ -13,7 +13,7 @@
 # A copy of that license can be found in the LICENSE file included as
 # part of this distribution.
 
-
+use strict;
 use lib "$LJ::HOME/cgi-bin";
 use Errno qw(ENOENT);
 use LJ::Config;
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/ljdefaults.pl
--- a/cgi-bin/ljdefaults.pl	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/ljdefaults.pl	Mon Aug 30 16:40:13 2010 +0800
@@ -17,6 +17,9 @@
 # cgi-bin/ljconfig.pl.  If you don't, copy it from doc/ljconfig.pl.txt to cgi-bin
 # and edit it there.  This file only provides backup default values for upgrading.
 #
+
+use strict;
+no strict "vars";
 
 {
     package LJ;
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/modperl_subs.pl
--- a/cgi-bin/modperl_subs.pl	Sat Aug 28 19:24:43 2010 +0800
+++ b/cgi-bin/modperl_subs.pl	Mon Aug 30 16:40:13 2010 +0800
@@ -84,7 +84,6 @@ require "htmlcontrols.pl";
 require "htmlcontrols.pl";
 require "weblib.pl";
 require "imageconf.pl";
-require "propparse.pl";
 use LJ::Support;
 use LJ::CleanHTML;
 use LJ::Talk;
diff -r 9477663e2e77 -r e1b59dbfb947 cgi-bin/propparse.pl
--- a/cgi-bin/propparse.pl	Sat Aug 28 19:24:43 2010 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#!/usr/bin/perl
-#
-# This code was forked from the LiveJournal project owned and operated
-# by Live Journal, Inc. The code has been modified and expanded by
-# Dreamwidth Studios, LLC. These files were originally licensed under
-# the terms of the license supplied by Live Journal, Inc, which can
-# currently be found at:
-#
-# http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
-#
-# In accordance with the original license, this code and all its
-# modifications are provided under the GNU General Public License.
-# A copy of that license can be found in the LICENSE file included as
-# part of this distribution.
-
-
-package LJ;
-
-$verbose = 0;
-@obs = ();
-
-sub xlinkify
-{
-    my ($a) = $_[0];
-    $$a =~ s/\[var\[([A-Z0-9\_]{2,})\]\]/<a href=\"\/developer\/varinfo?$1\">$1<\/a>/g;
-    $$a =~ s/\[view\[(\S+?)\]\]/<a href=\"\/developer\/views\#$1\">$1<\/a>/g;
-}
-
-
-1;
diff -r 9477663e2e77 -r e1b59dbfb947 t/use-strict.t
--- a/t/use-strict.t	Sat Aug 28 19:24:43 2010 +0800
+++ b/t/use-strict.t	Mon Aug 30 16:40:13 2010 +0800
@@ -2,11 +2,6 @@
 
 use strict;
 use Test::More;
-
-unless ($ENV{TEST_TODO}) {
-    plan skip_all => "This test fails too much to be run for everyone.";
-    exit;
-}
 
 my %check;
 my @files = `$ENV{LJHOME}/bin/cvsreport.pl --map`;
@@ -15,6 +10,9 @@ foreach my $line (@files) {
     $line =~ s!//!/!g;
     my ($rel, $path) = split(/\t/, $line);
     next unless $path =~ /\.(pl|pm)$/;
+    # skip stuff we're less concerned about or don't control
+    next if $path =~ m:\b(doc|etc|fck|miscperl|src|s2)/:;
+    next if $path =~ m:/S2Theme/:;
     $check{$rel} = 1;
 }
 
@@ -23,7 +21,7 @@ my @bad;
 my @bad;
 foreach my $f (sort keys %check) {
     my $strict = 0;
-    open (my $fh, $f) or die;
+    open (my $fh, $f) or die "Could not open $f: $!";
     while (<$fh>) {
         $strict = 1 if /^use strict;/;
     }
--------------------------------------------------------------------------------