Skip Menu |

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

Report information
The Basics
Id: 125823
Status: resolved
Priority: 0/
Queue: Perl-Critic-Pulp

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

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



Subject: Make ValuesAndExpressions::ProhibitFiletest_f not complain if -f isn't the only operator
I have tests where I'm doing, for example: ok( -f -r $filename, "$filename exists and is readable" ); I specifically want to check -f because I don't want directories, and the file I'm looking for better not be a pipe or device file or whatever. The -r tells me at least that it's readable. It would be nice if the policy didn't complain in this case. P.S. Big thumbs up on the depth of information in the explanation behind the reasoning behind this policy.
Subject: Re: [rt.cpan.org #125823] Make ValuesAndExpressions::ProhibitFiletest_f not complain if -f isn't the only operator
Date: Sun, 15 Jul 2018 15:52:13 +1000
To: "Andy Lester via RT" <bug-Perl-Critic-Pulp [...] rt.cpan.org>
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
"Andy Lester via RT" <bug-Perl-Critic-Pulp@rt.cpan.org> writes: Show quoted text
> > ok( -f -r $filename, "$filename exists and is readable" ); > > I specifically want to check -f because I don't want directories, and > the file I'm looking for better not be a pipe or device file or > whatever.
Are you sure? If so then my concept may too strict, and having thought and decided you're ok, then disable/skip/etc. I had trouble thinking of much besides a backup or archiver which would genuinely care about device vs ordinary. Show quoted text
> The -r tells me at least that it's readable. It would be > nice if the policy didn't complain in this case.
Ah, of a doubled operator. Hmm. I think I would still apply it there, unless I misunderstand. Show quoted text
> P.S. Big thumbs up on the depth of information in the explanation > behind the reasoning behind this policy.
:-) I struck a couple of module authors with preemptive -f so couldn't pass say /dev/null. Can't remember now exactly where, but I collected the rationale against. You're a test script is it? I can understand being more relaxed there since you're in complete control. I have in mind mostly module or program code, though there could be argument for still keeping up.
I don't have particularly strong feelings. It just seems to me that the core of the policy is "-f is not enough on its own", and my case of "-f -r" (or "-f -x" or "-f -w" or whatever) doesn't violate that ideal.
Subject: Re: [rt.cpan.org #125823] Make ValuesAndExpressions::ProhibitFiletest_f not complain if -f isn't the only operator
Date: Wed, 18 Jul 2018 18:22:54 +1000
To: "Andy Lester via RT" <bug-Perl-Critic-Pulp [...] rt.cpan.org>
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
"Andy Lester via RT" <bug-Perl-Critic-Pulp@rt.cpan.org> writes: Show quoted text
> > It just seems to me that the core of the policy is "-f is not enough > on its own", ...
Oh, :-), I'm harsher than that. I'm more like "never use -f". I'll see if I can massage the words a little, to either make that intention clearer or justify it yet further. Incidentally recent perlfunc "-X" has a note on permissions -r and friends being a race condition, so I can cross reference that. There too of course if you're in full control of a directory then can be more relaxed.
I put the crossrefs in the docs I said, and otherwise believe I still hold to the strictness of my concept. (Which of course is not to say anyone else can't make something else :-).