| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/Variables/ProhibitAugmentedAssignmentInDeclaration.pm |
| Statements | Executed 21 statements in 397µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 17µs | 17µs | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@10 |
| 1 | 1 | 1 | 8µs | 168µs | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@13 |
| 1 | 1 | 1 | 8µs | 34µs | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@14 |
| 1 | 1 | 1 | 8µs | 224µs | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@16 |
| 1 | 1 | 1 | 8µs | 11.4ms | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@17 |
| 1 | 1 | 1 | 8µs | 12µs | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@12 |
| 1 | 1 | 1 | 7µs | 19µs | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@11 |
| 1 | 1 | 1 | 6µs | 7µs | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::default_severity |
| 1 | 1 | 1 | 2µs | 2µs | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::supported_parameters |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::__ANON__[:45] |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::applies_to |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::default_themes |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::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::Variables::ProhibitAugmentedAssignmentInDeclaration; | ||||
| 9 | |||||
| 10 | 2 | 46µs | 1 | 17µs | # spent 17µs within Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@10 which was called:
# once (17µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 17µs making 1 call to Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@10 |
| 11 | 2 | 21µs | 2 | 30µs | # spent 19µs (7+12) within Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@11 which was called:
# once (7µs+12µs) by Module::Pluggable::Object::_require at line 11 # spent 19µs making 1 call to Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@11
# spent 12µs making 1 call to strict::import |
| 12 | 2 | 22µs | 2 | 16µs | # spent 12µs (8+4) within Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::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::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@12
# spent 4µs making 1 call to warnings::import |
| 13 | 2 | 25µs | 2 | 328µs | # spent 168µs (8+160) within Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@13 which was called:
# once (8µs+160µs) by Module::Pluggable::Object::_require at line 13 # spent 168µs making 1 call to Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@13
# spent 160µs making 1 call to Exporter::Tiny::import |
| 14 | 2 | 24µs | 2 | 60µs | # spent 34µs (8+26) within Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@14 which was called:
# once (8µs+26µs) by Module::Pluggable::Object::_require at line 14 # spent 34µs making 1 call to Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@14
# spent 26µs making 1 call to Exporter::import |
| 15 | |||||
| 16 | 2 | 25µs | 2 | 440µs | # spent 224µs (8+216) within Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@16 which was called:
# once (8µs+216µs) by Module::Pluggable::Object::_require at line 16 # spent 224µs making 1 call to Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@16
# spent 216µs making 1 call to Exporter::import |
| 17 | 2 | 202µs | 2 | 22.7ms | # spent 11.4ms (8µs+11.4) within Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@17 which was called:
# once (8µs+11.4ms) by Module::Pluggable::Object::_require at line 17 # spent 11.4ms making 1 call to Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::BEGIN@17
# spent 11.4ms making 1 call to base::import |
| 18 | |||||
| 19 | 1 | 600ns | our $VERSION = '1.121'; | ||
| 20 | |||||
| 21 | #----------------------------------------------------------------------------- | ||||
| 22 | |||||
| 23 | 1 | 2µs | 1 | 30µs | Readonly::Scalar my $DESC => q{Augmented assignment operator '%s' used in declaration}; # spent 30µs making 1 call to Readonly::Scalar |
| 24 | 1 | 1µs | 1 | 21µs | Readonly::Scalar my $EXPL => q{Use simple assignment when initializing variables}; # spent 21µs making 1 call to Readonly::Scalar |
| 25 | |||||
| 26 | #----------------------------------------------------------------------------- | ||||
| 27 | |||||
| 28 | 1 | 5µs | # spent 2µs within Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::supported_parameters which was called:
# once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||
| 29 | 1 | 2µs | # spent 7µs (6+1) within Perl::Critic::Policy::Variables::ProhibitAugmentedAssignmentInDeclaration::default_severity which was called:
# once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
| 30 | sub default_themes { return qw( core bugs ) } | ||||
| 31 | sub applies_to { return 'PPI::Statement::Variable' } | ||||
| 32 | |||||
| 33 | #----------------------------------------------------------------------------- | ||||
| 34 | |||||
| 35 | 1 | 17µs | 1 | 6µs | my %augmented_assignments = hashify( qw( **= += -= .= *= /= %= x= &= |= ^= <<= >>= &&= ||= //= ) ); # spent 6µs making 1 call to Perl::Critic::Utils::hashify |
| 36 | |||||
| 37 | sub violates { | ||||
| 38 | my ( $self, $elem, undef ) = @_; | ||||
| 39 | |||||
| 40 | # The assignment operator associated with a PPI::Statement::Variable | ||||
| 41 | # element is assumed to be the first immediate child of that element. | ||||
| 42 | # Other operators in the statement, e.g. the ',' in "my ( $a, $b ) = ();", | ||||
| 43 | # as assumed to never be immediate children. | ||||
| 44 | |||||
| 45 | my $found = firstval { $_->isa('PPI::Token::Operator') } $elem->children(); | ||||
| 46 | if ( $found ) { | ||||
| 47 | my $op = $found->content(); | ||||
| 48 | if ( !exists $augmented_assignments{ $op } ) { | ||||
| 49 | # PPI doesn't parse all augmented assignment operators. Detect | ||||
| 50 | # the unsupported ones by concatenating two immediately adjacent | ||||
| 51 | # operators and trying again. | ||||
| 52 | my $immediately_adjacent = $found->next_sibling(); # not snext_sibling() | ||||
| 53 | if ( $immediately_adjacent && $immediately_adjacent->isa('PPI::Token::Operator') ) { | ||||
| 54 | $op .= $immediately_adjacent->content(); | ||||
| 55 | } | ||||
| 56 | } | ||||
| 57 | |||||
| 58 | if ( exists $augmented_assignments{ $op } ) { | ||||
| 59 | return $self->violation( sprintf( $DESC, $op ), $EXPL, $found ); | ||||
| 60 | } | ||||
| 61 | } | ||||
| 62 | |||||
| 63 | return; | ||||
| 64 | } | ||||
| 65 | |||||
| 66 | |||||
| 67 | 1 | 6µs | 1; | ||
| 68 | |||||
| 69 | __END__ |