Announcing perlcritic Policy ValuesAndExpressions::ProhibitFiletest_rwxRWX

Джерело:
blogs.perl.org

Дата публікації:
06/07/2022 00:21

Постійна адреса новини:
http://www.vsinovyny.com/9138287

Announcing perlcritic Policy ValuesAndExpressions::ProhibitFiletest_rwxRWX

 

06/07/2022 00:21 // blogs.perl.org

Since several places in the Perl documentation caution against the use of the file access operators (-r and friends), and since I was unable to find a Perl::Critic policy dealing with this, I thought I would make one: Perl::Critic::Policy::ValuesAndExpressions::ProhibitFiletest_rwxRWX.

This policy is assigned to the 'bugs' theme. It has low severity because there are some uses of these operators that seem legitimate to me -- or at least I see no easy way to get around their use.

On the one hand, something like

-r $file or die "File $file not readable\n";
open my $handle, '<', $file;

is wrong several ways. On the other hand, it is hard to see how to implement File::Which without the use of -x. And in fact it does use -x.

This policy has no configuration options. I can imagine a configuration option to allow some file access operators, but was unsure how much actual need there is for such an option. A configuration option to allow file access operators within the scope of a use filetest 'access'; might be possible, but would certainly make the policy much more complex.

Maybe this policy should be in the ::BuiltinFunctions:: name space, but I decided to follow the precedent established by Kevin Ryde in his Perl::Critic::Policy::ValuesAndExpressions::ProhibitFiletest_f.

 

» Читати повністю

 

« Наступна новина з архіву
HTC Quietly Announced a New Android Tablet, and Nobody Noticed
  Попередня новина з архіву
РФ відводить військову техніку від кордону з Фінляндією: куди перевели армію Кремля
»

 

 
© 2026 www.vsinovyny.com