Skip Menu |

This queue is for tickets about the Module-CPANTS-Analyse CPAN distribution.

Report information
The Basics
Id: 38727
Status: resolved
Priority: 0/
Queue: Module-CPANTS-Analyse

People
Owner: Nobody in particular
Requestors: cjm [...] cpan.org
Support [...] RoxSoft.co.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.82
Fixed in: (no value)



Subject: Use strict test does not recognise use Moose
The tests for use strict and use warnings do not recognise use Moose and use Moose::Role as being equivalent. Attached a patch to fix this
Subject: uses.patch
--- Uses.pm 2008-08-26 10:31:04.000000000 +0100 +++ Uses.pm 2008-08-26 10:37:57.000000000 +0100 @@ -81,11 +81,15 @@ my ($strict)=$uses->{'strict'}; my ($moose)=$uses->{'Moose'}; - return 0 unless $strict; + my ($moose_role)=$uses->{'Moose::Role'}; + return 0 unless $strict or $moose or $moose_role; my $total = $strict->{in_code}; if ($moose) { $total += $moose->{in_code}; } + if ($moose_role) { + $total += $moose_role->{in_code}; + } return 1 if $total >= @$modules; return 0; }, @@ -101,8 +105,17 @@ my $uses=$d->{uses}; return 0 unless $modules && $uses; my ($warnings)=$uses->{'warnings'}; - return 0 unless $warnings; - return 1 if $warnings->{in_code} >= @$modules; + my ($moose)=$uses->{'Moose'}; + my ($moose_role)=$uses->{'Moose::Role'}; + return 0 unless $warnings or $moose or $moose_role; + my $total = $warnings->{in_code}; + if ($moose) { + $total += $moose->{in_code}; + } + if ($moose_role) { + $total += $moose_role->{in_code}; + } + return 1 if $total >= @$modules; return 0; }, },
Here's an improved version of the patch. It adds MooseX::Types to the list of modules that add strict & warnings. It also uses a loop, so it's easy to add more.
--- Module/CPANTS/Kwalitee/Uses.pm 2009-10-21 13:03:58.000000000 -0500 +++ Module/CPANTS/Kwalitee/Uses.pm 2009-10-21 16:30:01.595332228 -0500 @@ -78,14 +78,12 @@ my $modules=$d->{modules}; my $uses=$d->{uses}; return 0 unless $modules && $uses; - - my ($strict)=$uses->{'strict'}; - my ($moose)=$uses->{'Moose'}; - return 0 unless $strict; - my $total = $strict->{in_code}; - if ($moose) { - $total += $moose->{in_code}; - } + + my $total = 0; + foreach my $package (qw(strict Moose Moose::Role MooseX::Types)) { + my ($pkg_uses)=$uses->{$package}; + $total += $pkg_uses->{in_code} if $pkg_uses; + } # end foreach $package that provides strictness return 1 if $total >= @$modules; return 0; }, @@ -100,9 +98,13 @@ my $modules=$d->{modules}; my $uses=$d->{uses}; return 0 unless $modules && $uses; - my ($warnings)=$uses->{'warnings'}; - return 0 unless $warnings; - return 1 if $warnings->{in_code} >= @$modules; + + my $total = 0; + foreach my $package (qw(warnings Moose Moose::Role MooseX::Types)) { + my ($pkg_uses)=$uses->{$package}; + $total += $pkg_uses->{in_code} if $pkg_uses; + } # end foreach $package that provides warnings + return 1 if $total >= @$modules; return 0; }, },
Am Mi 21. Okt 2009, 17:32:38, CJM schrieb: Show quoted text
> Here's an improved version of the patch. It adds MooseX::Types to the > list of modules that add strict & warnings. It also uses a loop, so > it's easy to add more.
MooseX::Types does *not* enable use strict: A MooseX::Types is just a normal Perl module. Unlike Moose itself, it does not install use strict and use warnings in your class by default, so this is up to you.
On Tue, Jan 24, 2012 5:23:26 AM, ABRAXXA wrote: Show quoted text
> MooseX::Types does *not* enable use strict: > > A MooseX::Types is just a normal Perl module. Unlike Moose itself, it > does not install use strict and use warnings in your class by default, > so this is up to you.
Starting with MooseX::Types 0.04 it most certainly does enable strict and warnings. From its Changes: 0.04 2007-08-09 - Automatically set strict and warnings like Moose does From its import method: # everyone should want this strict->import; warnings->import;
fixed on github