Perl-Critic-Grape

 view release on metacpan or  search on metacpan

lib/Perl/Critic/Policy/CodeLayout/RequireParensWithBuiltins.pm  view on Meta::CPAN

package Perl::Critic::Policy::CodeLayout::RequireParensWithBuiltins;

use 5.010001;
use strict;
use warnings;
use Readonly;

use Perl::Critic::Utils qw/ :severities :data_conversion :classification :language /;
use base 'Perl::Critic::Policy';

our $VERSION = '0.0.7';

Readonly::Scalar my $DESC  => q{Builtin function called without parentheses};
Readonly::Scalar my $EXPL  => [ 13 ];

# In each section, the order follows that of perlfunc(1).
# Some keywords may be repeated if they appear in multiple perlfunc sections.

Readonly::Array my @REQUIRED => qw/
	chr crypt fc hex index lc lcfirst length oct ord pack rindex sprintf substr uc ucfirst
	quotemeta split study
	abs atan2 cos exp hex int log oct rand sin sqrt srand
	splice
	join unpack
	delete exists
	binmode close closedir fileno flock read readdir readline rewinddir seek seekdir select syscall sysread sysseek syswrite tell telldir truncate warn write
	pack read syscall sysread sysseek syswrite unpack vec
	chdir chmod chown chroot fcntl glob ioctl link lstat mkdir open opendir readlink rename rmdir select stat symlink sysopen umask unlink utime
	caller
	formline lock scalar
	alarm exec getpriority kill pipe readpipe setpgrp setpriority sleep system waitpid
	bless ref tie tied untie
	accept bind connect getpeername getsockname getsockopt listen recv send setsockopt shutdown socket socketpair
/;

Readonly::Array my @PERMITTED => qw/
	chomp chop
	pos
	eof getc
	exit
	defined reset undef
	getpgrp
	gmtime localtime time
/;

Readonly::Array my @ALLOWED => qw/
	reverse
	each keys pop push shift unshift values
	each keys values
	grep map reverse sort
	die format print printf say
	break continue die do dump eval evalbytes goto last next redo return wantarray
	import local my our package state use
	fork getppid times wait
	do import no package require use
	package use
/;

####-----------------------------------------------------------------------------

sub supported_parameters {
	return (
		{
			name           => 'require',
			description    => 'Always require parentheses of these operators.',
			default_string => join(' ',@REQUIRED),
			behavior       => 'string list',
		},
		{
			name           => 'permit',
			description    => 'Require parentheses when called with a parameter.',
			default_string => join(' ',@PERMITTED),
			behavior       => 'string list',
		},
		{
			name           => 'allow',
			description    => 'Never require parentheses.',
			default_string => join(' ', @ALLOWED),
			behavior       => 'string list',
		},
	);
}

sub default_severity     { return $SEVERITY_HIGH      }
sub default_themes       { return qw( core cosmetic ) }
sub applies_to           { return 'PPI::Token::Word'  }

#-----------------------------------------------------------------------------



( run in 0.497 second using v1.01-cache-2.11-cpan-5511b514fd6 )