← 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/ProhibitHardTabs.pm
StatementsExecuted 19 statements in 443µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11115µs15µsPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::BEGIN@10Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@10
1118µs8µsPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::supported_parametersPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::supported_parameters
1117µs11µsPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::BEGIN@12Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@12
1117µs27µsPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::BEGIN@13Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@13
1117µs18µsPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::BEGIN@11Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@11
1117µs192µsPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::BEGIN@15Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@15
1117µs56µsPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::BEGIN@16Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@16
1116µs7µsPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::default_severityPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::default_severity
1111µs1µsPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::CORE:qrPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::CORE:qr (opcode)
0000s0sPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::_allow_leading_tabsPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::_allow_leading_tabs
0000s0sPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::_is_extended_regexPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::_is_extended_regex
0000s0sPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::applies_toPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::applies_to
0000s0sPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::default_themesPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::default_themes
0000s0sPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::::violatesPerl::Critic::Policy::CodeLayout::ProhibitHardTabs::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::ProhibitHardTabs;
9
10242µs115µs
# spent 15µs within Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@10 which was called: # once (15µs+0s) by Module::Pluggable::Object::_require at line 10
use 5.006001;
11220µs229µs
# spent 18µs (7+11) within Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@11 which was called: # once (7µs+11µs) by Module::Pluggable::Object::_require at line 11
use strict;
# spent 18µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@11 # spent 11µs making 1 call to strict::import
12218µs214µs
# spent 11µs (7+4) within Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::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::ProhibitHardTabs::BEGIN@12 # spent 4µs making 1 call to warnings::import
13222µs248µs
# spent 27µs (7+20) within Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@13 which was called: # once (7µs+20µs) by Module::Pluggable::Object::_require at line 13
use Readonly;
# spent 27µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@13 # spent 20µs making 1 call to Exporter::import
14
15223µs2377µs
# spent 192µs (7+185) within Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@15 which was called: # once (7µs+185µs) by Module::Pluggable::Object::_require at line 15
use Perl::Critic::Utils qw{ :booleans :severities };
# spent 192µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@15 # spent 185µs making 1 call to Exporter::import
162293µs2106µs
# spent 56µs (7+50) within Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@16 which was called: # once (7µs+50µs) by Module::Pluggable::Object::_require at line 16
use base 'Perl::Critic::Policy';
# spent 56µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::BEGIN@16 # spent 50µs making 1 call to base::import
17
181500nsour $VERSION = '1.121';
19
20#-----------------------------------------------------------------------------
21
2212µs128µsReadonly::Scalar my $DESC => q{Hard tabs used};
# spent 28µs making 1 call to Readonly::Scalar
2312µs142µsReadonly::Scalar my $EXPL => [ 20 ];
# spent 42µs making 1 call to Readonly::Scalar
24
25#-----------------------------------------------------------------------------
26
27# The following regex should probably be "qr{^ .* [^\t]+ \t}xms" but it doesn't
28# match when I expect it to. I haven't figured out why, so I used "\S" to
29# approximately mean "not a tab", and that seemed to work.
30
3116µs222µsReadonly::Scalar my $NON_LEADING_TAB_REGEX => qr{^ .* \S+ \t }xms;
# spent 21µs making 1 call to Readonly::Scalar # spent 1µs making 1 call to Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::CORE:qr
32
33#-----------------------------------------------------------------------------
34
35
# spent 8µs within Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::supported_parameters which was called: # once (8µs+0s) by Perl::Critic::Policy::new at line 88 of Perl/Critic/Policy.pm
sub supported_parameters {
36 return (
37 {
38110µs name => 'allow_leading_tabs',
39 description => 'Allow hard tabs before first non-whitespace character.',
40 default_string => '1',
41 behavior => 'boolean',
42 },
43 );
44}
45
4612µs
# spent 7µs (6+1) within Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::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_MEDIUM }
47sub default_themes { return qw( core cosmetic pbp ) }
48sub applies_to { return 'PPI::Token' }
49
50#-----------------------------------------------------------------------------
51
52sub violates {
53 my ( $self, $elem, undef ) = @_;
54 $elem =~ m{ \t }xms || return;
55
56 # The __DATA__ element is exempt
57 return if $elem->parent->isa('PPI::Statement::Data');
58
59 # If allowed, permit leading tabs in situations where whitespace s not significant.
60 if ( $self->_allow_leading_tabs() ) {
61
62 return if $elem->location->[1] == 1;
63
64 return if _is_extended_regex($elem)
65 && $elem !~ $NON_LEADING_TAB_REGEX;
66
67 return if $elem->isa('PPI::Token::QuoteLike::Words')
68 && $elem !~ $NON_LEADING_TAB_REGEX;
69 }
70
71 # If we get here, then it must be a violation...
72 return $self->violation( $DESC, $EXPL, $elem );
73}
74
75#-----------------------------------------------------------------------------
76
77sub _allow_leading_tabs {
78 my ( $self ) = @_;
79 return $self->{_allow_leading_tabs};
80}
81
82#-----------------------------------------------------------------------------
83
84sub _is_extended_regex {
85 my ($elem) = @_;
86
87 $elem->isa('PPI::Token::Regexp')
88 || $elem->isa('PPI::Token::QuoteLike::Regexp')
89 || return;
90
91 # Look for the /x modifier near the end
92 return $elem =~ m{\b [gimso]* x [gimso]* $}xms;
93}
94
9514µs1;
96
97__END__
 
# spent 1µs within Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::CORE:qr which was called: # once (1µs+0s) by Module::Pluggable::Object::_require at line 31
sub Perl::Critic::Policy::CodeLayout::ProhibitHardTabs::CORE:qr; # opcode