Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 67850
Status: new
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: dolmen [...] cpan.org
user42 [...] zip.com.au
Cc: dolmen [...] cpan.org
AdminCc:

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

Attachments


Subject: ProhibitLeadingZeros on shmget()
Date: Sat, 30 Apr 2011 07:18:39 +1000
To: bug-Perl-Critic [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
Download (untitled) / with headers
text/plain 309b
The dispensation ProhibitLeadingZeros offers chmod and friends might be extended to the perms in a shmget(). It could be as easy as the dbmopen() bit per below. It doesn't handle an "IPC_CREAT | 0600" expression. Some sensible expression recognition might benefit almost all those octal exception funcs.
Index: lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitLeadingZeros.pm =================================================================== --- lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitLeadingZeros.pm (revision 4076) +++ lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitLeadingZeros.pm (working copy) @@ -50,7 +50,7 @@ return $self->_create_violation($elem) if $self->{_strict}; return if $self->_is_first_argument_of_chmod_or_umask($elem); return if $self->_is_second_argument_of_mkdir($elem); - return if $self->_is_third_argument_of_dbmopen($elem); + return if $self->_is_third_argument_of_dbmopen_or_shmget($elem); return if $self->_is_fourth_argument_of_sysopen($elem); return $self->_create_violation($elem); } @@ -95,7 +95,7 @@ return $previous_token->content() eq 'mkdir'; } -sub _is_third_argument_of_dbmopen { +sub _is_third_argument_of_dbmopen_or_shmget { my ($self, $elem) = @_; # Preceding comma. @@ -123,7 +123,8 @@ _previous_token_that_isnt_a_parenthesis($previous_token); return if not $previous_token; - return $previous_token->content() eq 'dbmopen'; + my $content = $previous_token->content(); + return $content eq 'dbmopen' || $content eq 'shmget'; } sub _is_fourth_argument_of_sysopen { @@ -217,6 +218,7 @@ mkdir $directory, 0755; # ok by default sysopen $filehandle, $filename, O_RDWR, 0666; # ok by default umask 0002; # ok by default + shmget (IPC_PRIVATE, 4096, 0600 | IPC_CREAT); # ok by default =head1 CONFIGURATION Index: t/ValuesAndExpressions/ProhibitLeadingZeros.run =================================================================== --- t/ValuesAndExpressions/ProhibitLeadingZeros.run (revision 4076) +++ t/ValuesAndExpressions/ProhibitLeadingZeros.run (working copy) @@ -92,6 +92,37 @@ #----------------------------------------------------------------------------- +## name shmget +## failures 0 +## cut + +shmget (IPC_PRIVATE, 4096, 0666 | IPC_CREAT) +shmget IPC_PRIVATE, 4096, 0666 | IPC_CREAT + +#----------------------------------------------------------------------------- + +## name shmget with number not at start of arg +## failures 0 +## TODO _is_third_argument_of_dbmopen_or_shmget() doesn't understand expressions +## cut + +shmget (IPC_PRIVATE, 4096, IPC_CREAT | 0666) +shmget IPC_PRIVATE, 4096, IPC_CREAT | 0666 + +#----------------------------------------------------------------------------- + +## name shmget with strict option +## failures 4 +## parms { strict => 1 } +## cut + +shmget (IPC_PRIVATE, 4096, IPC_CREAT | 0666) +shmget IPC_PRIVATE, 4096, IPC_CREAT | 0666 +shmget (IPC_PRIVATE, 4096, 0666 | IPC_CREAT) +shmget IPC_PRIVATE, 4096, 0666 | IPC_CREAT + +#----------------------------------------------------------------------------- + ## name mkdir ## failures 0 ## cut


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.