Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/CodeLayout/ProhibitTrailingWhitespace.pm |
Statements | Executed 24 statements in 573µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 427µs | 6.05ms | BEGIN@16 | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
1 | 1 | 1 | 16µs | 351µs | BEGIN@19 | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
1 | 1 | 1 | 16µs | 16µs | BEGIN@10 | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
1 | 1 | 1 | 11µs | 11µs | BEGIN@18 | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
1 | 1 | 1 | 8µs | 28µs | BEGIN@14 | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
1 | 1 | 1 | 8µs | 68µs | BEGIN@21 | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
1 | 1 | 1 | 7µs | 378µs | BEGIN@13 | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
1 | 1 | 1 | 7µs | 11µs | BEGIN@12 | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
1 | 1 | 1 | 7µs | 18µs | BEGIN@11 | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
1 | 1 | 1 | 6µs | 7µs | default_severity | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
1 | 1 | 1 | 2µs | 2µs | supported_parameters | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
0 | 0 | 0 | 0s | 0s | _escape | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
0 | 0 | 0 | 0s | 0s | applies_to | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
0 | 0 | 0 | 0s | 0s | violates | Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::
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::CodeLayout::ProhibitTrailingWhitespace; | ||||
9 | |||||
10 | 2 | 43µs | 1 | 16µs | # spent 16µs within Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::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::CodeLayout::ProhibitTrailingWhitespace::BEGIN@10 |
11 | 2 | 20µs | 2 | 29µs | # spent 18µs (7+11) within Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::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::CodeLayout::ProhibitTrailingWhitespace::BEGIN@11
# spent 11µs making 1 call to strict::import |
12 | 2 | 20µs | 2 | 15µs | # spent 11µs (7+4) within Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::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::CodeLayout::ProhibitTrailingWhitespace::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 23µs | 2 | 749µs | # spent 378µs (7+371) within Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@13 which was called:
# once (7µs+371µs) by Module::Pluggable::Object::_require at line 13 # spent 378µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@13
# spent 371µs making 1 call to English::import |
14 | 2 | 21µs | 2 | 47µs | # spent 28µs (8+19) within Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@14 which was called:
# once (8µs+19µs) by Module::Pluggable::Object::_require at line 14 # spent 28µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@14
# spent 19µs making 1 call to Exporter::import |
15 | |||||
16 | 2 | 91µs | 1 | 6.05ms | # spent 6.05ms (427µs+5.62) within Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@16 which was called:
# once (427µs+5.62ms) by Module::Pluggable::Object::_require at line 16 # spent 6.05ms making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@16 |
17 | |||||
18 | 2 | 29µs | 1 | 11µs | # spent 11µs within Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@18 which was called:
# once (11µs+0s) by Module::Pluggable::Object::_require at line 18 # spent 11µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@18 |
19 | 2 | 27µs | 2 | 686µs | # spent 351µs (16+335) within Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@19 which was called:
# once (16µs+335µs) by Module::Pluggable::Object::_require at line 19 # spent 351µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@19
# spent 335µs making 1 call to Exporter::import |
20 | |||||
21 | 2 | 284µs | 2 | 127µs | # spent 68µs (8+60) within Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@21 which was called:
# once (8µs+60µs) by Module::Pluggable::Object::_require at line 21 # spent 68µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::BEGIN@21
# spent 60µs making 1 call to base::import |
22 | |||||
23 | 1 | 600ns | our $VERSION = '1.121'; | ||
24 | |||||
25 | #----------------------------------------------------------------------------- | ||||
26 | |||||
27 | 1 | 2µs | 1 | 34µs | Readonly::Scalar my $EXPL => q{Don't use whitespace at the end of lines}; # spent 34µs making 1 call to Readonly::Scalar |
28 | |||||
29 | ## no critic (RequireInterpolationOfMetachars) | ||||
30 | 1 | 2µs | 1 | 36µs | Readonly::Hash my %C_STYLE_ESCAPES => # spent 36µs making 1 call to Readonly::Hash |
31 | ( | ||||
32 | ord "\t" => q{\t}, | ||||
33 | ord "\n" => q{\n}, | ||||
34 | ord "\r" => q{\r}, | ||||
35 | ord "\f" => q{\f}, | ||||
36 | ord "\b" => q{\b}, | ||||
37 | ord "\a" => q{\a}, | ||||
38 | ord "\e" => q{\e}, | ||||
39 | ); | ||||
40 | ## use critic | ||||
41 | |||||
42 | #----------------------------------------------------------------------------- | ||||
43 | |||||
44 | 1 | 5µs | # spent 2µs within Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::supported_parameters which was called:
# once (2µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm | ||
45 | 1 | 2µs | # spent 7µs (6+1) within Perl::Critic::Policy::CodeLayout::ProhibitTrailingWhitespace::default_severity which was called:
# once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
46 | sub default_themes { return qw( core maintenance ) } | ||||
47 | sub applies_to { return 'PPI::Token::Whitespace' } | ||||
48 | |||||
49 | #----------------------------------------------------------------------------- | ||||
50 | |||||
51 | sub violates { | ||||
52 | my ( $self, $token, undef ) = @_; | ||||
53 | |||||
54 | if ( $token->content() =~ m< ( (?! \n) \s )+ \n >xms ) { | ||||
55 | my $extra_whitespace = $1; | ||||
56 | |||||
57 | my $description = q{Found "}; | ||||
58 | $description .= | ||||
59 | join | ||||
60 | $EMPTY, | ||||
61 | map { _escape($_) } split $EMPTY, $extra_whitespace; | ||||
62 | $description .= q{" at the end of the line}; | ||||
63 | |||||
64 | return $self->violation( $description, $EXPL, $token ); | ||||
65 | } | ||||
66 | |||||
67 | return; | ||||
68 | } | ||||
69 | |||||
70 | sub _escape { | ||||
71 | my $character = shift; | ||||
72 | my $ordinal = ord $character; | ||||
73 | |||||
74 | if (my $c_escape = $C_STYLE_ESCAPES{$ordinal}) { | ||||
75 | return $c_escape; | ||||
76 | } | ||||
77 | |||||
78 | |||||
79 | # Apparently, the charnames.pm that ships with older perls does not | ||||
80 | # support the C<viacode> function, and newer versions of the module are | ||||
81 | # not distributed separately from perl itself So if the C<viacode> method | ||||
82 | # is not supported, then just substitute something. | ||||
83 | |||||
84 | |||||
85 | ## no critic (RequireInterpolationOfMetachars) | ||||
86 | if ( charnames->can( 'viacode' ) ) { | ||||
87 | return q/\N{/ . charnames::viacode($ordinal) . q/}/; | ||||
88 | } | ||||
89 | else { | ||||
90 | return '\N{WHITESPACE CHAR}'; | ||||
91 | } | ||||
92 | } | ||||
93 | |||||
94 | 1 | 4µs | 1; | ||
95 | |||||
96 | #----------------------------------------------------------------------------- | ||||
97 | |||||
98 | __END__ |