← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:13 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Policy/CodeLayout/RequireConsistentNewlines.pm
StatementsExecuted 23 statements in 456µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11117µs17µsPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::BEGIN@10Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@10
1118µs31µsPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::BEGIN@13Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@13
1118µs391µsPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::BEGIN@17Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@17
1118µs64µsPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::BEGIN@18Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@18
1117µs11µsPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::BEGIN@12Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@12
1117µs152µsPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::BEGIN@15Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@15
1117µs19µsPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::BEGIN@11Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@11
1116µs7µsPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::default_severityPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::default_severity
1114µs4µsPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::BEGIN@16Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@16
1112µs2µsPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::supported_parametersPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::supported_parameters
1112µs2µsPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::CORE:qrPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::CORE:qr (opcode)
0000s0sPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::applies_toPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::applies_to
0000s0sPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::default_themesPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::default_themes
0000s0sPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::::violatesPerl::Critic::Policy::CodeLayout::RequireConsistentNewlines::violates
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1##############################################################################
2# $URL$
3# $Date$
4# $Author$
5# $Revision$
6##############################################################################
7
8package Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines;
9
10241µs117µ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
use 5.006001;
11221µs231µ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
use strict;
# spent 19µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@11 # spent 12µs making 1 call to strict::import
12223µs215µ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
use warnings;
# spent 11µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@12 # spent 4µs making 1 call to warnings::import
13223µs254µ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
use Readonly;
# spent 31µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@13 # spent 23µs making 1 call to Exporter::import
14
15223µs2297µ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
use Perl::Critic::Utils qw{ :severities };
# spent 152µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@15 # spent 145µs making 1 call to Exporter::import
16220µs14µ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
use PPI::Token::Whitespace;
17224µs2774µ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
use English qw(-no_match_vars);
# spent 391µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@17 # spent 383µs making 1 call to English::import
182256µs2120µ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
use base 'Perl::Critic::Policy';
# spent 64µs making 1 call to Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::BEGIN@18 # spent 56µs making 1 call to base::import
19
201600nsour $VERSION = '1.121';
21
22111µs231µsReadonly::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
2611µs122µsReadonly::Scalar my $DESC => q{Use the same newline through the source};
# spent 22µs making 1 call to Readonly::Scalar
271800ns120µsReadonly::Scalar my $EXPL => q{Change your newlines to be the same throughout};
# spent 20µs making 1 call to Readonly::Scalar
28
29#-----------------------------------------------------------------------------
30
3116µ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
sub supported_parameters { return () }
3212µ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
sub default_severity { return $SEVERITY_HIGH }
33sub default_themes { return qw( core bugs ) }
34sub applies_to { return 'PPI::Document' }
35
36#-----------------------------------------------------------------------------
37
38sub 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
7114µs1;
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
sub Perl::Critic::Policy::CodeLayout::RequireConsistentNewlines::CORE:qr; # opcode