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

People
Owner: Nobody in particular
Requestors: adamk [...] cpan.org
Cc:
AdminCc:

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



Subject: Two-argument open is legitimate in some situations
Two-argument open is considered legitimate in scenarios where three-argument open is not available. Skip two-argument open errors if and only if that module/file contains a Perl version declaration older than 5.006. That is, a two-agument critique in the following case is a correctable false positive. use 5.005; open( FOO, ">$file" );
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 15:02:19 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Adam Kennedy via RT wrote: Show quoted text
> Two-argument open is considered legitimate in scenarios where > three-argument open is not available. > > Skip two-argument open errors if and only if that module/file contains a > Perl version declaration older than 5.006. > > That is, a two-agument critique in the following case is a correctable > false positive. > > use 5.005; > open( FOO, ">$file" );
I've thought on this a bit and I now disagree. The problem is old code that has never had the use statement "upgraded". The user may be running nothing but, say, 5.6, and yet the code, for whatever reason, has never had this changed to "use 5.006". The policy should still complain if they've got a two argument open. If you've got a distribution that's supposed to support older perl versions, put a perlcriticrc in that distribution that turns this policy off. Different distributions should not share perlcriticrc files.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Mon, 31 Mar 2008 11:26:06 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Elliot Shank via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=34385 > > > Adam Kennedy via RT wrote: >
>> Two-argument open is considered legitimate in scenarios where >> three-argument open is not available. >> >> Skip two-argument open errors if and only if that module/file contains a >> Perl version declaration older than 5.006. >> >> That is, a two-agument critique in the following case is a correctable >> false positive. >> >> use 5.005; >> open( FOO, ">$file" ); >>
> > I've thought on this a bit and I now disagree. The problem is old code that has never had the use statement "upgraded". The user may be running nothing but, say, 5.6, and yet the code, for whatever reason, has never had this changed to "use 5.006". The policy should still complain if they've got a two argument open. > > If you've got a distribution that's supposed to support older perl versions, put a perlcriticrc in that distribution that turns this policy off. Different distributions should not share perlcriticrc files. >
"The user" ? If the AUTHOR has declared a version of Perl is supported, then the full set of users will have a variety of versions. Of look at it this way. If the "problem" is that the use 5.005 hasn't been upgraded, then just throw down a blanket Perl::Critic rule that says that anyone requiring a version older than 5.8.8 is making a mistake. Who are we to declare, without reading their code, that all situations in which the code declares support for old perl's must be a mistake. Adam K
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 20:09:40 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Adam Kennedy via RT wrote: Show quoted text
> Queue: Perl-Critic Ticket <URL: > http://rt.cpan.org/Ticket/Display.html?id=34385 > > > Elliot Shank via RT wrote:
>> Adam Kennedy via RT wrote:
>>> Two-argument open is considered legitimate in scenarios where >>> three-argument open is not available. >>> >>> Skip two-argument open errors if and only if that module/file >>> contains a Perl version declaration older than 5.006. >>>
>> I've thought on this a bit and I now disagree. The problem is old >> code that has never had the use statement "upgraded". The user may >> be running nothing but, say, 5.6, and yet the code, for whatever >> reason, has never had this changed to "use 5.006". The policy >> should still complain if they've got a two argument open. >>
> "The user" ?
The user of perlcritic. Show quoted text
> If the AUTHOR has declared a version of Perl is supported, then the > full set of users will have a variety of versions. > > Of look at it this way. > > If the "problem" is that the use 5.005 hasn't been upgraded, then > just throw down a blanket Perl::Critic rule that says that anyone > requiring a version older than 5.8.8 is making a mistake. > > Who are we to declare, without reading their code, that all > situations in which the code declares support for old perl's must be > a mistake.
Let's say I'm looking at this with self interest in mind. At work, there's old code with old "use 5.xxx" declarations in it. I don't give a damn what that statement says. I want perlcritic to complain about two argument open, full stop.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Mon, 31 Mar 2008 12:05:20 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Show quoted text
> Let's say I'm looking at this with self interest in mind. At work, there's old code with old "use 5.xxx" declarations in it. I don't give a damn what that statement says. I want perlcritic to complain about two argument open, full stop
Then the correct action would be to correct the use 5.xxx, and then perlcritic wouldn't ignore 2-argument open. Adam K
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 20:17:06 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Adam Kennedy via RT wrote: Two-argument open is considered legitimate in scenarios where Show quoted text
> three-argument open is not available. > > Skip two-argument open errors if and only if that module/file contains a > Perl version declaration older than 5.006. > > That is, a two-agument critique in the following case is a correctable > false positive. > > use 5.005; > open( FOO, ">$file" );
Actually, this is not a false positive. It /is/ a two argument open. Regardless of what the perl version is.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 20:19:31 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Adam Kennedy via RT wrote: Show quoted text
> Queue: Perl-Critic Ticket <URL: > http://rt.cpan.org/Ticket/Display.html?id=34385 > > >
>> Let's say I'm looking at this with self interest in mind. At work, >> there's old code with old "use 5.xxx" declarations in it. I don't >> give a damn what that statement says. I want perlcritic to >> complain about two argument open, full stop
> > Then the correct action would be to correct the use 5.xxx, and then > perlcritic wouldn't ignore 2-argument open.
Look, the policy is doing what it's supposed to do. It complains about two argument open. If you don't want the policy to complain, turn it off.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Mon, 31 Mar 2008 12:14:13 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Elliot Shank via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=34385 > > > Adam Kennedy via RT wrote: > Two-argument open is considered legitimate in scenarios where >
>> three-argument open is not available. >> >> Skip two-argument open errors if and only if that module/file contains a >> Perl version declaration older than 5.006. >> >> That is, a two-agument critique in the following case is a correctable >> false positive. >> >> use 5.005; >> open( FOO, ">$file" ); >>
> > Actually, this is not a false positive. It /is/ a two argument open. Regardless of what the perl version is.
The actual detection of a two-argument open is correctly done. The decision that it is "wrong" is incorrect, as two-argument open is the only form of open that exists, and we're telling people not to use something that is the only way to do it, and to use a language construct that does not exist. The use of three-argument open with 5.005 also triggers a Perl::MinimumVersion violation. Adam K
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Mon, 31 Mar 2008 12:16:47 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Elliot Shank via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=34385 > > > Adam Kennedy via RT wrote: >
>> Queue: Perl-Critic Ticket <URL: >> http://rt.cpan.org/Ticket/Display.html?id=34385 > >> >> >>
>>> Let's say I'm looking at this with self interest in mind. At work, >>> there's old code with old "use 5.xxx" declarations in it. I don't >>> give a damn what that statement says. I want perlcritic to >>> complain about two argument open, full stop >>>
>> Then the correct action would be to correct the use 5.xxx, and then >> perlcritic wouldn't ignore 2-argument open. >>
> > Look, the policy is doing what it's supposed to do.
No. The IMPLEMENTATION is doing what it is supposed to do. The Policy (encouraging people to use a better form of open) is not doing what it is supposed to do. Adam K
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 20:25:37 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Adam Kennedy via RT wrote: Show quoted text
> The use of three-argument open with 5.005 also triggers a > Perl::MinimumVersion violation.
Modules::PerlMinimumVersion is part of P::C::More, not the core distribution.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Mon, 31 Mar 2008 12:22:34 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Elliot Shank via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=34385 > > > Adam Kennedy via RT wrote: >
>> The use of three-argument open with 5.005 also triggers a >> Perl::MinimumVersion violation. >>
> > Modules::PerlMinimumVersion is part of P::C::More, not the core distribution. >
The recommendation of three-argument open in 5.005 situations is a case of us knowingly recommending the user introduce back-compatibility bugs into their software. P:MV is how we detect that bug. The fact that back-compatibility bug detection is not available in the core doesn't change the fact we're recommending that people introduce bugs into their software when we are capable of not making that recommendation. Adam K
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 20:57:56 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Adam Kennedy via RT wrote: Show quoted text
> Elliot Shank via RT wrote:
>> Look, the policy is doing what it's supposed to do.
> No. The IMPLEMENTATION is doing what it is supposed to do. > > The Policy (encouraging people to use a better form of open) is not > doing what it is supposed to do.
On this I will disagree with you. The policy does what it is supposed to. What you want is a different policy that complains about using three argument open in cases where you want to be compatible with 5.005.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Mon, 31 Mar 2008 12:54:54 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Elliot Shank via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=34385 > > > Adam Kennedy via RT wrote: >
>> Elliot Shank via RT wrote: >>
>>> Look, the policy is doing what it's supposed to do. >>>
>> No. The IMPLEMENTATION is doing what it is supposed to do. >> >> The Policy (encouraging people to use a better form of open) is not >> doing what it is supposed to do. >>
> > > On this I will disagree with you. The policy does what it is supposed to. What you want is a different policy that complains about using three argument open in cases where you want to be compatible with 5.005. > >
As you mentioned, THAT policy already exists in ::More, and will directly collide with the two-argument open. If ::More is installed, perlcritic will not allow ANY open call under 5.005, since all variations trigger either the "don't use two argument open" policy or "anything other than two-argument policy is a bug" policy. You have to no-critic every single open call in code that is 5.005.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 21:14:03 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Adam Kennedy via RT wrote: Show quoted text
> Elliot Shank via RT wrote:
>> On this I will disagree with you. The policy does what it is >> supposed to. What you want is a different policy that complains >> about using three argument open in cases where you want to be >> compatible with 5.005. >> >>
> As you mentioned, THAT policy already exists in ::More, and will > directly collide with the two-argument open. > > If ::More is installed, perlcritic will not allow ANY open call under > 5.005, since all variations trigger either the "don't use two > argument open" policy or "anything other than two-argument policy is > a bug" policy. > > You have to no-critic every single open call in code that is 5.005.
Modules::PerlMinimumVersion has nothing to do with open. All it cares about is a version statement. *sigh* Look, there's no way that the defaults for P::C can please everyone. The defaults don't even please the P::C developers. (See t/40_perlcriticrc in the distro.) If you want a policy that complains about three argument open, I'll even write it for you.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Mon, 31 Mar 2008 13:21:01 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Elliot Shank via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=34385 > > > Adam Kennedy via RT wrote: >
>> Elliot Shank via RT wrote: >>
>>> On this I will disagree with you. The policy does what it is >>> supposed to. What you want is a different policy that complains >>> about using three argument open in cases where you want to be >>> compatible with 5.005. >>> >>> >>>
>> As you mentioned, THAT policy already exists in ::More, and will >> directly collide with the two-argument open. >> >> If ::More is installed, perlcritic will not allow ANY open call under >> 5.005, since all variations trigger either the "don't use two >> argument open" policy or "anything other than two-argument policy is >> a bug" policy. >> >> You have to no-critic every single open call in code that is 5.005. >>
> > Modules::PerlMinimumVersion has nothing to do with open. All it cares about is a version statement. >
Speaking as the person that wrote it, no. P:MV looks at the version statement, yes. And THEN it scans the document in a similar way to Perl::Critic. Except instead of scanning for policy violations, it scans for expressions that we know require a certain version of Perl. Things like three-value open. It collects all the dependencies, both explicit and implicit, and reports on both the minimum versions, and reports problems where you THOUGHT you had an explicit dependency on 5.005, but you ACTUALLY used a language structure that had a dependency on 5.006. Show quoted text
> *sigh* > > Look, there's no way that the defaults for P::C can please everyone. The defaults don't even please the P::C developers. (See t/40_perlcriticrc in the distro.) > > If you want a policy that complains about three argument open, I'll even write it for you. >
That would be great. Except of course it will collide with the two-argument open. You can't use two-argument, and you can't use three argument. The policies should not be blind. Otherwise why not have a policy to prevent "use vars" for no reason at all. All the policies were introduced for a reason. And the reason wasn't "don't use two-argument", it was "don't use two-argument BECAUSE ...". It's the because that is important here. Adam K
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 21:47:25 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Adam Kennedy via RT wrote: Show quoted text
>> Modules::PerlMinimumVersion has nothing to do with open. All it >> cares about is a version statement. >>
> Speaking as the person that wrote it, no.
Ok, we're talking about different things. When I say Modules::PerlMinimumVersion, I mean Perl::Critic::Policy::Modules::PerlMinimumVersion. Which doesn't care about anything other than that there's version statement. Show quoted text
>> Look, there's no way that the defaults for P::C can please >> everyone. The defaults don't even please the P::C developers. >> (See t/40_perlcriticrc in the distro.) >> >> If you want a policy that complains about three argument open, I'll >> even write it for you. >>
> That would be great. Except of course it will collide with the > two-argument open. You can't use two-argument, and you can't use > three argument.
Who says you can't have conflicting policies? Yes, you can't have conflicting policies enabled at the same time, obviously. But there's no reason that you can't configure which one you want to be active at a time. You seem to want all defaults to operate the way you see things. And I don't think that that's possible. Again, it isn't possible even for the P::C developers. Every time I bring up configuration, you ignore it. If you disagree with a policy, turn it off.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Mon, 31 Mar 2008 14:14:12 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Show quoted text
> You seem to want all defaults to operate the way you see things. And I don't think that that's possible. Again, it isn't possible even for the P::C developers. Every time I bring up configuration, you ignore it. If you disagree with a policy, turn it off. >
No, I want defaults that don't suggest introducing bugs. Where the issue comes down to one of personal preference, I don't care. Where the issue comes down to suggesting bugs by default, or not doing so, it isn't a question of opinion or preferences. Adam K
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Mon, 31 Mar 2008 14:24:08 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Show quoted text
> Who says you can't have conflicting policies? Yes, you can't have conflicting policies enabled at the same time, obviously. But there's no reason that you can't configure which one you want to be active at a time. > > You seem to want all defaults to operate the way you see things. And I don't think that that's possible. Again, it isn't possible even for the P::C developers. Every time I bring up configuration, you ignore it. If you disagree with a policy, turn it off. > >
Anyways, I'm done. It's obvious you wish to retain this functionality. Instead, I would like to request an enhancement that allows me to turn this policy off for use 5.005 cases as you suggest, without having to turn it off for ALL cases, since the two-argument open checks are useful in the normal case. Adam K
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 22:49:18 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Adam Kennedy via RT wrote: Show quoted text
> Instead, I would like to request an enhancement that allows me to > turn this policy off for use 5.005 cases as you suggest, without > having to turn it off for ALL cases, since the two-argument open > checks are useful in the normal case.
I'm starting a P::C::Compatibility distro.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 22:50:51 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Adam Kennedy via RT wrote: Show quoted text
> It's obvious you wish to retain this functionality.
I'm not the only one on the project. :]
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Mon, 31 Mar 2008 14:46:41 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Elliot Shank via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=34385 > > > Adam Kennedy via RT wrote: >
>> It's obvious you wish to retain this functionality. >>
> > > I'm not the only one on the project. :] > >
Well, I haven't heard any other responses, and similar bug reports (where the policy implementation reported false positives that would have introduced bugs in order to fix) have been reported and fixed just fine in the past. Adam K
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 21:09:46 -0700 (PDT)
To: bug-Perl-Critic [...] rt.cpan.org
From: Jeffrey Thalhammer <jeffrey.thalhammer [...] yahoo.com>
I am watching the discussion, but I haven't formed an opinion yet. -Jeff
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 23:20:10 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Chris Dolan <chris [...] chrisdolan.net>
On Mar 30, 2008, at 10:49 PM, Elliot Shank via RT wrote: Show quoted text
> > I'm starting a P::C::Compatibility distro. >
This is an EXCELLENT idea! Bravo Elliot! Using Perl::Critic to solve real bugs makes me happy. If only I had a little more free time, I would write some specific policies for Build.PL (e.g. insist on "create_makefile_pl => 'traditional'" and validate "dynamic_config => 0|1") and Makefile.PL. Chris
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 30 Mar 2008 23:48:16 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Chris Dolan via RT wrote: Show quoted text
> On Mar 30, 2008, at 10:49 PM, Elliot Shank via RT wrote:
>> I'm starting a P::C::Compatibility distro. >>
> > This is an EXCELLENT idea! Bravo Elliot! Using Perl::Critic to > solve real bugs makes me happy. If only I had a little more free > time, I would write some specific policies for Build.PL (e.g. insist > on "create_makefile_pl => 'traditional'" and validate "dynamic_config > => 0|1") and Makefile.PL.
Actually, I've been thinking of adding some sort of version information to P::C::Document. For example, it would be good if we could tell whether "say" was turned on so that any policy that is concerned with print could treat say the same way.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Mon, 31 Mar 2008 15:46:07 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: Adam Kennedy <adamkennedybackup [...] gmail.com>
Elliot Shank via RT wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=34385 > > > Chris Dolan via RT wrote: >
>> On Mar 30, 2008, at 10:49 PM, Elliot Shank via RT wrote: >>
>>> I'm starting a P::C::Compatibility distro. >>> >>>
>> This is an EXCELLENT idea! Bravo Elliot! Using Perl::Critic to >> solve real bugs makes me happy. If only I had a little more free >> time, I would write some specific policies for Build.PL (e.g. insist >> on "create_makefile_pl => 'traditional'" and validate "dynamic_config >> => 0|1") and Makefile.PL. >>
> > Actually, I've been thinking of adding some sort of version information to P::C::Document. For example, it would be good if we could tell whether "say" was turned on so that any policy that is concerned with print could treat say the same way. > >
Only downside, that sort of thing goes fractal very very quickly. :) Adam K
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Tue, 1 Apr 2008 22:52:58 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Chris Dolan <chris [...] chrisdolan.net>
On Mar 30, 2008, at 8:23 PM, Adam Kennedy via RT wrote: Show quoted text
> > Queue: Perl-Critic > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=34385 > > > Elliot Shank via RT wrote:
>>> Look, the policy is doing what it's supposed to do.
> No. The IMPLEMENTATION is doing what it is supposed to do. > > The Policy (encouraging people to use a better form of open) is not > doing what it is supposed to do. > > Adam K
In this case, Elliot is right. The policy declares that the right form of open() is the three-arg form. The choice to enable that policy or not falls to the user. It is irrelevant whether you agree with with the policy or whether it is appropriate for 5.005. Now, on the other hand, the fact that the policy implementation says sub default_severity { return $SEVERITY_HIGHEST } is relevant. That our default severities do not take into account the environment is a philosophy choice that implicitly says that compromising code to support 5.005 is a poor choice. I mildly agree with that philosophy in general, but I STRONGLY agree with it with regard to three-arg open. As we all know quite well, two arg open is a serious security risk. I think it would be better for the Perl community to patch 5.005 and make a new release (if there are enough tuits) than regress working three-arg code back to two-arg style. I'm quite comfortable saying that 5.005-compatible code is a second- class citizen in this modern 5.8/5.10 world. When I started programming in Perl, Perl4 was the "bad old days". Now, I declare that 5.005 is the "bad old days" and the sooner we close the door on that world, the better. Chris
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Wed, 2 Apr 2008 16:13:04 +1100
To: bug-Perl-Critic [...] rt.cpan.org
From: "Adam Kennedy" <adamkennedybackup [...] gmail.com>
Show quoted text
> The policy declares that the right form of open() is the three-arg > form. The choice to enable that policy or not falls to the user. It > is irrelevant whether you agree with with the policy or whether it is > appropriate for 5.005.
I certainly AGREE with the policy. I just assert that non-functional code is never "right". And on 5.005 three-argument open is non-functional. Lacking a 5.005 upgrade, an open statement with a known potential security issue is still preferable to an open statement that causes the compiler to throw a syntax error. I'm sure there's other examples of things that are "more right" but only come with Perl 5.10, or 5.8.8, or 5.6.2. Does recommending the user modify their code, with the highest possible severity no less, to introduce a syntax error into their code really become more or less right based on the version in which the syntax error exists? That the author has explicitly chosen to support 5.005 should be entirely orthogonal, and the subject of a different policy. Adam K Show quoted text
> > Now, on the other hand, the fact that the policy implementation says > sub default_severity { return $SEVERITY_HIGHEST } > is relevant. That our default severities do not take into account > the environment is a philosophy choice that implicitly says that > compromising code to support 5.005 is a poor choice. I mildly agree > with that philosophy in general, but I STRONGLY agree with it with > regard to three-arg open. > > As we all know quite well, two arg open is a serious security risk. I > think it would be better for the Perl community to patch 5.005 and > make a new release (if there are enough tuits) than regress working > three-arg code back to two-arg style. > > I'm quite comfortable saying that 5.005-compatible code is a second- > class citizen in this modern 5.8/5.10 world. When I started > programming in Perl, Perl4 was the "bad old days". Now, I declare > that 5.005 is the > "bad old days" and the sooner we close the door on that world, the > better. > > Chris > >
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Wed, 2 Apr 2008 01:37:43 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Chris Dolan <chris [...] chrisdolan.net>
On Apr 2, 2008, at 12:13 AM, Adam Kennedy via RT wrote: Show quoted text
>
>> The policy declares that the right form of open() is the three-arg >> form. The choice to enable that policy or not falls to the >> user. It >> is irrelevant whether you agree with with the policy or whether >> it is >> appropriate for 5.005.
> > I certainly AGREE with the policy. I just assert that non-functional > code is never "right". > > And on 5.005 three-argument open is non-functional. Lacking a 5.005 > upgrade, an open statement with a known potential security issue is > still preferable to an open statement that causes the compiler to > throw a syntax error. > > I'm sure there's other examples of things that are "more right" but > only come with Perl 5.10, or 5.8.8, or 5.6.2. Does recommending the > user modify their code, with the highest possible severity no less, to > introduce a syntax error into their code really become more or less > right based on the version in which the syntax error exists? > > That the author has explicitly chosen to support 5.005 should be > entirely orthogonal, and the subject of a different policy.
I'll go one step farther and say that the choice of 5.005 is orthogonal to the choice of whether to use Perl::Critic or not. Authors who need to support 5.005 can simply turn off the policy or write their own or ignore Perl::Critic entirely. Perl::Critic is a TOOL to help people enforce their OWN standards of what they think is good code. Like any tool, if it does not solve your problem, you should not use it. It is not a religion proclaiming the one true way. If you think it is, then you've badly misunderstood the project. Instead it's absurdly flexible, like Perl itself and allows virtually any collections of policies to be applied. Chris
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 13 Apr 2008 13:33:29 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Elliot Shank via RT wrote: Show quoted text
> I'm starting a P::C::Compatibility distro.
It's been implemented. http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic-Compatibility Can't be released yet because it depends upon unreleased P::C functionality.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 13 Apr 2008 21:00:26 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Elliot Shank via RT wrote: Show quoted text
> Elliot Shank via RT wrote:
>> I'm starting a P::C::Compatibility distro.
> > It's been implemented. > > http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic-Compatibility > > Can't be released yet because it depends upon unreleased P::C > functionality.
I released a dev version of P::C, so I released a dev version of this that depends upon it. Comments Adam? Does it do what you want?
Hey Adam- Elliot has made a production release of Perl-Critic that supports Perl-Critic-Compatibility. Have you had a chance to try it out yet? Can we close out this bug? Thanks for your time. -Jeff
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Thu, 19 Jun 2008 13:45:48 -0500
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Adam Kennedy via RT wrote: Show quoted text
> Two-argument open is considered legitimate in scenarios where > three-argument open is not available. > > Skip two-argument open errors if and only if that module/file contains a > Perl version declaration older than 5.006. > > That is, a two-agument critique in the following case is a correctable > false positive. > > use 5.005; > open( FOO, ">$file" );
Change done. To be explicit: ---FAIL--- open FOO ">$foo"; ---PASS--- open FOO ">$foo"; use 5.005; ---FAIL--- open FOO ">$foo"; use 5.006; ---------- On a related note, RequireUseWarnings will now shut up in similar circumstances.
Subject: Re: [rt.cpan.org #34385] Two-argument open is legitimate in some situations
Date: Sun, 22 Jun 2008 10:58:36 -0700
To: bug-Perl-Critic [...] rt.cpan.org
From: Elliot Shank <perl [...] galumph.com>
Released in P::C 1.087.