NAME

Perl::Critic::Policy::Plicease::ProhibitLeadingZeros - Leading zeroes are okay as the first arg to chmod, and other such reasonableness

VERSION

version 0.05

SYNOPSIS

perlcriticrc:

[Plicease::ProhibitLeadingZeros]

code:

0123;               # not ok
1234;               # ok
chmod 0700;         # ok
mkpath($foo, 0700); # ok

DESCRIPTION

Perl interprets numbers with leading zeros as octal. If that's what you really want, its better to use oct and make it obvious. However, some operations are well known as using octal such as chmod and mkpath so this policy disallows mistakes like this:

my $x = 1231;
my $y = 2345;
my $z = 0032;

But not non-mistakes like this:

chmod 0700, "secret_file.txt";

or this:

use File::Path qw( mkpath );

mkpath("/foo/bar/baz", 1, 0700);

or is this:

use Path::Class qw( dir );

dir()->mkpath(1,0700);

AFFILIATION

None.

CONFIGURATION

This policy is not configurable except for the standard options.

CAVEATS

Because mkpath is not a built in (as chmod is), this policy does not differentiate between the mkpath function provided by File::Path or the mkpath method provided by Path::Class::Dir and arbitrary mkpath function or methods that you or someone else might define. Also, there is no way to really check if the object invocant of a mkpath method is really an instance of Path::Class::Dir.

SEE ALSO

This policy is based largely on the existing in-core policy, and one in the lax bundle, but adds a few exceptions that I find useful.

Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros
Perl::Critic::Policy::Lax::ProhibitLeadingZeros::ExceptChmod

AUTHOR

Author: Graham Ollis <plicease@cpan.org>

Contributors:

Ville Skyttä (SCOP)

COPYRIGHT AND LICENSE

This software is copyright (c) 2019-2024 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.