On Oct 9, 2006, at 4:51 AM, Paul Cochrane (via RT) wrote:
# New Ticket Created by "Paul Cochrane"
# Please include the string: [perl #40482]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40482 >
Hi,
This patch adds a new policy for the Parrot Perl::Critic tests, namely
to check that the shebang line doesn't use 'perl -w', rather 'use
warnings;' and that the shebang line doesn't use something unix
specific such as '#!/usr/bin/perl' and rather '#! perl'. Would it be
a good idea to group all of the code standards-related stuff into a
directory CodeStandards? As such, should I then make a patch for
CodeLayout::UseParrotCoda to go under CodeStandards::UseParrotCoda
instead? I'm also wondering what the policy is on svn Id keywords in
files, and whether or not the svn:keywords property is set to a
particular value. I don't think there's a standard or anything
defined for this yet. Should there be? If so, should I put a request
into RT?
Paul,
A few comments:
* No, this shouldn't go into UseParrotCoda. Separately enabled
policies are more flexible.
* In fact, yours should probably be broken into two policies. Perhaps
CodeStandards::ProhibitShebangWarningsArg
and
CodeStandards::RequirePortableShebang
* This would be a nice addition to core Perl::Critic!
* The -w catcher fails on "#!perl -T -w" or other variations on
argument lists. Perhaps forbid any arguments at all?
* The shebang line is always a PPI::Token::Comment and is always on
the first line. Take a look at this utility function from
Perl::Critic::Utils:
sub is_script {
my $doc = shift;
my $first_comment = $doc->find_first('PPI::Token::Comment');
return if !$first_comment;
return if $first_comment->location()->[0] != 1;
return $first_comment =~ m{ \A \#\! }mx;
}
Now that I'm talking about it, I should write a
Perl::Critic::Utils::get_shebang() function...
Chris
--
Chris Dolan, Software Developer, http://www.chrisdolan.net/
Public key: http://www.chrisdolan.net/public.key
vCard: http://www.chrisdolan.net/ChrisDolan.vcf