Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/InputOutput/RequireCheckedSyscalls.pm |
Statements | Executed 20 statements in 529µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 38µs | 49µs | supported_parameters | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
1 | 1 | 1 | 15µs | 15µs | BEGIN@10 | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
1 | 1 | 1 | 7µs | 57µs | BEGIN@18 | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
1 | 1 | 1 | 7µs | 9µs | default_severity | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
1 | 1 | 1 | 7µs | 669µs | BEGIN@15 | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
1 | 1 | 1 | 7µs | 10µs | BEGIN@12 | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
1 | 1 | 1 | 7µs | 27µs | BEGIN@13 | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
1 | 1 | 1 | 7µs | 18µs | BEGIN@11 | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
0 | 0 | 0 | 0s | 0s | applies_to | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
0 | 0 | 0 | 0s | 0s | initialize_if_enabled | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
0 | 0 | 0 | 0s | 0s | violates | Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | ############################################################################## | ||||
2 | # $URL$ | ||||
3 | # $Date$ | ||||
4 | # $Author$ | ||||
5 | # $Revision$ | ||||
6 | ############################################################################## | ||||
7 | |||||
8 | package Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls; | ||||
9 | |||||
10 | 2 | 41µs | 1 | 15µs | # spent 15µs within Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@10 which was called:
# once (15µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 15µs making 1 call to Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@10 |
11 | 2 | 20µs | 2 | 29µs | # spent 18µs (7+11) within Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@11 which was called:
# once (7µs+11µs) by Module::Pluggable::Object::_require at line 11 # spent 18µs making 1 call to Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 18µs | 2 | 14µs | # spent 10µs (7+3) within Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@12 which was called:
# once (7µs+3µs) by Module::Pluggable::Object::_require at line 12 # spent 10µs making 1 call to Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 24µs | 2 | 47µs | # spent 27µs (7+20) within Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@13 which was called:
# once (7µs+20µs) by Module::Pluggable::Object::_require at line 13 # spent 27µs making 1 call to Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@13
# spent 20µs making 1 call to Exporter::import |
14 | |||||
15 | 1 | 200ns | # spent 669µs (7+662) within Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@15 which was called:
# once (7µs+662µs) by Module::Pluggable::Object::_require at line 16 | ||
16 | 1 | 25µs | 2 | 1.33ms | hashify is_perl_bareword }; # spent 669µs making 1 call to Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@15
# spent 662µs making 1 call to Exporter::import |
17 | |||||
18 | 2 | 356µs | 2 | 107µs | # spent 57µs (7+50) within Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@18 which was called:
# once (7µs+50µs) by Module::Pluggable::Object::_require at line 18 # spent 57µs making 1 call to Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::BEGIN@18
# spent 50µs making 1 call to base::import |
19 | |||||
20 | 1 | 500ns | our $VERSION = '1.121'; | ||
21 | |||||
22 | #----------------------------------------------------------------------------- | ||||
23 | |||||
24 | 1 | 2µs | 1 | 29µs | Readonly::Scalar my $DESC => q{Return value of flagged function ignored}; # spent 29µs making 1 call to Readonly::Scalar |
25 | 1 | 2µs | 1 | 43µs | Readonly::Scalar my $EXPL => [208, 278]; # spent 43µs making 1 call to Readonly::Scalar |
26 | |||||
27 | 1 | 1µs | 1 | 20µs | Readonly::Array my @DEFAULT_FUNCTIONS => qw( # spent 20µs making 1 call to Readonly::Array |
28 | open close print say | ||||
29 | ); | ||||
30 | # I created this list by searching for "return" in perlfunc | ||||
31 | 1 | 2µs | 1 | 61µs | Readonly::Array my @BUILTIN_FUNCTIONS => qw( # spent 61µs making 1 call to Readonly::Array |
32 | accept bind binmode chdir chmod chown close closedir connect | ||||
33 | dbmclose dbmopen exec fcntl flock fork ioctl kill link listen | ||||
34 | mkdir msgctl msgget msgrcv msgsnd open opendir pipe print read | ||||
35 | readdir readline readlink readpipe recv rename rmdir say seek seekdir | ||||
36 | semctl semget semop send setpgrp setpriority setsockopt shmctl | ||||
37 | shmget shmread shutdown sleep socket socketpair symlink syscall | ||||
38 | sysopen sysread sysseek system syswrite tell telldir truncate | ||||
39 | umask unlink utime wait waitpid | ||||
40 | ); | ||||
41 | |||||
42 | #----------------------------------------------------------------------------- | ||||
43 | |||||
44 | # spent 49µs (38+12) within Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::supported_parameters which was called:
# once (38µs+12µs) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||||
45 | return ( | ||||
46 | { | ||||
47 | 1 | 25µs | 8 | 12µs | name => 'functions', # spent 6µs making 4 calls to Readonly::Array::FETCH, avg 2µs/call
# spent 3µs making 3 calls to Readonly::Scalar::FETCH, avg 1µs/call
# spent 2µs making 1 call to Readonly::Array::FETCHSIZE |
48 | description => | ||||
49 | 'The set of functions to require checking the return value of.', | ||||
50 | default_string => join( $SPACE, @DEFAULT_FUNCTIONS ), | ||||
51 | behavior => 'string list', | ||||
52 | }, | ||||
53 | { | ||||
54 | name => 'exclude_functions', | ||||
55 | description => | ||||
56 | 'The set of functions to not require checking the return value of.', | ||||
57 | default_string => $EMPTY, | ||||
58 | behavior => 'string list', | ||||
59 | }, | ||||
60 | ); | ||||
61 | } | ||||
62 | |||||
63 | 1 | 2µs | # spent 9µs (7+2) within Perl::Critic::Policy::InputOutput::RequireCheckedSyscalls::default_severity which was called:
# once (7µs+2µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
64 | sub default_themes { return qw( core maintenance certrule ) } | ||||
65 | sub applies_to { return 'PPI::Token::Word' } | ||||
66 | |||||
67 | #----------------------------------------------------------------------------- | ||||
68 | |||||
69 | sub initialize_if_enabled { | ||||
70 | my ($self, $config) = @_; | ||||
71 | |||||
72 | my @specified_functions = keys %{ $self->{_functions} }; | ||||
73 | my @resulting_functions; | ||||
74 | |||||
75 | foreach my $function (@specified_functions) { | ||||
76 | if ( $function eq ':defaults' ) { | ||||
77 | push @resulting_functions, @DEFAULT_FUNCTIONS; | ||||
78 | } | ||||
79 | elsif ( $function eq ':builtins' ) { | ||||
80 | push @resulting_functions, @BUILTIN_FUNCTIONS; | ||||
81 | } | ||||
82 | else { | ||||
83 | push @resulting_functions, $function; | ||||
84 | } | ||||
85 | } | ||||
86 | |||||
87 | my %functions = hashify(@resulting_functions); | ||||
88 | |||||
89 | foreach my $function ( keys %{ $self->{_exclude_functions} } ) { | ||||
90 | delete $functions{$function}; | ||||
91 | } | ||||
92 | |||||
93 | $self->{_functions} = \%functions; | ||||
94 | |||||
95 | return $TRUE; | ||||
96 | } | ||||
97 | |||||
98 | #----------------------------------------------------------------------------- | ||||
99 | |||||
100 | sub violates { | ||||
101 | my ( $self, $elem, undef ) = @_; | ||||
102 | |||||
103 | if ( $self->{_functions}->{':all'} ) { | ||||
104 | return if is_perl_bareword($elem); | ||||
105 | return if $self->{_exclude_functions}->{ $elem->content() }; | ||||
106 | } | ||||
107 | elsif ( not $self->{_functions}->{ $elem->content() } ) { | ||||
108 | return; | ||||
109 | } | ||||
110 | |||||
111 | return if not is_unchecked_call( $elem ); | ||||
112 | |||||
113 | return $self->violation( "$DESC - " . $elem->content(), $EXPL, $elem ); | ||||
114 | } | ||||
115 | |||||
116 | |||||
117 | 1 | 11µs | 1; | ||
118 | |||||
119 | __END__ |