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
In reply to Re: Perlcritic and checking file modes
by kcott
in thread Perlcritic and checking file modes
by neilwatson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |