Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/CodeLayout/RequireConsistentNewlines.pm |
Statements | Executed 23 statements in 456µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 17µs | 17µs | BEGIN@10 | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
1 | 1 | 1 | 8µs | 31µs | BEGIN@13 | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
1 | 1 | 1 | 8µs | 391µs | BEGIN@17 | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
1 | 1 | 1 | 8µs | 64µs | BEGIN@18 | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
1 | 1 | 1 | 7µs | 11µs | BEGIN@12 | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
1 | 1 | 1 | 7µs | 152µs | BEGIN@15 | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
1 | 1 | 1 | 7µs | 19µs | BEGIN@11 | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
1 | 1 | 1 | 6µs | 7µs | default_severity | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
1 | 1 | 1 | 4µs | 4µs | BEGIN@16 | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
1 | 1 | 1 | 2µs | 2µs | supported_parameters | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
1 | 1 | 1 | 2µs | 2µs | CORE:qr (opcode) | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
0 | 0 | 0 | 0s | 0s | applies_to | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
0 | 0 | 0 | 0s | 0s | default_themes | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
0 | 0 | 0 | 0s | 0s | violates | Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::
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::RequireConsistentNewlines; | ||||
9 | |||||
10 | 2 | 41µs | 1 | 17µs | # spent 17µs within Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::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::CodeLayout::RequireConsistentNewlines::BEGIN@10 |
11 | 2 | 21µs | 2 | 31µs | # spent 19µs (7+12) within Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::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::CodeLayout::RequireConsistentNewlines::BEGIN@11
# spent 12µs making 1 call to strict::import |
12 | 2 | 23µs | 2 | 15µs | # spent 11µs (7+4) within Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::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::RequireConsistentNewlines::BEGIN@12
# spent 4µs making 1 call to warnings::import |
13 | 2 | 23µs | 2 | 54µs | # spent 31µs (8+23) within Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@13 which was called:
# once (8µs+23µs) by Module::Pluggable::Object::_require at line 13 # spent 31µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@13
# spent 23µs making 1 call to Exporter::import |
14 | |||||
15 | 2 | 23µs | 2 | 297µs | # spent 152µs (7+145) within Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@15 which was called:
# once (7µs+145µs) by Module::Pluggable::Object::_require at line 15 # spent 152µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@15
# spent 145µs making 1 call to Exporter::import |
16 | 2 | 20µs | 1 | 4µs | # spent 4µs within Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@16 which was called:
# once (4µs+0s) by Module::Pluggable::Object::_require at line 16 # spent 4µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@16 |
17 | 2 | 24µs | 2 | 774µs | # spent 391µs (8+383) within Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@17 which was called:
# once (8µs+383µs) by Module::Pluggable::Object::_require at line 17 # spent 391µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@17
# spent 383µs making 1 call to English::import |
18 | 2 | 256µs | 2 | 120µs | # spent 64µs (8+56) within Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@18 which was called:
# once (8µs+56µs) by Module::Pluggable::Object::_require at line 18 # spent 64µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@18
# spent 56µs making 1 call to base::import |
19 | |||||
20 | 1 | 600ns | our $VERSION = '1.121'; | ||
21 | |||||
22 | 1 | 11µs | 2 | 31µs | Readonly::Scalar my $LINE_END => qr/\015{1,2}\012|[\012\015]/mxs; # spent 29µs making 1 call to Readonly::Scalar
# spent 2µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::CORE:qr |
23 | |||||
24 | #----------------------------------------------------------------------------- | ||||
25 | |||||
26 | 1 | 1µs | 1 | 22µs | Readonly::Scalar my $DESC => q{Use the same newline through the source}; # spent 22µs making 1 call to Readonly::Scalar |
27 | 1 | 800ns | 1 | 20µs | Readonly::Scalar my $EXPL => q{Change your newlines to be the same throughout}; # spent 20µs making 1 call to Readonly::Scalar |
28 | |||||
29 | #----------------------------------------------------------------------------- | ||||
30 | |||||
31 | 1 | 6µs | # spent 2µs within Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::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 7µs (6+1) within Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::default_severity which was called:
# once (6µs+1µs) by Perl::Critic::Policy::get_severity at line 331 of Perl/Critic/Policy.pm | ||
33 | sub default_themes { return qw( core bugs ) } | ||||
34 | sub applies_to { return 'PPI::Document' } | ||||
35 | |||||
36 | #----------------------------------------------------------------------------- | ||||
37 | |||||
38 | sub violates { | ||||
39 | my ( $self, undef, $doc ) = @_; | ||||
40 | |||||
41 | my $filename = $doc->filename(); | ||||
42 | return if !$filename; | ||||
43 | |||||
44 | my $fh; | ||||
45 | return if !open $fh, '<', $filename; | ||||
46 | local $RS = undef; | ||||
47 | my $source = <$fh>; | ||||
48 | close $fh or return; | ||||
49 | |||||
50 | my $newline; # undef until we find the first one | ||||
51 | my $line = 1; | ||||
52 | my @v; | ||||
53 | while ( $source =~ m/\G([^\012\015]*)($LINE_END)/cgmxs ) { | ||||
54 | my $code = $1; | ||||
55 | my $nl = $2; | ||||
56 | my $col = length $code; | ||||
57 | $newline ||= $nl; | ||||
58 | if ( $nl ne $newline ) { | ||||
59 | my $token = PPI::Token::Whitespace->new( $nl ); | ||||
60 | # TODO this is a terrible violation of encapsulation, but absent a | ||||
61 | # mechanism to override the line numbers in the violation, I do | ||||
62 | # not know what to do about it. | ||||
63 | $token->{_location} = [$line, $col, $col, $line, $filename]; | ||||
64 | push @v, $self->violation( $DESC, $EXPL, $token ); | ||||
65 | } | ||||
66 | $line++; | ||||
67 | } | ||||
68 | return @v; | ||||
69 | } | ||||
70 | |||||
71 | 1 | 4µs | 1; | ||
72 | |||||
73 | #----------------------------------------------------------------------------- | ||||
74 | |||||
75 | __END__ | ||||
# spent 2µs within Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::CORE:qr which was called:
# once (2µs+0s) by Module::Pluggable::Object::_require at line 22 |