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: 38855
Status: resolved
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

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



Subject: ProhibitAmpersandSigils with parens
Date: Sat, 30 Aug 2008 09:21:31 +1000
To: bug-perl-critic [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
ProhibitAmpersandSigils allows defined &foo but doesn't with parens like defined(&foo) It'd be good if it let you do that (and leave ProhibitParensWithBuiltins to deny such parens, for those who don't like them). Perhaps something like:
--- ProhibitAmpersandSigils.pm.old 2008-07-25 08:48:25.000000000 +1000 +++ ProhibitAmpersandSigils.pm 2008-08-30 09:16:58.000000000 +1000 @@ -46,8 +46,20 @@ return if ( $elem !~ m{\A [&] }mx ); # ok - my $previous = $elem->sprevious_sibling(); - return if $previous and $EXEMPTIONS{$previous}; + # look up past parens to get say the "defined" in "defined(&foo)" + if (! $psib) { + my $parent = $elem->parent(); + if ($parent && $parent->isa('PPI::Statement::Expression')) { + my $grandparent = $parent->parent(); + if ($grandparent && $grandparent->isa('PPI::Structure::List')) { + my $word = $grandparent->sprevious_sibling(); + if ($word && $word->isa('PPI::Token::Word')) { + $psib = $word; + } + } + } + } + return if $psib and $EXEMPTIONS{$psib}; return $self->violation( $DESC, $EXPL, $elem ); }
-- "The most rewarding part was when he gave me my money."
Subject: Re: [rt.cpan.org #38855] ProhibitAmpersandSigils with parens
Date: Fri, 29 Aug 2008 22:05:28 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Chris Dolan <chris [...] chrisdolan.net>
That patch looks to me like it would do the job nicely. Chris On Aug 29, 2008, at 6:22 PM, Kevin Ryde via RT wrote: Show quoted text
> Fri Aug 29 19:22:06 2008: Request 38855 was acted upon. > Transaction: Ticket created by user42@zip.com.au > Queue: Perl-Critic > Subject: ProhibitAmpersandSigils with parens > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: user42@zip.com.au > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=38855 > > > > ProhibitAmpersandSigils allows > > defined &foo > > but doesn't with parens like > > defined(&foo) > > It'd be good if it let you do that (and leave > ProhibitParensWithBuiltins > to deny such parens, for those who don't like them). > > Perhaps something like: > > > --- ProhibitAmpersandSigils.pm.old 2008-07-25 08:48:25.000000000 +1000 > +++ ProhibitAmpersandSigils.pm 2008-08-30 09:16:58.000000000 +1000 > @@ -46,8 +46,20 @@ > > return if ( $elem !~ m{\A [&] }mx ); # ok > > - my $previous = $elem->sprevious_sibling(); > - return if $previous and $EXEMPTIONS{$previous}; > + # look up past parens to get say the "defined" in "defined(&foo)" > + if (! $psib) { > + my $parent = $elem->parent(); > + if ($parent && $parent->isa('PPI::Statement::Expression')) { > + my $grandparent = $parent->parent(); > + if ($grandparent && $grandparent->isa > ('PPI::Structure::List')) { > + my $word = $grandparent->sprevious_sibling(); > + if ($word && $word->isa('PPI::Token::Word')) { > + $psib = $word; > + } > + } > + } > + } > + return if $psib and $EXEMPTIONS{$psib}; > > return $self->violation( $DESC, $EXPL, $elem ); > } > > -- > "The most rewarding part was when he gave me my money."
Subject: Re: [rt.cpan.org #38855] ProhibitAmpersandSigils with parens
Date: Sat, 10 Jan 2009 08:45:04 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
A new diff allowing nested parens. Feels a touch excessive, but it's almost as easy to go up multiple levels as it is one.

Message body is not shown because sender requested not to inline it.

I've applied this patch in my branch, rt38855, along with a test for the behavior.
Subject: Re: [rt.cpan.org #38855] ProhibitAmpersandSigils with parens
Date: Sun, 15 Feb 2009 16:20:09 -0600
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
The branch has been merged to trunk.
This has been completed and released in Perl-Critic-1.097_002. http://search.cpan.org/~elliotjs/Perl-Critic-1.097_002 Thank you for submitting this ticket.