| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/InputOutput/RequireBracedFileHandleWithPrint.pm |
| Statements | Executed 21 statements in 491µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 19µs | 19µs | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@10 |
| 1 | 1 | 1 | 12µs | 35µs | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@13 |
| 1 | 1 | 1 | 8µs | 21µs | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@11 |
| 1 | 1 | 1 | 8µs | 3.65ms | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@15 |
| 1 | 1 | 1 | 8µs | 12µs | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@12 |
| 1 | 1 | 1 | 8µs | 58µs | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@16 |
| 1 | 1 | 1 | 7µs | 9µs | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::default_severity |
| 1 | 1 | 1 | 2µs | 2µs | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::supported_parameters |
| 1 | 1 | 1 | 1µs | 1µs | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::CORE:qr (opcode) |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::applies_to |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::default_themes |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::violates |
| 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::RequireBracedFileHandleWithPrint; | ||||
| 9 | |||||
| 10 | 2 | 44µs | 1 | 19µs | # spent 19µs within Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@10 which was called:
# once (19µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 19µs making 1 call to Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@10 |
| 11 | 2 | 22µs | 2 | 34µs | # spent 21µs (8+13) within Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@11 which was called:
# once (8µs+13µs) by Module::Pluggable::Object::_require at line 11 # spent 21µs making 1 call to Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@11
# spent 13µs making 1 call to strict::import |
| 12 | 2 | 20µs | 2 | 17µs | # spent 12µs (8+4) within Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@12 which was called:
# once (8µs+4µs) by Module::Pluggable::Object::_require at line 12 # spent 12µs making 1 call to Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@12
# spent 4µs making 1 call to warnings::import |
| 13 | 2 | 26µs | 2 | 58µs | # spent 35µs (12+23) within Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@13 which was called:
# once (12µs+23µs) by Module::Pluggable::Object::_require at line 13 # spent 35µs making 1 call to Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@13
# spent 23µs making 1 call to Exporter::import |
| 14 | |||||
| 15 | 2 | 26µs | 2 | 7.28ms | # spent 3.65ms (8µs+3.64) within Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@15 which was called:
# once (8µs+3.64ms) by Module::Pluggable::Object::_require at line 15 # spent 3.65ms making 1 call to Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@15
# spent 3.64ms making 1 call to Exporter::import |
| 16 | 2 | 322µs | 2 | 109µs | # spent 58µs (8+50) within Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@16 which was called:
# once (8µs+50µs) by Module::Pluggable::Object::_require at line 16 # spent 58µs making 1 call to Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::BEGIN@16
# spent 50µs making 1 call to base::import |
| 17 | |||||
| 18 | 1 | 500ns | our $VERSION = '1.121'; | ||
| 19 | |||||
| 20 | #----------------------------------------------------------------------------- | ||||
| 21 | |||||
| 22 | 1 | 2µs | 1 | 26µs | Readonly::Array my @POSTFIX_WORDS => qw( if unless for ); # spent 26µs making 1 call to Readonly::Array |
| 23 | 1 | 7µs | 3 | 47µs | Readonly::Hash my %POSTFIX_WORDS => hashify( @POSTFIX_WORDS ); # spent 29µs making 1 call to Readonly::Hash
# spent 16µs making 1 call to Perl::Critic::Utils::hashify
# spent 1µs making 1 call to Readonly::Array::FETCHSIZE |
| 24 | 1 | 7µs | 2 | 25µs | Readonly::Scalar my $PRINT_RX => qr/ \A (?: print f? | say ) \z /xms; # spent 23µs making 1 call to Readonly::Scalar
# spent 1µs making 1 call to Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::CORE:qr |
| 25 | |||||
| 26 | 1 | 1µs | 1 | 20µs | Readonly::Scalar my $DESC => q{File handle for "print" or "printf" is not braced}; # spent 20µs making 1 call to Readonly::Scalar |
| 27 | 1 | 1µs | 1 | 40µs | Readonly::Scalar my $EXPL => [ 217 ]; # spent 40µs making 1 call to Readonly::Scalar |
| 28 | |||||
| 29 | #----------------------------------------------------------------------------- | ||||
| 30 | |||||
| 31 | 1 | 4µs | # spent 2µs within Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::supported_parameters which was called:
# once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||
| 32 | 1 | 2µs | # spent 9µs (7+2) within Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::default_severity which was called:
# once (7µs+2µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
| 33 | sub default_themes { return qw( core pbp cosmetic ) } | ||||
| 34 | sub applies_to { return 'PPI::Token::Word' } | ||||
| 35 | |||||
| 36 | #----------------------------------------------------------------------------- | ||||
| 37 | |||||
| 38 | sub violates { | ||||
| 39 | my ( $self, $elem, undef ) = @_; | ||||
| 40 | |||||
| 41 | return if $elem !~ $PRINT_RX; | ||||
| 42 | return if ! is_function_call($elem); | ||||
| 43 | |||||
| 44 | my @sib; | ||||
| 45 | |||||
| 46 | $sib[0] = $elem->snext_sibling(); | ||||
| 47 | return if !$sib[0]; | ||||
| 48 | |||||
| 49 | # Deal with situations where 'print' is called with parentheses | ||||
| 50 | if ( $sib[0]->isa('PPI::Structure::List') ) { | ||||
| 51 | my $expr = $sib[0]->schild(0); | ||||
| 52 | return if !$expr; | ||||
| 53 | $sib[0] = $expr->schild(0); | ||||
| 54 | return if !$sib[0]; | ||||
| 55 | } | ||||
| 56 | |||||
| 57 | $sib[1] = $sib[0]->next_sibling(); | ||||
| 58 | return if !$sib[1]; | ||||
| 59 | $sib[2] = $sib[1]->next_sibling(); | ||||
| 60 | return if !$sib[2]; | ||||
| 61 | |||||
| 62 | # First token must be a scalar symbol or bareword; | ||||
| 63 | return if !( ($sib[0]->isa('PPI::Token::Symbol') && $sib[0] =~ m/\A \$/xms) | ||||
| 64 | || $sib[0]->isa('PPI::Token::Word') ); | ||||
| 65 | |||||
| 66 | # First token must not be a builtin function or control | ||||
| 67 | return if is_perl_builtin($sib[0]); | ||||
| 68 | return if exists $POSTFIX_WORDS{ $sib[0] }; | ||||
| 69 | |||||
| 70 | # Second token must be white space | ||||
| 71 | return if !$sib[1]->isa('PPI::Token::Whitespace'); | ||||
| 72 | |||||
| 73 | # Third token must not be an operator | ||||
| 74 | return if $sib[2]->isa('PPI::Token::Operator'); | ||||
| 75 | |||||
| 76 | # Special case for postfix controls | ||||
| 77 | return if exists $POSTFIX_WORDS{ $sib[2] }; | ||||
| 78 | |||||
| 79 | return if $sib[0]->isa('PPI::Structure::Block'); | ||||
| 80 | |||||
| 81 | return $self->violation( $DESC, $EXPL, $elem ); | ||||
| 82 | } | ||||
| 83 | |||||
| 84 | 1 | 6µs | 1; | ||
| 85 | |||||
| 86 | __END__ | ||||
# spent 1µs within Perl::Critic::Policy::InputOutput::RequireBracedFileHandleWithPrint::CORE:qr which was called:
# once (1µs+0s) by Module::Pluggable::Object::_require at line 24 |