« Perl/Lint/Policy/ValuesAndExpressions/ProhibitNoisyQuotes.pm
↑ Summary
Perl/Lint/Policy/ValuesAndExpressions/ProhibitEmptyQuotes.pm »
| 1 | package Perl::Lint::Keywords; | ||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use B::Keywords; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use parent qw/Exporter/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 4 | our @EXPORT = qw/ | |||||||||
| 7 | is_perl_builtin | ||||||||||
| 8 | is_perl_builtin_which_provide_list_context | ||||||||||
| 9 | is_perl_builtin_which_take_multiple_arguments | ||||||||||
| 10 | is_perl_bareword | ||||||||||
| 11 | is_perl_pragma | ||||||||||
| 12 | /; | ||||||||||
| 13 | |||||||||||
| 14 | 4 | my %builtin_func_map; | |||||||||
| 15 | 4 | for my $func (@B::Keywords::Functions) { | |||||||||
| 16 | 976 | $builtin_func_map{$func} = 1; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 4 | my %bareword_map; | |||||||||
| 20 | 4 | for my $bareword (@B::Keywords::Barewords) { | |||||||||
| 21 | 216 | $bareword_map{$bareword} = 1; | |||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | # perldoc -uT perlfunc | grep '=item.*LIST' | sed 's/(//' | awk '{print $2 " => 1,"}' | uniq | ||||||||||
| 25 | 4 | my %builtin_func_which_provide_list_context_map = ( | |||||||||
| 26 | chmod => 1, | ||||||||||
| 27 | chomp => 1, | ||||||||||
| 28 | chop => 1, | ||||||||||
| 29 | chown => 1, | ||||||||||
| 30 | die => 1, | ||||||||||
| 31 | do => 1, | ||||||||||
| 32 | exec => 1, | ||||||||||
| 33 | formline => 1, | ||||||||||
| 34 | grep => 1, | ||||||||||
| 35 | import => 1, | ||||||||||
| 36 | join => 1, | ||||||||||
| 37 | kill => 1, | ||||||||||
| 38 | map => 1, | ||||||||||
| 39 | no => 1, | ||||||||||
| 40 | open => 1, | ||||||||||
| 41 | pack => 1, | ||||||||||
| 42 | print => 1, | ||||||||||
| 43 | printf => 1, | ||||||||||
| 44 | push => 1, | ||||||||||
| 45 | reverse => 1, | ||||||||||
| 46 | say => 1, | ||||||||||
| 47 | sort => 1, | ||||||||||
| 48 | splice => 1, | ||||||||||
| 49 | sprintf => 1, | ||||||||||
| 50 | syscall => 1, | ||||||||||
| 51 | system => 1, | ||||||||||
| 52 | tie => 1, | ||||||||||
| 53 | unlink => 1, | ||||||||||
| 54 | unshift => 1, | ||||||||||
| 55 | use => 1, | ||||||||||
| 56 | utime => 1, | ||||||||||
| 57 | warn => 1, | ||||||||||
| 58 | ); | ||||||||||
| 59 | |||||||||||
| 60 | # perldoc -uT perlfunc | grep '=item.*[A-Z],' | awk '{print $2 " => 1,"}' | uniq | ||||||||||
| 61 | 4 | my %builtin_func_which_take_multiple_arguments_map = ( | |||||||||
| 62 | accept => 1, | ||||||||||
| 63 | atan2 => 1, | ||||||||||
| 64 | bind => 1, | ||||||||||
| 65 | binmode => 1, | ||||||||||
| 66 | bless => 1, | ||||||||||
| 67 | connect => 1, | ||||||||||
| 68 | crypt => 1, | ||||||||||
| 69 | dbmopen => 1, | ||||||||||
| 70 | fcntl => 1, | ||||||||||
| 71 | flock => 1, | ||||||||||
| 72 | formline => 1, | ||||||||||
| 73 | getpriority => 1, | ||||||||||
| 74 | getservbyname => 1, | ||||||||||
| 75 | gethostbyaddr => 1, | ||||||||||
| 76 | getnetbyaddr => 1, | ||||||||||
| 77 | getservbyport => 1, | ||||||||||
| 78 | getsockopt => 1, | ||||||||||
| 79 | grep => 1, | ||||||||||
| 80 | index => 1, | ||||||||||
| 81 | ioctl => 1, | ||||||||||
| 82 | join => 1, | ||||||||||
| 83 | kill => 1, | ||||||||||
| 84 | link => 1, | ||||||||||
| 85 | listen => 1, | ||||||||||
| 86 | map => 1, | ||||||||||
| 87 | mkdir => 1, | ||||||||||
| 88 | msgctl => 1, | ||||||||||
| 89 | msgget => 1, | ||||||||||
| 90 | msgrcv => 1, | ||||||||||
| 91 | msgsnd => 1, | ||||||||||
| 92 | open => 1, | ||||||||||
| 93 | opendir => 1, | ||||||||||
| 94 | pack => 1, | ||||||||||
| 95 | pipe => 1, | ||||||||||
| 96 | printf => 1, | ||||||||||
| 97 | push => 1, | ||||||||||
| 98 | read => 1, | ||||||||||
| 99 | recv => 1, | ||||||||||
| 100 | rename => 1, | ||||||||||
| 101 | rindex => 1, | ||||||||||
| 102 | seek => 1, | ||||||||||
| 103 | seekdir => 1, | ||||||||||
| 104 | select => 1, | ||||||||||
| 105 | semctl => 1, | ||||||||||
| 106 | semget => 1, | ||||||||||
| 107 | semop => 1, | ||||||||||
| 108 | send => 1, | ||||||||||
| 109 | setpgrp => 1, | ||||||||||
| 110 | setpriority => 1, | ||||||||||
| 111 | setsockopt => 1, | ||||||||||
| 112 | shmctl => 1, | ||||||||||
| 113 | shmget => 1, | ||||||||||
| 114 | shmread => 1, | ||||||||||
| 115 | shmwrite => 1, | ||||||||||
| 116 | shutdown => 1, | ||||||||||
| 117 | socket => 1, | ||||||||||
| 118 | socketpair => 1, | ||||||||||
| 119 | splice => 1, | ||||||||||
| 120 | split => 1, | ||||||||||
| 121 | sprintf => 1, | ||||||||||
| 122 | substr => 1, | ||||||||||
| 123 | symlink => 1, | ||||||||||
| 124 | syscall => 1, | ||||||||||
| 125 | sysopen => 1, | ||||||||||
| 126 | sysread => 1, | ||||||||||
| 127 | sysseek => 1, | ||||||||||
| 128 | syswrite => 1, | ||||||||||
| 129 | tie => 1, | ||||||||||
| 130 | truncate => 1, | ||||||||||
| 131 | unpack => 1, | ||||||||||
| 132 | unshift => 1, | ||||||||||
| 133 | vec => 1, | ||||||||||
| 134 | waitpid => 1, | ||||||||||
| 135 | %builtin_func_which_provide_list_context_map, | ||||||||||
| 136 | ); | ||||||||||
| 137 | |||||||||||
| 138 | # from `Module::CoreList->find_modules(qr/^[a-z].*/);` | ||||||||||
| 139 | # NOTE the above script is a bit slow, so results of this are hardcoded | ||||||||||
| 140 | 4 | my %pragma_map = ( | |||||||||
| 141 | 'arybase' => 1, | ||||||||||
| 142 | 'assertions' => 1, | ||||||||||
| 143 | 'assertions::activate' => 1, | ||||||||||
| 144 | 'assertions::compat' => 1, | ||||||||||
| 145 | 'attributes' => 1, | ||||||||||
| 146 | 'attrs' => 1, | ||||||||||
| 147 | 'autodie' => 1, | ||||||||||
| 148 | 'autodie::exception' => 1, | ||||||||||
| 149 | 'autodie::exception::system' => 1, | ||||||||||
| 150 | 'autodie::hints' => 1, | ||||||||||
| 151 | 'autodie::skip' => 1, | ||||||||||
| 152 | 'autouse' => 1, | ||||||||||
| 153 | 'base' => 1, | ||||||||||
| 154 | 'bigint' => 1, | ||||||||||
| 155 | 'bignum' => 1, | ||||||||||
| 156 | 'bigrat' => 1, | ||||||||||
| 157 | 'blib' => 1, | ||||||||||
| 158 | 'bytes' => 1, | ||||||||||
| 159 | 'charnames' => 1, | ||||||||||
| 160 | 'constant' => 1, | ||||||||||
| 161 | 'deprecate' => 1, | ||||||||||
| 162 | 'diagnostics' => 1, | ||||||||||
| 163 | 'encoding' => 1, | ||||||||||
| 164 | 'encoding::warnings' => 1, | ||||||||||
| 165 | 'feature' => 1, | ||||||||||
| 166 | 'fields' => 1, | ||||||||||
| 167 | 'filetest' => 1, | ||||||||||
| 168 | 'if' => 1, | ||||||||||
| 169 | 'inc::latest' => 1, | ||||||||||
| 170 | 'integer' => 1, | ||||||||||
| 171 | 'legacy' => 1, | ||||||||||
| 172 | 'less' => 1, | ||||||||||
| 173 | 'lib' => 1, | ||||||||||
| 174 | 'locale' => 1, | ||||||||||
| 175 | 'mro' => 1, | ||||||||||
| 176 | 'open' => 1, | ||||||||||
| 177 | 'ops' => 1, | ||||||||||
| 178 | 'overload' => 1, | ||||||||||
| 179 | 'overload::numbers' => 1, | ||||||||||
| 180 | 'overloading' => 1, | ||||||||||
| 181 | 'parent' => 1, | ||||||||||
| 182 | 'perlfaq' => 1, | ||||||||||
| 183 | 're' => 1, | ||||||||||
| 184 | 'sigtrap' => 1, | ||||||||||
| 185 | 'sort' => 1, | ||||||||||
| 186 | 'strict' => 1, | ||||||||||
| 187 | 'subs' => 1, | ||||||||||
| 188 | 'threads' => 1, | ||||||||||
| 189 | 'threads::shared' => 1, | ||||||||||
| 190 | 'unicore::Name' => 1, | ||||||||||
| 191 | 'utf8' => 1, | ||||||||||
| 192 | 'vars' => 1, | ||||||||||
| 193 | 'version' => 1, | ||||||||||
| 194 | 'vmsish' => 1, | ||||||||||
| 195 | 'warnings' => 1, | ||||||||||
| 196 | 'warnings::register' => 1, | ||||||||||
| 197 | ); | ||||||||||
| 198 | |||||||||||
| 199 | 0 | ▶ | sub is_perl_builtin { | ||||||||
|
Subroutine
is_perl_builtin: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 200 | 0 | my $key = shift; | |||||||||
| 201 | 0 | ▶ | return if !$key; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 202 | |||||||||||
| 203 | 0 | return exists $builtin_func_map{$key}; | |||||||||
| 204 | } | ||||||||||
| 205 | |||||||||||
| 206 | 0 | ▶ | sub is_perl_builtin_which_provide_list_context { | ||||||||
|
Subroutine
is_perl_builtin_which_provide_list_context: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 207 | 0 | my $key = shift; | |||||||||
| 208 | 0 | ▶ | return if !$key; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 209 | |||||||||||
| 210 | 0 | return exists $builtin_func_which_provide_list_context_map{$key}; | |||||||||
| 211 | } | ||||||||||
| 212 | |||||||||||
| 213 | 0 | ▶ | sub is_perl_builtin_which_take_multiple_arguments { | ||||||||
|
Subroutine
is_perl_builtin_which_take_multiple_arguments: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 214 | 0 | my $key = shift; | |||||||||
| 215 | 0 | ▶ | return if !$key; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 216 | |||||||||||
| 217 | 0 | return exists $builtin_func_which_take_multiple_arguments_map{$key}; | |||||||||
| 218 | } | ||||||||||
| 219 | |||||||||||
| 220 | 0 | ▶ | sub is_perl_bareword { | ||||||||
|
Subroutine
is_perl_bareword: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 221 | 0 | my $key = shift; | |||||||||
| 222 | 0 | ▶ | return if !$key; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 223 | |||||||||||
| 224 | 0 | return exists $bareword_map{$key}; | |||||||||
| 225 | } | ||||||||||
| 226 | |||||||||||
| 227 | 0 | ▶ | sub is_perl_pragma { | ||||||||
|
Subroutine
is_perl_pragma: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 228 | 0 | my $key = shift; | |||||||||
| 229 | 0 | ▶ | return if !$key; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 230 | |||||||||||
| 231 | 0 | return exists $pragma_map{$key}; | |||||||||
| 232 | } | ||||||||||
| 233 | |||||||||||
| 234 | 4 | 1; | |||||||||
| 235 | |||||||||||