Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 20481
Status: resolved
Worked: 30 min
Priority: 0/
Queue: Perl-Critic

People
Owner: thaljef [...] cpan.org
Requestors: andy [...] petdance.com
Cc:
AdminCc:

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



Subject: Makefile.PL mistaken for a module
Date: Sun, 16 Jul 2006 00:43:03 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Andy Lester <andy [...] petdance.com>
I ran perlcritic on my Makefile.PL and it trips this: ./Makefile.PL: Module does not end with '1;' at line 24, column 1. Must end with a recognizable true value. (Severity: 4) -- Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance
Subject: Re: [rt.cpan.org #20481] Makefile.PL mistaken for a module
Date: Sun, 16 Jul 2006 09:52:53 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Chris Dolan <chris [...] chrisdolan.net>
On Jul 16, 2006, at 12:43 AM, andy@petdance.com via RT wrote: Show quoted text
> I ran perlcritic on my Makefile.PL and it trips this: > > ./Makefile.PL: Module does not end with '1;' at line 24, column 1. > Must end with a recognizable true value. (Severity: 4)
Simple solution: add "#!perl" to the top to let Perl::Critic know its a program not a module. However, I posit that if you need to run Perl::Critic to evaluate the maintainability of your Makefile.PL, then your Makefile.PL is too complex. :-) Seriously though, I think that Makefile/Build.PL is a special case because it's (usually) pidgin-perl where brevity is important. Maybe we should create some pre-defined Configs for special cases like Makefile.PL which turn off some policies. Chris -- Chris Dolan, Software Developer, http://www.chrisdolan.net/ Public key: http://www.chrisdolan.net/public.key vCard: http://www.chrisdolan.net/ChrisDolan.vcf
I had a thought in the shower. It might be becasue I had a package declaration in the Makefile.PL that made PC think that it was a module. Whether or not we have special rules for Makefile.PL, I don't think that PC should think that Makefile.PL is a module.
Subject: Re: [rt.cpan.org #20481] Makefile.PL mistaken for a module
Date: Sun, 16 Jul 2006 20:19:22 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Chris Dolan <chris [...] clotho.com>
On Jul 16, 2006, at 10:04 AM, Andy Lester via RT wrote: Show quoted text
> > Queue: Perl-Critic > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=20481 > > > I had a thought in the shower. It might be becasue I had a package > declaration in the Makefile.PL that made PC think that it was a > module. > > Whether or not we have special rules for Makefile.PL, I don't think > that > PC should think that Makefile.PL is a module. >
<brainstorming> But how would it know? P::C doesn't make use of the filename in any way. So, it would have to trigger on the existence of a WriteMakefile call or something. Does that seem brittle? </brainstorming> Chris -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. 608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703 vCard: http://www.chrisdolan.net/ChrisDolan.vcf Clotho Advanced Media, Inc. - Creators of MediaLandscape Software (http://www.media-landscape.com/) and partners in the revolutionary Croquet project (http://www.opencroquet.org/)
Subject: Re: [rt.cpan.org #20481] Makefile.PL mistaken for a module
Date: Sun, 16 Jul 2006 20:23:11 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Andy Lester <andy [...] petdance.com>
On Jul 16, 2006, at 8:20 PM, chris@clotho.com via RT wrote: Show quoted text
> But how would it know? P::C doesn't make use of the filename in any > way.
Why doesn't it? That's pretty safe I would think. -- Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance
What if is_script() looked for the absence of a package, instead of the presence of a shebang. Like this... sub is_script { my $doc = shift; # Look for a "package" statement, other than "main" if ( my $packages_ref = $doc->find('PPI::Statement::Package') ) { return if any{ $_ !~ m{\b main \b} } @{ $packages_ref }; } return 1; }
Subject: Re: [rt.cpan.org #20481] Makefile.PL mistaken for a module
Date: Mon, 17 Jul 2006 03:03:23 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Chris Dolan <chris [...] clotho.com>
On Jul 16, 2006, at 9:23 PM, Jeffrey Thalhammer via RT wrote: Show quoted text
> Queue: Perl-Critic > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=20481 > > > What if is_script() looked for the absence of a package, instead of > the > presence of a shebang. Like this... > > sub is_script { > my $doc = shift; > > # Look for a "package" statement, other than "main" > if ( my $packages_ref = $doc->find('PPI::Statement::Package') ) { > return if any{ $_ !~ m{\b main \b} } @{ $packages_ref }; > } > > return 1; > }
Makes sense to me. That should be find_first(), not find(), however. Chris -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. 608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703 vCard: http://www.chrisdolan.net/ChrisDolan.vcf Clotho Advanced Media, Inc. - Creators of MediaLandscape Software (http://www.media-landscape.com/) and partners in the revolutionary Croquet project (http://www.opencroquet.org/)
Subject: Re: [rt.cpan.org #20481] Makefile.PL mistaken for a module
Date: Mon, 17 Jul 2006 03:05:03 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Chris Dolan <chris [...] clotho.com>
On Jul 16, 2006, at 8:23 PM, andy@petdance.com via RT wrote: Show quoted text
> On Jul 16, 2006, at 8:20 PM, chris@clotho.com via RT wrote: >
>> But how would it know? P::C doesn't make use of the filename in any >> way.
> > Why doesn't it? That's pretty safe I would think.
Sometimes the filename is inaccessible and we have only the source code to work with: % cat Makefile.PL | perlcritic Chris -- Chris Dolan, Software Developer, Clotho Advanced Media Inc. 608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703 vCard: http://www.chrisdolan.net/ChrisDolan.vcf Clotho Advanced Media, Inc. - Creators of MediaLandscape Software (http://www.media-landscape.com/) and partners in the revolutionary Croquet project (http://www.opencroquet.org/)
This is (partially) fixed in revision 2568. If you feed the file over a pipe, then it will still mistake the file as a module. But if the file is named as an argument to perlcritic (or with Test::Perl::Critic) then any filename ending with ".PL" will be classified as a script.
Subject: [rt.cpan.org #20481]
Date: Tue, 22 Jul 2008 08:18:31 -0700
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Fix released in v1.090.