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

People
Owner: thaljef [...] cpan.org
Requestors: perl [...] galumph.com
Cc:
AdminCc:

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



CC: Heiko <heiko [...] hexco.de>
Subject: ProhibitStringyEval doesn't handle "expressions giving values".
Date: Sun, 09 Mar 2008 17:01:25 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
BuiltinFunctions::ProhibitStringyEval gives Expression form of "eval" at line 12, column 6. See page 161 of PBP. (Severity: 5) for code: my $x = 2; my $y = '4711 * $x'; # reevaluate $y = eval "qq{$y}"; Perl has this useful feature of evaluation at runtime. It would be nice, if we could give the critique only when the reevaluation yields code, but not for reevaluating $variables in expressions giving values. But I have no idea how to detect that.
Subject: Re: [rt.cpan.org #33939] ProhibitStringyEval doesn't handle "expressions giving values".
Date: Sun, 09 Mar 2008 17:41:35 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Elliot Shank via RT wrote: Show quoted text
> BuiltinFunctions::ProhibitStringyEval gives > > Expression form of "eval" at line 12, column 6. See page 161 of PBP. (Severity: 5) > > for code: > > my $x = 2; > my $y = '4711 * $x'; > > # reevaluate > $y = eval "qq{$y}"; > > Perl has this useful feature of evaluation at runtime. > It would be nice, if we could give the critique only when the reevaluation > yields code, but not for reevaluating $variables in expressions giving values. > But I have no idea how to detect that.
An interesting quandary. But Perl::Critic can't really handle this case without actually evaluating code. How is Perl::Critic supposed to statically determine that $y doesn't contain '5}; print $_ foreach (-2..2); {'? I don't think that this case can be addressed, given that Perl::Critic specifically doesn't execute any analyzed code.
I agree. This is beyond Perl-Critic's capabilities. A "## no critic" will have to do. Hopefully that pattern doesn't appear too often :)