[libmoo-perl] 01/43: consistently disable once warning via Moo::_strictures

gregor herrmann gregoa at debian.org
Mon Dec 26 17:56:12 UTC 2016


This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to branch master
in repository libmoo-perl.

commit a8da6d933fd9f4fcd45b14a00fc51a3ddf75ed36
Author: Graham Knop <haarg at haarg.org>
Date:   Tue Jun 28 10:29:56 2016 -0400

    consistently disable once warning via Moo::_strictures
---
 lib/Moo.pm                |  1 -
 lib/Moo/HandleMoose.pm    |  5 ++---
 lib/Moo/_Utils.pm         | 12 ++++++------
 lib/Moo/_strictures.pm    |  1 +
 t/constructor-modify.t    |  1 -
 t/moo-object.t            |  2 --
 t/no-moo.t                | 12 ++++--------
 t/sub-quote.t             |  1 -
 xt/type-inflate-threads.t |  1 -
 9 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/lib/Moo.pm b/lib/Moo.pm
index c2b6182..5ec4f07 100644
--- a/lib/Moo.pm
+++ b/lib/Moo.pm
@@ -125,7 +125,6 @@ sub _set_superclasses {
   elsif (!$target->isa('Moo::Object')) {
     Moo->_constructor_maker_for($target);
   }
-  no warnings 'once'; # piss off. -- mst
   $Moo::HandleMoose::MOUSE{$target} = [
     grep defined, map Mouse::Util::find_meta($_), @_
   ] if Mouse::Util->can('find_meta');
diff --git a/lib/Moo/HandleMoose.pm b/lib/Moo/HandleMoose.pm
index d0c74ef..2a368fd 100644
--- a/lib/Moo/HandleMoose.pm
+++ b/lib/Moo/HandleMoose.pm
@@ -1,6 +1,5 @@
 package Moo::HandleMoose;
 use Moo::_strictures;
-no warnings 'once';
 use Moo::_Utils qw(_getstash);
 use Sub::Quote qw(quotify);
 use Carp qw(croak);
@@ -16,7 +15,7 @@ sub inject_all {
     if $Moo::sification::disabled;
   require Class::MOP;
   inject_fake_metaclass_for($_)
-    for grep $_ ne 'Moo::Object', do { no warnings 'once'; keys %Moo::MAKERS };
+    for grep $_ ne 'Moo::Object', keys %Moo::MAKERS;
   inject_fake_metaclass_for($_) for keys %Moo::Role::INFO;
   require Moose::Meta::Method::Constructor;
   @Moo::HandleMoose::FakeConstructor::ISA = 'Moose::Meta::Method::Constructor';
@@ -219,7 +218,7 @@ sub inject_real_metaclass_for {
     }
     $meta->add_role(Class::MOP::class_of($_))
       for grep !/\|/ && $_ ne $name, # reject Foo|Bar and same-role-as-self
-        do { no warnings 'once'; keys %{$Moo::Role::APPLIED_TO{$name}} };
+        keys %{$Moo::Role::APPLIED_TO{$name}}
   }
   $DID_INJECT{$name} = 1;
   $meta;
diff --git a/lib/Moo/_Utils.pm b/lib/Moo/_Utils.pm
index 019fbd4..a8b839b 100644
--- a/lib/Moo/_Utils.pm
+++ b/lib/Moo/_Utils.pm
@@ -1,12 +1,12 @@
 package Moo::_Utils;
-
-no warnings 'once'; # guard against -w
-
-sub _getglob { \*{$_[0]} }
-sub _getstash { \%{"$_[0]::"} }
-
 use Moo::_strictures;
 
+{
+  no strict 'refs';
+  sub _getglob { \*{$_[0]} }
+  sub _getstash { \%{"$_[0]::"} }
+}
+
 BEGIN {
   my ($su, $sn);
   $su = $INC{'Sub/Util.pm'} && defined &Sub::Util::set_subname
diff --git a/lib/Moo/_strictures.pm b/lib/Moo/_strictures.pm
index edac524..97ce92a 100644
--- a/lib/Moo/_strictures.pm
+++ b/lib/Moo/_strictures.pm
@@ -12,6 +12,7 @@ sub import {
   else {
     strict->import;
     warnings->import;
+    warnings->unimport('once');
   }
 }
 
diff --git a/t/constructor-modify.t b/t/constructor-modify.t
index 66369d3..56a5ec6 100644
--- a/t/constructor-modify.t
+++ b/t/constructor-modify.t
@@ -1,5 +1,4 @@
 use Moo::_strictures;
-no warnings 'once';
 use Test::More;
 use Test::Fatal;
 
diff --git a/t/moo-object.t b/t/moo-object.t
index ce659e8..2a8a044 100644
--- a/t/moo-object.t
+++ b/t/moo-object.t
@@ -2,8 +2,6 @@ use Moo::_strictures;
 use Test::More;
 use Test::Fatal;
 
-no warnings 'once';
-
 {
   package MyClass;
   use base 'Moo::Object';
diff --git a/t/no-moo.t b/t/no-moo.t
index bbbe1e8..28d4422 100644
--- a/t/no-moo.t
+++ b/t/no-moo.t
@@ -92,19 +92,15 @@ is(NoMooClass->has, "has!", 'has left alone');
 
 ok(!GlobalConflict->can('extends'), 'extends cleaned');
 is(GlobalConflict->has, "has!", 'has left alone');
-{
-  no warnings 'once';
-  is($GlobalConflict::around, "has!", 'package global left alone');
-}
+
+is($GlobalConflict::around, "has!", 'package global left alone');
 
 ok(RollerTiny->can('around'), 'around left alone');
 is(RollerTiny->with, "with!", 'with left alone');
 
 ok(!GlobalConflict2->can('extends'), 'extends cleaned');
 is(GlobalConflict2->has, "has!", 'has left alone');
-{
-  no warnings 'once';
-  is($GlobalConflict2::after, "has!", 'package global left alone');
-}
+
+is($GlobalConflict2::after, "has!", 'package global left alone');
 
 done_testing;
diff --git a/t/sub-quote.t b/t/sub-quote.t
index 9beccd4..9ef5a48 100644
--- a/t/sub-quote.t
+++ b/t/sub-quote.t
@@ -463,7 +463,6 @@ like exception {
 }
 
 {
-  no warnings 'once';
   $Bar::baz = 3;
   my $inlined_code = inlinify q{
     package Bar;
diff --git a/xt/type-inflate-threads.t b/xt/type-inflate-threads.t
index 2e3f97f..cb35d6c 100644
--- a/xt/type-inflate-threads.t
+++ b/xt/type-inflate-threads.t
@@ -13,7 +13,6 @@ use Type::Tiny;
 my $str = sub {
   die unless defined $_[0] && !ref $_[0];
 };
-no warnings 'once';
 $Moo::HandleMoose::TYPE_MAP{$str} = sub {
   require Moose::Util::TypeConstraints;
   Moose::Util::TypeConstraints::find_type_constraint("Str");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmoo-perl.git



More information about the Pkg-perl-cvs-commits mailing list