| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/RegularExpressions/RequireExtendedFormatting.pm |
| Statements | Executed 18 statements in 375µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 16µs | 16µs | Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@10 |
| 1 | 1 | 1 | 8µs | 8µs | Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::supported_parameters |
| 1 | 1 | 1 | 8µs | 61µs | Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@17 |
| 1 | 1 | 1 | 8µs | 144µs | Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@15 |
| 1 | 1 | 1 | 7µs | 11µs | Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@12 |
| 1 | 1 | 1 | 7µs | 18µs | Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@11 |
| 1 | 1 | 1 | 7µs | 27µs | Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@13 |
| 1 | 1 | 1 | 6µs | 7µs | Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::default_severity |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::applies_to |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::default_themes |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::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::RegularExpressions::RequireExtendedFormatting; | ||||
| 9 | |||||
| 10 | 2 | 38µs | 1 | 16µs | # spent 16µs within Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@10 which was called:
# once (16µs+0s) by Module::Pluggable::Object::_require at line 10 # spent 16µs making 1 call to Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@10 |
| 11 | 2 | 25µs | 2 | 29µs | # spent 18µs (7+11) within Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::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::RegularExpressions::RequireExtendedFormatting::BEGIN@11
# spent 11µs making 1 call to strict::import |
| 12 | 2 | 18µs | 2 | 15µs | # spent 11µs (7+4) within Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@12 which was called:
# once (7µs+4µs) by Module::Pluggable::Object::_require at line 12 # spent 11µs making 1 call to Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@12
# spent 4µs making 1 call to warnings::import |
| 13 | 2 | 26µs | 2 | 47µs | # spent 27µs (7+20) within Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::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::RegularExpressions::RequireExtendedFormatting::BEGIN@13
# spent 20µs making 1 call to Exporter::import |
| 14 | |||||
| 15 | 2 | 24µs | 2 | 281µs | # spent 144µs (8+137) within Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@15 which was called:
# once (8µs+137µs) by Module::Pluggable::Object::_require at line 15 # spent 144µs making 1 call to Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@15
# spent 137µs making 1 call to Exporter::import |
| 16 | |||||
| 17 | 2 | 226µs | 2 | 115µs | # spent 61µs (8+54) within Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@17 which was called:
# once (8µs+54µs) by Module::Pluggable::Object::_require at line 17 # spent 61µs making 1 call to Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::BEGIN@17
# spent 54µs making 1 call to base::import |
| 18 | |||||
| 19 | 1 | 600ns | our $VERSION = '1.121'; | ||
| 20 | |||||
| 21 | #----------------------------------------------------------------------------- | ||||
| 22 | |||||
| 23 | 1 | 2µs | 1 | 28µs | Readonly::Scalar my $DESC => q{Regular expression without "/x" flag}; # spent 28µs making 1 call to Readonly::Scalar |
| 24 | 1 | 2µs | 1 | 42µs | Readonly::Scalar my $EXPL => [ 236 ]; # spent 42µs making 1 call to Readonly::Scalar |
| 25 | |||||
| 26 | #----------------------------------------------------------------------------- | ||||
| 27 | |||||
| 28 | # spent 8µs within Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::supported_parameters which was called:
# once (8µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||||
| 29 | return ( | ||||
| 30 | { | ||||
| 31 | 1 | 10µs | name => 'minimum_regex_length_to_complain_about', | ||
| 32 | description => | ||||
| 33 | q<The number of characters that a regular expression must contain before this policy will complain.>, | ||||
| 34 | behavior => 'integer', | ||||
| 35 | default_string => '0', | ||||
| 36 | integer_minimum => 0, | ||||
| 37 | }, | ||||
| 38 | { | ||||
| 39 | name => 'strict', | ||||
| 40 | description => | ||||
| 41 | q<Should regexes that only contain whitespace and word characters be complained about?>, | ||||
| 42 | behavior => 'boolean', | ||||
| 43 | default_string => '0', | ||||
| 44 | }, | ||||
| 45 | ); | ||||
| 46 | } | ||||
| 47 | |||||
| 48 | 1 | 2µs | # spent 7µs (6+1) within Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting::default_severity which was called:
# once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
| 49 | sub default_themes { return qw< core pbp maintenance > } | ||||
| 50 | sub applies_to { | ||||
| 51 | return qw< | ||||
| 52 | PPI::Token::Regexp::Match | ||||
| 53 | PPI::Token::Regexp::Substitute | ||||
| 54 | PPI::Token::QuoteLike::Regexp | ||||
| 55 | >; | ||||
| 56 | } | ||||
| 57 | |||||
| 58 | #----------------------------------------------------------------------------- | ||||
| 59 | |||||
| 60 | sub violates { | ||||
| 61 | my ( $self, $elem, $doc ) = @_; | ||||
| 62 | |||||
| 63 | my $match = $elem->get_match_string(); | ||||
| 64 | return if length $match <= $self->{_minimum_regex_length_to_complain_about}; | ||||
| 65 | return if not $self->{_strict} and $match =~ m< \A [\s\w]* \z >xms; | ||||
| 66 | |||||
| 67 | my $re = $doc->ppix_regexp_from_element( $elem ) | ||||
| 68 | or return; | ||||
| 69 | $re->modifier_asserted( 'x' ) | ||||
| 70 | or return $self->violation( $DESC, $EXPL, $elem ); | ||||
| 71 | |||||
| 72 | return; # ok!; | ||||
| 73 | } | ||||
| 74 | |||||
| 75 | 1 | 3µs | 1; | ||
| 76 | |||||
| 77 | __END__ |