Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Perlcritic and checking file modes

by kcott (Archbishop)
on Jul 08, 2015 at 16:43 UTC ( [id://1133744]=note: print w/replies, xml ) Need Help??


in reply to Perlcritic and checking file modes

G'day Neil,

To be honest, that does sound like a typo somewhere in your code using oct. You haven't shown that code so please confirm that with these lines:

my $mode = $sb[2] & 0777; ... ok( ! ( $mode & 022 ), "File is not group or world writable" );

Test 3 passes and you get those 2 perlcritic warnings.

But, when changing those lines to:

my $mode = $sb[2] & oct(777); ... ok( ! ( $mode & oct(22) ), "File is not group or world writable" );

Test 3 fails but you get those 0 perlcritic warnings.

And do note that I've removed the leading zeros for the oct arguments: oct(0777) and oct(022) will still generate the perlcritic warnings.

If you believe you have checked closely and there's no typos, can you provide a short, self-contained script to reproduce the problem that we can run.

I did actually try to reproduce it with the script I posted in response to your last question regarding this "Testing for group or world writable files". Without oct, I got 4 passes and 4 perlcritic warnings; with oct, I got 4 passes and 0 perlcritic warnings.

Personally, although there's much about PBP I like, this isn't one of them: you're working with modes, there's a variable called $mode (so that's somewhat obvious), modes are in octal, why complain about octal numbers. If you're of the same view, just turn the warnings off (in the smallest scope possible):

## no critic (LeadingZeros) my $mode = $sb[2] & 0777; ## use critic ... ## no critic (LeadingZeros) ok( ! ( $mode & 022 ), "File is not group or world writable" ); ## use critic

-- Ken

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1133744]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-18 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found