← 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:11 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/Config.pm
StatementsExecuted 8168 statements in 23.2ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1118.59ms418msPerl::Critic::Config::::_load_policiesPerl::Critic::Config::_load_policies
5515.33ms6.17msPerl::Critic::Config::::_validate_and_save_color_severityPerl::Critic::Config::_validate_and_save_color_severity
1111.65ms1.31sPerl::Critic::Config::::BEGIN@24Perl::Critic::Config::BEGIN@24
1111.19ms8.20msPerl::Critic::Config::::BEGIN@26Perl::Critic::Config::BEGIN@26
289211.07ms1.07msPerl::Critic::Config::::policiesPerl::Critic::Config::policies
141111.07ms1.37msPerl::Critic::Config::::_policy_is_includedPerl::Critic::Config::_policy_is_included
14111944µs1.21msPerl::Critic::Config::::_policy_is_excludedPerl::Critic::Config::_policy_is_excluded
14111898µs3.50msPerl::Critic::Config::::_policy_is_unimportantPerl::Critic::Config::_policy_is_unimportant
14111817µs12.9msPerl::Critic::Config::::_policy_is_thematicPerl::Critic::Config::_policy_is_thematic
14111781µs3.23msPerl::Critic::Config::::_policy_is_enabledPerl::Critic::Config::_policy_is_enabled
14111778µs3.49msPerl::Critic::Config::::_policy_is_disabledPerl::Critic::Config::_policy_is_disabled
111709µs1.96msPerl::Critic::Config::::BEGIN@25Perl::Critic::Config::BEGIN@25
14411530µs549µsPerl::Critic::Config::::program_extensions_as_regexesPerl::Critic::Config::program_extensions_as_regexes
111514µs1.57msPerl::Critic::Config::::BEGIN@20Perl::Critic::Config::BEGIN@20
14411342µs342µsPerl::Critic::Config::::forcePerl::Critic::Config::force
2211331µs654µsPerl::Critic::Config::::_add_policy_if_enabledPerl::Critic::Config::_add_policy_if_enabled
297111317µs317µsPerl::Critic::Config::::_profilePerl::Critic::Config::_profile
111310µs1.82msPerl::Critic::Config::::BEGIN@22Perl::Critic::Config::BEGIN@22
111258µs426msPerl::Critic::Config::::_initPerl::Critic::Config::_init
2211243µs2.64msPerl::Critic::Config::::add_policyPerl::Critic::Config::add_policy
14221211µs211µsPerl::Critic::Config::::single_policyPerl::Critic::Config::single_policy
14111193µs193µsPerl::Critic::Config::::onlyPerl::Critic::Config::only
14111184µs184µsPerl::Critic::Config::::includePerl::Critic::Config::include
14111171µs171µsPerl::Critic::Config::::excludePerl::Critic::Config::exclude
14111154µs154µsPerl::Critic::Config::::themePerl::Critic::Config::theme
11166µs161µsPerl::Critic::Config::::_validate_and_save_themePerl::Critic::Config::_validate_and_save_theme
33158µs71µsPerl::Critic::Config::::_validate_and_save_regexPerl::Critic::Config::_validate_and_save_regex
11130µs42µsPerl::Critic::Config::::_validate_and_save_severityPerl::Critic::Config::_validate_and_save_severity
11129µs40µsPerl::Critic::Config::::_validate_and_save_profile_strictnessPerl::Critic::Config::_validate_and_save_profile_strictness
11128µs56µsPerl::Critic::Config::::_validate_and_save_verbosityPerl::Critic::Config::_validate_and_save_verbosity
297127µs27µsPerl::Critic::Config::::CORE:substPerl::Critic::Config::CORE:subst (opcode)
11124µs30µsPerl::Critic::Config::::_validate_and_save_pagerPerl::Critic::Config::_validate_and_save_pager
11124µs31µsPerl::Critic::Config::::_validate_and_save_program_extensionsPerl::Critic::Config::_validate_and_save_program_extensions
11122µs32µsPerl::Critic::Config::::_validate_and_save_topPerl::Critic::Config::_validate_and_save_top
22118µs19µsPerl::Critic::Config::::CORE:regcompPerl::Critic::Config::CORE:regcomp (opcode)
11114µs14µsPerl::Critic::Config::::BEGIN@10Perl::Critic::Config::BEGIN@10
11111µs426msPerl::Critic::Config::::newPerl::Critic::Config::new
1119µs21µsPerl::Critic::Config::::BEGIN@21Perl::Critic::Config::BEGIN@21
1118µs12µsPerl::Critic::Config::::BEGIN@12Perl::Critic::Config::BEGIN@12
1118µs120µsPerl::Critic::Config::::BEGIN@31Perl::Critic::Config::BEGIN@31
1118µs32µsPerl::Critic::Config::::BEGIN@35Perl::Critic::Config::BEGIN@35
1117µs680µsPerl::Critic::Config::::BEGIN@27Perl::Critic::Config::BEGIN@27
1117µs359µsPerl::Critic::Config::::BEGIN@14Perl::Critic::Config::BEGIN@14
1117µs26µsPerl::Critic::Config::::BEGIN@23Perl::Critic::Config::BEGIN@23
1117µs26µsPerl::Critic::Config::::BEGIN@15Perl::Critic::Config::BEGIN@15
1117µs27µsPerl::Critic::Config::::BEGIN@18Perl::Critic::Config::BEGIN@18
1116µs17µsPerl::Critic::Config::::BEGIN@11Perl::Critic::Config::BEGIN@11
1116µs231µsPerl::Critic::Config::::BEGIN@17Perl::Critic::Config::BEGIN@17
1113µs3µsPerl::Critic::Config::::pagerPerl::Critic::Config::pager
1113µs3µsPerl::Critic::Config::::program_extensionsPerl::Critic::Config::program_extensions
1112µs2µsPerl::Critic::Config::::profile_strictnessPerl::Critic::Config::profile_strictness
1112µs2µsPerl::Critic::Config::::CORE:qrPerl::Critic::Config::CORE:qr (opcode)
1111µs1µsPerl::Critic::Config::::CORE:sortPerl::Critic::Config::CORE:sort (opcode)
111300ns300nsPerl::Critic::Config::::CORE:matchPerl::Critic::Config::CORE:match (opcode)
0000s0sPerl::Critic::Config::::__ANON__[:299]Perl::Critic::Config::__ANON__[:299]
0000s0sPerl::Critic::Config::::__ANON__[:308]Perl::Critic::Config::__ANON__[:308]
0000s0sPerl::Critic::Config::::__ANON__[:320]Perl::Critic::Config::__ANON__[:320]
0000s0sPerl::Critic::Config::::__ANON__[:348]Perl::Critic::Config::__ANON__[:348]
0000s0sPerl::Critic::Config::::__ANON__[:547]Perl::Critic::Config::__ANON__[:547]
0000s0sPerl::Critic::Config::::_add_single_policy_exception_toPerl::Critic::Config::_add_single_policy_exception_to
0000s0sPerl::Critic::Config::::_new_global_value_exceptionPerl::Critic::Config::_new_global_value_exception
0000s0sPerl::Critic::Config::::_policy_is_single_policyPerl::Critic::Config::_policy_is_single_policy
0000s0sPerl::Critic::Config::::all_policies_enabled_or_notPerl::Critic::Config::all_policies_enabled_or_not
0000s0sPerl::Critic::Config::::colorPerl::Critic::Config::color
0000s0sPerl::Critic::Config::::color_severity_highPerl::Critic::Config::color_severity_high
0000s0sPerl::Critic::Config::::color_severity_highestPerl::Critic::Config::color_severity_highest
0000s0sPerl::Critic::Config::::color_severity_lowPerl::Critic::Config::color_severity_low
0000s0sPerl::Critic::Config::::color_severity_lowestPerl::Critic::Config::color_severity_lowest
0000s0sPerl::Critic::Config::::color_severity_mediumPerl::Critic::Config::color_severity_medium
0000s0sPerl::Critic::Config::::criticism_fatalPerl::Critic::Config::criticism_fatal
0000s0sPerl::Critic::Config::::severityPerl::Critic::Config::severity
0000s0sPerl::Critic::Config::::site_policy_namesPerl::Critic::Config::site_policy_names
0000s0sPerl::Critic::Config::::topPerl::Critic::Config::top
0000s0sPerl::Critic::Config::::unsafe_allowedPerl::Critic::Config::unsafe_allowed
0000s0sPerl::Critic::Config::::verbosePerl::Critic::Config::verbose
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::Config;
9
10235µs114µs
# spent 14µs within Perl::Critic::Config::BEGIN@10 which was called: # once (14µs+0s) by Perl::Critic::BEGIN@24 at line 10
use 5.006001;
# spent 14µs making 1 call to Perl::Critic::Config::BEGIN@10
11218µs228µs
# spent 17µs (6+11) within Perl::Critic::Config::BEGIN@11 which was called: # once (6µs+11µs) by Perl::Critic::BEGIN@24 at line 11
use strict;
# spent 17µs making 1 call to Perl::Critic::Config::BEGIN@11 # spent 11µs making 1 call to strict::import
12219µs216µs
# spent 12µs (8+4) within Perl::Critic::Config::BEGIN@12 which was called: # once (8µs+4µs) by Perl::Critic::BEGIN@24 at line 12
use warnings;
# spent 12µs making 1 call to Perl::Critic::Config::BEGIN@12 # spent 4µs making 1 call to warnings::import
13
14220µs2711µs
# spent 359µs (7+352) within Perl::Critic::Config::BEGIN@14 which was called: # once (7µs+352µs) by Perl::Critic::BEGIN@24 at line 14
use English qw(-no_match_vars);
# spent 359µs making 1 call to Perl::Critic::Config::BEGIN@14 # spent 352µs making 1 call to English::import
15221µs244µs
# spent 26µs (7+19) within Perl::Critic::Config::BEGIN@15 which was called: # once (7µs+19µs) by Perl::Critic::BEGIN@24 at line 15
use Readonly;
# spent 26µs making 1 call to Perl::Critic::Config::BEGIN@15 # spent 19µs making 1 call to Exporter::import
16
17223µs2455µs
# spent 231µs (6+224) within Perl::Critic::Config::BEGIN@17 which was called: # once (6µs+224µs) by Perl::Critic::BEGIN@24 at line 17
use List::MoreUtils qw(any none apply);
# spent 231µs making 1 call to Perl::Critic::Config::BEGIN@17 # spent 224µs making 1 call to Exporter::Tiny::import
18219µs247µs
# spent 27µs (7+20) within Perl::Critic::Config::BEGIN@18 which was called: # once (7µs+20µs) by Perl::Critic::BEGIN@24 at line 18
use Scalar::Util qw(blessed);
# spent 27µs making 1 call to Perl::Critic::Config::BEGIN@18 # spent 20µs making 1 call to Exporter::import
19
20289µs21.59ms
# spent 1.57ms (514µs+1.06) within Perl::Critic::Config::BEGIN@20 which was called: # once (514µs+1.06ms) by Perl::Critic::BEGIN@24 at line 20
use Perl::Critic::Exception::AggregateConfiguration;
# spent 1.57ms making 1 call to Perl::Critic::Config::BEGIN@20 # spent 17µs making 1 call to Exporter::import
21220µs233µs
# spent 21µs (9+12) within Perl::Critic::Config::BEGIN@21 which was called: # once (9µs+12µs) by Perl::Critic::BEGIN@24 at line 21
use Perl::Critic::Exception::Configuration;
# spent 21µs making 1 call to Perl::Critic::Config::BEGIN@21 # spent 12µs making 1 call to Exporter::import
22295µs21.83ms
# spent 1.82ms (310µs+1.51) within Perl::Critic::Config::BEGIN@22 which was called: # once (310µs+1.51ms) by Perl::Critic::BEGIN@24 at line 22
use Perl::Critic::Exception::Configuration::Option::Global::ParameterValue;
# spent 1.82ms making 1 call to Perl::Critic::Config::BEGIN@22 # spent 15µs making 1 call to Exporter::import
23219µs246µs
# spent 26µs (7+19) within Perl::Critic::Config::BEGIN@23 which was called: # once (7µs+19µs) by Perl::Critic::BEGIN@24 at line 23
use Perl::Critic::Exception::Fatal::Internal qw{ throw_internal };
# spent 26µs making 1 call to Perl::Critic::Config::BEGIN@23 # spent 19µs making 1 call to Exporter::import
24295µs22.62s
# spent 1.31s (1.65ms+1.31) within Perl::Critic::Config::BEGIN@24 which was called: # once (1.65ms+1.31s) by Perl::Critic::BEGIN@24 at line 24
use Perl::Critic::PolicyFactory;
# spent 1.31s making 1 call to Perl::Critic::Config::BEGIN@24 # spent 1.30s making 1 call to Perl::Critic::PolicyFactory::import
25291µs22.04ms
# spent 1.96ms (709µs+1.25) within Perl::Critic::Config::BEGIN@25 which was called: # once (709µs+1.25ms) by Perl::Critic::BEGIN@24 at line 25
use Perl::Critic::Theme qw( $RULE_INVALID_CHARACTER_REGEX cook_rule );
# spent 1.96ms making 1 call to Perl::Critic::Config::BEGIN@25 # spent 84µs making 1 call to Exporter::import
26292µs18.20ms
# spent 8.20ms (1.19+7.00) within Perl::Critic::Config::BEGIN@26 which was called: # once (1.19ms+7.00ms) by Perl::Critic::BEGIN@24 at line 26
use Perl::Critic::UserProfile qw();
# spent 8.20ms making 1 call to Perl::Critic::Config::BEGIN@26
271200ns
# spent 680µs (7+673) within Perl::Critic::Config::BEGIN@27 which was called: # once (7µs+673µs) by Perl::Critic::BEGIN@24 at line 30
use Perl::Critic::Utils qw{
28 :booleans :characters :severities :internal_lookup :classification
29 :data_conversion
30128µs21.35ms};
# spent 680µs making 1 call to Perl::Critic::Config::BEGIN@27 # spent 673µs making 1 call to Exporter::import
311400ns
# spent 120µs (8+112) within Perl::Critic::Config::BEGIN@31 which was called: # once (8µs+112µs) by Perl::Critic::BEGIN@24 at line 34
use Perl::Critic::Utils::Constants qw<
32 :profile_strictness
33 $_MODULE_VERSION_TERM_ANSICOLOR
34125µs2232µs>;
# spent 120µs making 1 call to Perl::Critic::Config::BEGIN@31 # spent 112µs making 1 call to Exporter::import
3522.79ms256µs
# spent 32µs (8+24) within Perl::Critic::Config::BEGIN@35 which was called: # once (8µs+24µs) by Perl::Critic::BEGIN@24 at line 35
use Perl::Critic::Utils::DataConversion qw< boolean_to_number dor >;
# spent 32µs making 1 call to Perl::Critic::Config::BEGIN@35 # spent 24µs making 1 call to Exporter::import
36
37#-----------------------------------------------------------------------------
38
391700nsour $VERSION = '1.121';
40
41#-----------------------------------------------------------------------------
42
4312µs135µsReadonly::Scalar my $SINGLE_POLICY_CONFIG_KEY => 'single-policy';
# spent 35µs making 1 call to Readonly::Scalar
44
45#-----------------------------------------------------------------------------
46# Constructor
47
48
# spent 426ms (11µs+426) within Perl::Critic::Config::new which was called: # once (11µs+426ms) by Perl::Critic::new at line 42 of Perl/Critic.pm
sub new {
49
501900ns my ( $class, %args ) = @_;
5111µs my $self = bless {}, $class;
5213µs1426ms $self->_init( %args );
# spent 426ms making 1 call to Perl::Critic::Config::_init
5314µs return $self;
54}
55
56#-----------------------------------------------------------------------------
57
58
# spent 426ms (258µs+426) within Perl::Critic::Config::_init which was called: # once (258µs+426ms) by Perl::Critic::Config::new at line 52
sub _init {
591700ns my ( $self, %args ) = @_;
60
61 # -top or -theme imply that -severity is 1, unless it is already defined
6212µs if ( defined $args{-top} || defined $args{-theme} ) {
63 $args{-severity} ||= $SEVERITY_LOWEST;
64 }
65
6613µs1601µs my $errors = Perl::Critic::Exception::AggregateConfiguration->new();
# spent 601µs making 1 call to Perl::Critic::Exception::AggregateConfiguration::new
67
68 # Construct the UserProfile to get default options.
6911µs my $profile_source = $args{-profile}; # Can be file path or data struct
7015µs1635µs my $profile = Perl::Critic::UserProfile->new( -profile => $profile_source );
# spent 635µs making 1 call to Perl::Critic::UserProfile::new
7112µs12µs my $options_processor = $profile->options_processor();
# spent 2µs making 1 call to Perl::Critic::UserProfile::options_processor
7212µs $self->{_profile} = $profile;
73
7413µs140µs $self->_validate_and_save_profile_strictness(
75 $args{'-profile-strictness'},
76 $errors,
77 );
78
79 # If given, these options should always have a true value.
8016µs236µs $self->_validate_and_save_regex(
# spent 34µs making 1 call to Perl::Critic::Config::_validate_and_save_regex # spent 2µs making 1 call to Perl::Critic::OptionsProcessor::include
81 'include', $args{-include}, $options_processor->include(), $errors
82 );
8315µs217µs $self->_validate_and_save_regex(
# spent 14µs making 1 call to Perl::Critic::Config::_validate_and_save_regex # spent 3µs making 1 call to Perl::Critic::OptionsProcessor::exclude
84 'exclude', $args{-exclude}, $options_processor->exclude(), $errors
85 );
8617µs326µs $self->_validate_and_save_regex(
# spent 22µs making 1 call to Perl::Critic::Config::_validate_and_save_regex # spent 2µs making 1 call to Perl::Critic::OptionsProcessor::single_policy # spent 2µs making 1 call to Readonly::Scalar::FETCH
87 $SINGLE_POLICY_CONFIG_KEY,
88 $args{ qq/-$SINGLE_POLICY_CONFIG_KEY/ },
89 $options_processor->single_policy(),
90 $errors,
91 );
9216µs25.96ms $self->_validate_and_save_color_severity(
93 'color_severity_highest', $args{'-color-severity-highest'},
94 $options_processor->color_severity_highest(), $errors
95 );
9616µs269µs $self->_validate_and_save_color_severity(
97 'color_severity_high', $args{'-color-severity-high'},
98 $options_processor->color_severity_high(), $errors
99 );
10014µs251µs $self->_validate_and_save_color_severity(
101 'color_severity_medium', $args{'-color-severity-medium'},
102 $options_processor->color_severity_medium(), $errors
103 );
10414µs250µs $self->_validate_and_save_color_severity(
105 'color_severity_low', $args{'-color-severity-low'},
106 $options_processor->color_severity_low(), $errors
107 );
10814µs248µs $self->_validate_and_save_color_severity(
109 'color_severity_lowest', $args{'-color-severity-lowest'},
110 $options_processor->color_severity_lowest(), $errors
111 );
112
11314µs156µs $self->_validate_and_save_verbosity($args{-verbose}, $errors);
# spent 56µs making 1 call to Perl::Critic::Config::_validate_and_save_verbosity
11413µs142µs $self->_validate_and_save_severity($args{-severity}, $errors);
# spent 42µs making 1 call to Perl::Critic::Config::_validate_and_save_severity
11513µs132µs $self->_validate_and_save_top($args{-top}, $errors);
# spent 32µs making 1 call to Perl::Critic::Config::_validate_and_save_top
11613µs1161µs $self->_validate_and_save_theme($args{-theme}, $errors);
# spent 161µs making 1 call to Perl::Critic::Config::_validate_and_save_theme
11713µs130µs $self->_validate_and_save_pager($args{-pager}, $errors);
# spent 30µs making 1 call to Perl::Critic::Config::_validate_and_save_pager
11813µs131µs $self->_validate_and_save_program_extensions(
119 $args{'-program-extensions'}, $errors);
120
121 # If given, these options can be true or false (but defined)
122 # We normalize these to numeric values by multiplying them by 1;
123111µs416µs $self->{_force} = boolean_to_number( dor( $args{-force}, $options_processor->force() ) );
# spent 8µs making 1 call to Perl::Critic::Utils::DataConversion::boolean_to_number # spent 4µs making 1 call to Perl::Critic::Utils::DataConversion::dor # spent 2µs making 1 call to Perl::Critic::OptionsProcessor::force # spent 1µs making 1 call to Readonly::Scalar::FETCH
12418µs411µs $self->{_only} = boolean_to_number( dor( $args{-only}, $options_processor->only() ) );
# spent 6µs making 1 call to Perl::Critic::Utils::DataConversion::boolean_to_number # spent 2µs making 1 call to Perl::Critic::OptionsProcessor::only # spent 2µs making 1 call to Perl::Critic::Utils::DataConversion::dor # spent 1µs making 1 call to Readonly::Scalar::FETCH
12517µs411µs $self->{_color} = boolean_to_number( dor( $args{-color}, $options_processor->color() ) );
# spent 6µs making 1 call to Perl::Critic::Utils::DataConversion::boolean_to_number # spent 2µs making 1 call to Perl::Critic::OptionsProcessor::color # spent 2µs making 1 call to Perl::Critic::Utils::DataConversion::dor # spent 1µs making 1 call to Readonly::Scalar::FETCH
12617µs413µs $self->{_unsafe_allowed} =
# spent 8µs making 1 call to Perl::Critic::Utils::DataConversion::boolean_to_number # spent 2µs making 1 call to Perl::Critic::OptionsProcessor::allow_unsafe # spent 2µs making 1 call to Perl::Critic::Utils::DataConversion::dor # spent 1µs making 1 call to Readonly::Scalar::FETCH
127 boolean_to_number(
128 dor( $args{'-allow-unsafe'}, $options_processor->allow_unsafe()
129 ) );
13017µs410µs $self->{_criticism_fatal} =
# spent 5µs making 1 call to Perl::Critic::Utils::DataConversion::boolean_to_number # spent 2µs making 1 call to Perl::Critic::OptionsProcessor::criticism_fatal # spent 2µs making 1 call to Perl::Critic::Utils::DataConversion::dor # spent 1µs making 1 call to Readonly::Scalar::FETCH
131 boolean_to_number(
132 dor( $args{'-criticism-fatal'}, $options_processor->criticism_fatal() )
133 );
134
135
136 # Construct a Factory with the Profile
13716µs2190µs my $factory =
# spent 188µs making 1 call to Perl::Critic::PolicyFactory::new # spent 2µs making 1 call to Perl::Critic::Config::profile_strictness
138 Perl::Critic::PolicyFactory->new(
139 -profile => $profile,
140 -errors => $errors,
141 '-profile-strictness' => $self->profile_strictness(),
142 );
1431500ns $self->{_factory} = $factory;
144
145 # Initialize internal storage for Policies
1461400ns $self->{_all_policies_enabled_or_not} = [];
1471500ns $self->{_policies} = [];
148
149 # "NONE" means don't load any policies
15013µs1418ms if ( not defined $profile_source or $profile_source ne 'NONE' ) {
# spent 418ms making 1 call to Perl::Critic::Config::_load_policies
151 # Heavy lifting here...
152 $self->_load_policies($errors);
153 }
154
15513µs17µs if ( $errors->has_exceptions() ) {
156 $errors->rethrow();
157 }
158
159144µs return $self;
160}
161
162#-----------------------------------------------------------------------------
163
164
# spent 2.64ms (243µs+2.40) within Perl::Critic::Config::add_policy which was called 22 times, avg 120µs/call: # 22 times (243µs+2.40ms) by Perl::Critic::Config::_load_policies at line 249, avg 120µs/call
sub add_policy {
165
1662216µs my ( $self, %args ) = @_;
167
1682254µs221.71ms if ( not $args{-policy} ) {
# spent 1.71ms making 22 calls to Perl::Critic::Policy::to_string, avg 78µs/call
169 throw_internal q{The -policy argument is required};
170 }
171
1722212µs my $policy = $args{-policy};
173
174 # If the -policy is already a blessed object, then just add it directly.
1752278µs2232µs if ( blessed $policy ) {
# spent 32µs making 22 calls to Scalar::Util::blessed, avg 1µs/call
1762225µs22654µs $self->_add_policy_if_enabled($policy);
# spent 654µs making 22 calls to Perl::Critic::Config::_add_policy_if_enabled, avg 30µs/call
1772252µs return $self;
178 }
179
180 # NOTE: The "-config" option is supported for backward compatibility.
181 my $params = $args{-params} || $args{-config};
182
183 my $factory = $self->{_factory};
184 my $policy_object =
185 $factory->create_policy(-name=>$policy, -params=>$params);
186 $self->_add_policy_if_enabled($policy_object);
187
188 return $self;
189}
190
191#-----------------------------------------------------------------------------
192
193
# spent 654µs (331+322) within Perl::Critic::Config::_add_policy_if_enabled which was called 22 times, avg 30µs/call: # 22 times (331µs+322µs) by Perl::Critic::Config::add_policy at line 176, avg 30µs/call
sub _add_policy_if_enabled {
194226µs my ( $self, $policy_object ) = @_;
195
1962234µs2234µs my $config = $policy_object->__get_config()
# spent 34µs making 22 calls to Perl::Critic::Policy::__get_config, avg 2µs/call
197 or throw_internal
198 q{Policy was not set up properly because it does not have }
199 . q{a value for its config attribute.};
200
2012217µs push @{ $self->{_all_policies_enabled_or_not} }, $policy_object;
20222126µs42178µs if ( $policy_object->initialize_if_enabled( $config ) ) {
# spent 106µs making 19 calls to Perl::Critic::Policy::initialize_if_enabled, avg 6µs/call # spent 35µs making 1 call to Perl::Critic::Policy::ControlStructures::ProhibitMutatingListFunctions::initialize_if_enabled # spent 29µs making 20 calls to Readonly::Scalar::FETCH, avg 1µs/call # spent 4µs making 1 call to Perl::Critic::Policy::Variables::ProhibitEvilVariables::initialize_if_enabled # spent 4µs making 1 call to Perl::Critic::Policy::Modules::ProhibitEvilModules::initialize_if_enabled
2032155µs21133µs $policy_object->__set_enabled($TRUE);
# spent 133µs making 21 calls to Perl::Critic::Policy::__set_enabled, avg 6µs/call
2042117µs push @{ $self->{_policies} }, $policy_object;
205 }
206 else {
20713µs16µs $policy_object->__set_enabled($FALSE);
# spent 6µs making 1 call to Perl::Critic::Policy::__set_enabled
208 }
209
2102241µs return;
211}
212
213#-----------------------------------------------------------------------------
214
215
# spent 418ms (8.59+409) within Perl::Critic::Config::_load_policies which was called: # once (8.59ms+409ms) by Perl::Critic::Config::_init at line 150
sub _load_policies {
216
2171400ns my ( $self, $errors ) = @_;
2181400ns my $factory = $self->{_factory};
21919µs1379ms my @policies = $factory->create_all_policies( $errors );
# spent 379ms making 1 call to Perl::Critic::PolicyFactory::create_all_policies
220
22112µs15µs return if $errors->has_exceptions();
222
223124µs for my $policy ( @policies ) {
224
225 # If -single-policy is true, only load policies that match it
226141160µs141210µs if ( $self->single_policy() ) {
# spent 210µs making 141 calls to Perl::Critic::Config::single_policy, avg 1µs/call
227 if ( $self->_policy_is_single_policy( $policy ) ) {
228 $self->add_policy( -policy => $policy );
229 }
230 next;
231 }
232
233 # Always exclude unsafe policies, unless instructed not to
234141853µs282967µs next if not ( $policy->is_safe() or $self->unsafe_allowed() );
# spent 760µs making 141 calls to Perl::Critic::Policy::is_safe, avg 5µs/call # spent 207µs making 141 calls to Readonly::Scalar::FETCH, avg 1µs/call
235
236 # To load, or not to load -- that is the question.
237141408µs282352µs my $load_me = $self->only() ? $FALSE : $TRUE;
# spent 193µs making 141 calls to Perl::Critic::Config::only, avg 1µs/call # spent 158µs making 141 calls to Readonly::Scalar::FETCH, avg 1µs/call
238
239 ## no critic (ProhibitPostfixControls)
240141170µs1413.49ms $load_me = $FALSE if $self->_policy_is_disabled( $policy );
# spent 3.49ms making 141 calls to Perl::Critic::Config::_policy_is_disabled, avg 25µs/call
241141188µs1413.23ms $load_me = $TRUE if $self->_policy_is_enabled( $policy );
# spent 3.23ms making 141 calls to Perl::Critic::Config::_policy_is_enabled, avg 23µs/call
242141408µs2603.64ms $load_me = $FALSE if $self->_policy_is_unimportant( $policy );
# spent 3.50ms making 141 calls to Perl::Critic::Config::_policy_is_unimportant, avg 25µs/call # spent 136µs making 119 calls to Readonly::Scalar::FETCH, avg 1µs/call
243141155µs14112.9ms $load_me = $FALSE if not $self->_policy_is_thematic( $policy );
# spent 12.9ms making 141 calls to Perl::Critic::Config::_policy_is_thematic, avg 91µs/call
244141324µs1411.37ms $load_me = $TRUE if $self->_policy_is_included( $policy );
# spent 1.37ms making 141 calls to Perl::Critic::Config::_policy_is_included, avg 10µs/call
245141264µs1411.21ms $load_me = $FALSE if $self->_policy_is_excluded( $policy );
# spent 1.21ms making 141 calls to Perl::Critic::Config::_policy_is_excluded, avg 9µs/call
246
247
24814178µs next if not $load_me;
2492248µs222.64ms $self->add_policy( -policy => $policy );
# spent 2.64ms making 22 calls to Perl::Critic::Config::add_policy, avg 120µs/call
250 }
251
252 # When using -single-policy, only one policy should ever be loaded.
25311µs11µs if ($self->single_policy() && scalar $self->policies() != 1) {
# spent 1µs making 1 call to Perl::Critic::Config::single_policy
254 $self->_add_single_policy_exception_to($errors);
255 }
256
2571771µs return;
258}
259
260#-----------------------------------------------------------------------------
261
262
# spent 3.49ms (778µs+2.71) within Perl::Critic::Config::_policy_is_disabled which was called 141 times, avg 25µs/call: # 141 times (778µs+2.71ms) by Perl::Critic::Config::_load_policies at line 240, avg 25µs/call
sub _policy_is_disabled {
26314130µs my ($self, $policy) = @_;
264141139µs141151µs my $profile = $self->_profile();
# spent 151µs making 141 calls to Perl::Critic::Config::_profile, avg 1µs/call
265141359µs1412.56ms return $profile->policy_is_disabled( $policy );
# spent 2.56ms making 141 calls to Perl::Critic::UserProfile::policy_is_disabled, avg 18µs/call
266}
267
268#-----------------------------------------------------------------------------
269
270
# spent 3.23ms (781µs+2.44) within Perl::Critic::Config::_policy_is_enabled which was called 141 times, avg 23µs/call: # 141 times (781µs+2.44ms) by Perl::Critic::Config::_load_policies at line 241, avg 23µs/call
sub _policy_is_enabled {
27114132µs my ($self, $policy) = @_;
272141126µs141148µs my $profile = $self->_profile();
# spent 148µs making 141 calls to Perl::Critic::Config::_profile, avg 1µs/call
273141362µs1412.30ms return $profile->policy_is_enabled( $policy );
# spent 2.30ms making 141 calls to Perl::Critic::UserProfile::policy_is_enabled, avg 16µs/call
274}
275
276#-----------------------------------------------------------------------------
277
278
# spent 12.9ms (817µs+12.1) within Perl::Critic::Config::_policy_is_thematic which was called 141 times, avg 91µs/call: # 141 times (817µs+12.1ms) by Perl::Critic::Config::_load_policies at line 243, avg 91µs/call
sub _policy_is_thematic {
27914131µs my ($self, $policy) = @_;
280141138µs141154µs my $theme = $self->theme();
# spent 154µs making 141 calls to Perl::Critic::Config::theme, avg 1µs/call
281141401µs14111.9ms return $theme->policy_is_thematic( -policy => $policy );
# spent 11.9ms making 141 calls to Perl::Critic::Theme::policy_is_thematic, avg 85µs/call
282}
283
284#-----------------------------------------------------------------------------
285
286
# spent 3.50ms (898µs+2.60) within Perl::Critic::Config::_policy_is_unimportant which was called 141 times, avg 25µs/call: # 141 times (898µs+2.60ms) by Perl::Critic::Config::_load_policies at line 242, avg 25µs/call
sub _policy_is_unimportant {
28714140µs my ($self, $policy) = @_;
288141442µs1412.60ms my $policy_severity = $policy->get_severity();
# spent 2.60ms making 141 calls to Perl::Critic::Policy::get_severity, avg 18µs/call
28914143µs my $min_severity = $self->{_severity};
290141290µs return $policy_severity < $min_severity;
291}
292
293#-----------------------------------------------------------------------------
294
295
# spent 1.37ms (1.07+302µs) within Perl::Critic::Config::_policy_is_included which was called 141 times, avg 10µs/call: # 141 times (1.07ms+302µs) by Perl::Critic::Config::_load_policies at line 244, avg 10µs/call
sub _policy_is_included {
29614135µs my ($self, $policy) = @_;
29714142µs my $policy_long_name = ref $policy;
298141162µs141184µs my @inclusions = $self->include();
# spent 184µs making 141 calls to Perl::Critic::Config::include, avg 1µs/call
299141808µs141118µs return any { $policy_long_name =~ m/$_/ixms } @inclusions;
# spent 118µs making 141 calls to List::MoreUtils::any, avg 835ns/call
300}
301
302#-----------------------------------------------------------------------------
303
304
# spent 1.21ms (944µs+264µs) within Perl::Critic::Config::_policy_is_excluded which was called 141 times, avg 9µs/call: # 141 times (944µs+264µs) by Perl::Critic::Config::_load_policies at line 245, avg 9µs/call
sub _policy_is_excluded {
30514131µs my ($self, $policy) = @_;
30614144µs my $policy_long_name = ref $policy;
307141146µs141171µs my @exclusions = $self->exclude();
# spent 171µs making 141 calls to Perl::Critic::Config::exclude, avg 1µs/call
308141714µs14193µs return any { $policy_long_name =~ m/$_/ixms } @exclusions;
# spent 93µs making 141 calls to List::MoreUtils::any, avg 658ns/call
309}
310
311#-----------------------------------------------------------------------------
312
313sub _policy_is_single_policy {
314 my ($self, $policy) = @_;
315
316 my @patterns = $self->single_policy();
317 return if not @patterns;
318
319 my $policy_long_name = ref $policy;
320 return any { $policy_long_name =~ m/$_/ixms } @patterns;
321}
322
323#-----------------------------------------------------------------------------
324
325sub _new_global_value_exception {
326 my ($self, @args) = @_;
327
328 return
329 Perl::Critic::Exception::Configuration::Option::Global::ParameterValue
330 ->new(@args);
331}
332
333#-----------------------------------------------------------------------------
334
335sub _add_single_policy_exception_to {
336 my ($self, $errors) = @_;
337
338 my $message_suffix = $EMPTY;
339 my $patterns = join q{", "}, $self->single_policy();
340
341 if (scalar $self->policies() == 0) {
342 $message_suffix =
343 q{did not match any policies (in combination with }
344 . q{other policy restrictions).};
345 }
346 else {
347 $message_suffix = qq{matched multiple policies:\n\t};
348 $message_suffix .= join qq{,\n\t}, apply { chomp } sort $self->policies();
349 }
350
351 $errors->add_exception(
352 $self->_new_global_value_exception(
353 option_name => $SINGLE_POLICY_CONFIG_KEY,
354 option_value => $patterns,
355 message_suffix => $message_suffix,
356 )
357 );
358
359 return;
360}
361
362#-----------------------------------------------------------------------------
363
364
# spent 71µs (58+13) within Perl::Critic::Config::_validate_and_save_regex which was called 3 times, avg 24µs/call: # once (31µs+4µs) by Perl::Critic::Config::_init at line 80 # once (16µs+6µs) by Perl::Critic::Config::_init at line 86 # once (12µs+3µs) by Perl::Critic::Config::_init at line 83
sub _validate_and_save_regex {
36534µs11µs my ($self, $option_name, $args_value, $default_value, $errors) = @_;
# spent 1µs making 1 call to Readonly::Scalar::FETCH
366
3673300ns my $full_option_name;
3683100ns my $source;
3693400ns my @regexes;
370
3713400ns if ($args_value) {
372 $full_option_name = "-$option_name";
373
374 if (ref $args_value) {
375 @regexes = @{ $args_value };
376 }
377 else {
378 @regexes = ( $args_value );
379 }
380 }
381
382310µs if (not @regexes) {
3833900ns $full_option_name = $option_name;
38436µs68µs $source = $self->_profile()->source();
# spent 4µs making 3 calls to Perl::Critic::UserProfile::source, avg 1µs/call # spent 4µs making 3 calls to Perl::Critic::Config::_profile, avg 1µs/call
385
38632µs if (ref $default_value) {
387 @regexes = @{ $default_value };
388 }
389 elsif ($default_value) {
390 @regexes = ( $default_value );
391 }
392 }
393
3943200ns my $found_errors;
39532µs foreach my $regex (@regexes) {
396 eval { qr/$regex/ixms }
397 or do {
398 my $cleaned_error = $EVAL_ERROR || '<unknown reason>';
399 $cleaned_error =~
400 s/ [ ] at [ ] .* Config [.] pm [ ] line [ ] \d+ [.] \n? \z/./xms;
401
402 $errors->add_exception(
403 $self->_new_global_value_exception(
404 option_name => $option_name,
405 option_value => $regex,
406 source => $source,
407 message_suffix => qq{is not valid: $cleaned_error},
408 )
409 );
410
411 $found_errors = 1;
412 }
413 }
414
4153900ns if (not $found_errors) {
4163700ns my $option_key = $option_name;
417311µs33µs $option_key =~ s/ - /_/xmsg;
# spent 3µs making 3 calls to Perl::Critic::Config::CORE:subst, avg 1µs/call
418
41933µs $self->{"_$option_key"} = \@regexes;
420 }
421
42238µs return;
423}
424
425#-----------------------------------------------------------------------------
426
427
# spent 40µs (29+11) within Perl::Critic::Config::_validate_and_save_profile_strictness which was called: # once (29µs+11µs) by Perl::Critic::Config::_init at line 74
sub _validate_and_save_profile_strictness {
4281900ns my ($self, $args_value, $errors) = @_;
429
4301200ns my $option_name;
4311100ns my $source;
4321200ns my $profile_strictness;
433
4341500ns if ($args_value) {
435 $option_name = '-profile-strictness';
436 $profile_strictness = $args_value;
437 }
438 else {
4391500ns $option_name = 'profile-strictness';
440
44113µs12µs my $profile = $self->_profile();
# spent 2µs making 1 call to Perl::Critic::Config::_profile
44212µs12µs $source = $profile->source();
# spent 2µs making 1 call to Perl::Critic::UserProfile::source
44314µs24µs $profile_strictness = $profile->options_processor()->profile_strictness();
# spent 3µs making 1 call to Perl::Critic::OptionsProcessor::profile_strictness # spent 1µs making 1 call to Perl::Critic::UserProfile::options_processor
444 }
445
44614µs12µs if ( not $PROFILE_STRICTNESSES{$profile_strictness} ) {
# spent 2µs making 1 call to Readonly::Hash::FETCH
447 $errors->add_exception(
448 $self->_new_global_value_exception(
449 option_name => $option_name,
450 option_value => $profile_strictness,
451 source => $source,
452 message_suffix => q{is not one of "}
453 . join ( q{", "}, (sort keys %PROFILE_STRICTNESSES) )
454 . q{".},
455 )
456 );
457
458 $profile_strictness = $PROFILE_STRICTNESS_FATAL;
459 }
460
4611800ns $self->{_profile_strictness} = $profile_strictness;
462
46314µs return;
464}
465
466#-----------------------------------------------------------------------------
467
468
# spent 56µs (28+27) within Perl::Critic::Config::_validate_and_save_verbosity which was called: # once (28µs+27µs) by Perl::Critic::Config::_init at line 113
sub _validate_and_save_verbosity {
4691800ns my ($self, $args_value, $errors) = @_;
470
4711200ns my $option_name;
4721100ns my $source;
4731200ns my $verbosity;
474
4751600ns if ($args_value) {
476 $option_name = '-verbose';
477 $verbosity = $args_value;
478 }
479 else {
4801500ns $option_name = 'verbose';
481
48211µs11µs my $profile = $self->_profile();
# spent 1µs making 1 call to Perl::Critic::Config::_profile
48312µs11µs $source = $profile->source();
# spent 1µs making 1 call to Perl::Critic::UserProfile::source
48414µs24µs $verbosity = $profile->options_processor()->verbose();
# spent 2µs making 1 call to Perl::Critic::OptionsProcessor::verbose # spent 2µs making 1 call to Perl::Critic::UserProfile::options_processor
485 }
486
48716µs221µs if (
# spent 11µs making 1 call to Perl::Critic::Utils::is_valid_numeric_verbosity # spent 10µs making 1 call to Perl::Critic::Utils::is_integer
488 is_integer($verbosity)
489 and not is_valid_numeric_verbosity($verbosity)
490 ) {
491 $errors->add_exception(
492 $self->_new_global_value_exception(
493 option_name => $option_name,
494 option_value => $verbosity,
495 source => $source,
496 message_suffix =>
497 'is not the number of one of the pre-defined verbosity formats.',
498 )
499 );
500 }
501 else {
5021700ns $self->{_verbose} = $verbosity;
503 }
504
50514µs return;
506}
507
508#-----------------------------------------------------------------------------
509
510
# spent 42µs (30+13) within Perl::Critic::Config::_validate_and_save_severity which was called: # once (30µs+13µs) by Perl::Critic::Config::_init at line 114
sub _validate_and_save_severity {
5111400ns my ($self, $args_value, $errors) = @_;
512
5131100ns my $option_name;
5141100ns my $source;
5151100ns my $severity;
516
5171600ns if ($args_value) {
518 $option_name = '-severity';
519 $severity = $args_value;
520 }
521 else {
5221400ns $option_name = 'severity';
523
52411µs11µs my $profile = $self->_profile();
# spent 1µs making 1 call to Perl::Critic::Config::_profile
52511µs11µs $source = $profile->source();
# spent 1µs making 1 call to Perl::Critic::UserProfile::source
52614µs24µs $severity = $profile->options_processor()->severity();
# spent 2µs making 1 call to Perl::Critic::OptionsProcessor::severity # spent 1µs making 1 call to Perl::Critic::UserProfile::options_processor
527 }
528
52917µs37µs if ( is_integer($severity) ) {
# spent 4µs making 1 call to Perl::Critic::Utils::is_integer # spent 2µs making 2 calls to Readonly::Scalar::FETCH, avg 1µs/call
530 if (
531 $severity >= $SEVERITY_LOWEST and $severity <= $SEVERITY_HIGHEST
532 ) {
533 $self->{_severity} = $severity;
534 }
535 else {
536 $errors->add_exception(
537 $self->_new_global_value_exception(
538 option_name => $option_name,
539 option_value => $severity,
540 source => $source,
541 message_suffix =>
542 "is not between $SEVERITY_LOWEST (low) and $SEVERITY_HIGHEST (high).",
543 )
544 );
545 }
546 }
547 elsif ( not any { $_ eq lc $severity } @SEVERITY_NAMES ) {
548 $errors->add_exception(
549 $self->_new_global_value_exception(
550 option_name => $option_name,
551 option_value => $severity,
552 source => $source,
553 message_suffix =>
554 q{is not one of the valid severity names: "}
555 . join (q{", "}, @SEVERITY_NAMES)
556 . q{".},
557 )
558 );
559 }
560 else {
561 $self->{_severity} = severity_to_number($severity);
562 }
563
56413µs return;
565}
566
567#-----------------------------------------------------------------------------
568
569
# spent 32µs (22+10) within Perl::Critic::Config::_validate_and_save_top which was called: # once (22µs+10µs) by Perl::Critic::Config::_init at line 115
sub _validate_and_save_top {
5701800ns my ($self, $args_value, $errors) = @_;
571
5721200ns my $option_name;
57310s my $source;
5741200ns my $top;
575
5761700ns if (defined $args_value and $args_value ne q{}) {
577 $option_name = '-top';
578 $top = $args_value;
579 }
580 else {
5811500ns $option_name = 'top';
582
58311µs11µs my $profile = $self->_profile();
# spent 1µs making 1 call to Perl::Critic::Config::_profile
58411µs11µs $source = $profile->source();
# spent 1µs making 1 call to Perl::Critic::UserProfile::source
58514µs24µs $top = $profile->options_processor()->top();
# spent 2µs making 1 call to Perl::Critic::OptionsProcessor::top # spent 1µs making 1 call to Perl::Critic::UserProfile::options_processor
586 }
587
58812µs14µs if ( is_integer($top) and $top >= 0 ) {
# spent 4µs making 1 call to Perl::Critic::Utils::is_integer
589 $self->{_top} = $top;
590 }
591 else {
592 $errors->add_exception(
593 $self->_new_global_value_exception(
594 option_name => $option_name,
595 option_value => $top,
596 source => $source,
597 message_suffix => q{is not a non-negative integer.},
598 )
599 );
600 }
601
60213µs return;
603}
604
605#-----------------------------------------------------------------------------
606
607
# spent 161µs (66+96) within Perl::Critic::Config::_validate_and_save_theme which was called: # once (66µs+96µs) by Perl::Critic::Config::_init at line 116
sub _validate_and_save_theme {
6081700ns my ($self, $args_value, $errors) = @_;
609
6101200ns my $option_name;
6111100ns my $source;
6121100ns my $theme_rule;
613
6141500ns if ($args_value) {
615 $option_name = '-theme';
616 $theme_rule = $args_value;
617 }
618 else {
6191500ns $option_name = 'theme';
620
62111µs11µs my $profile = $self->_profile();
# spent 1µs making 1 call to Perl::Critic::Config::_profile
62211µs11µs $source = $profile->source();
# spent 1µs making 1 call to Perl::Critic::UserProfile::source
62313µs24µs $theme_rule = $profile->options_processor()->theme();
# spent 2µs making 1 call to Perl::Critic::OptionsProcessor::theme # spent 1µs making 1 call to Perl::Critic::UserProfile::options_processor
624 }
625
626113µs310µs if ( $theme_rule =~ m/$RULE_INVALID_CHARACTER_REGEX/xms ) {
# spent 8µs making 1 call to Perl::Critic::Config::CORE:regcomp # spent 1µs making 1 call to Readonly::Scalar::FETCH # spent 300ns making 1 call to Perl::Critic::Config::CORE:match
627 my $bad_character = $1;
628
629 $errors->add_exception(
630 $self->_new_global_value_exception(
631 option_name => $option_name,
632 option_value => $theme_rule,
633 source => $source,
634 message_suffix =>
635 qq{contains an illegal character ("$bad_character").},
636 )
637 );
638 }
639 else {
64012µs128µs my $rule_as_code = cook_rule($theme_rule);
# spent 28µs making 1 call to Perl::Critic::Theme::cook_rule
64113µs1300ns $rule_as_code =~ s/ [\w\d]+ / 1 /gxms;
# spent 300ns making 1 call to Perl::Critic::Config::CORE:subst
642
643 # eval of an empty string does not reset $@ in Perl 5.6.
64413µs11µs local $EVAL_ERROR = $EMPTY;
# spent 1µs making 1 call to Readonly::Scalar::FETCH
645119µs eval $rule_as_code; ## no critic (ProhibitStringyEval, RequireCheckingReturnValueOfEval)
646
6471700ns if ($EVAL_ERROR) {
648 $errors->add_exception(
649 $self->_new_global_value_exception(
650 option_name => $option_name,
651 option_value => $theme_rule,
652 source => $source,
653 message_suffix => q{is not syntactically valid.},
654 )
655 );
656 }
657 else {
658 eval {
65916µs152µs $self->{_theme} =
# spent 52µs making 1 call to Perl::Critic::Theme::new
660 Perl::Critic::Theme->new( -rule => $theme_rule );
661 }
6621700ns or do {
663 $errors->add_exception_or_rethrow( $EVAL_ERROR );
664 };
665 }
666 }
667
66813µs return;
669}
670
671#-----------------------------------------------------------------------------
672
673
# spent 30µs (24+6) within Perl::Critic::Config::_validate_and_save_pager which was called: # once (24µs+6µs) by Perl::Critic::Config::_init at line 117
sub _validate_and_save_pager {
6741800ns my ($self, $args_value, $errors) = @_;
675
6761200ns my $pager;
67711µs if ( $args_value ) {
678 $pager = defined $args_value ? $args_value : $EMPTY;
679 }
680 elsif ( $ENV{PERLCRITIC_PAGER} ) {
681 $pager = $ENV{PERLCRITIC_PAGER};
682 }
683 else {
68411µs11µs my $profile = $self->_profile();
# spent 1µs making 1 call to Perl::Critic::Config::_profile
68513µs24µs $pager = $profile->options_processor()->pager();
# spent 2µs making 1 call to Perl::Critic::OptionsProcessor::pager # spent 1µs making 1 call to Perl::Critic::UserProfile::options_processor
686 }
687
6881600ns if ($pager eq '$PAGER') { ## no critic (RequireInterpolationOfMetachars)
689 $pager = $ENV{PAGER};
690 }
69112µs11µs $pager ||= $EMPTY;
# spent 1µs making 1 call to Readonly::Scalar::FETCH
692
6931800ns $self->{_pager} = $pager;
694
69513µs return;
696}
697
698#-----------------------------------------------------------------------------
699
700
# spent 6.17ms (5.33+840µs) within Perl::Critic::Config::_validate_and_save_color_severity which was called 5 times, avg 1.23ms/call: # once (5.23ms+731µs) by Perl::Critic::Config::_init at line 92 # once (30µs+36µs) by Perl::Critic::Config::_init at line 96 # once (24µs+25µs) by Perl::Critic::Config::_init at line 100 # once (23µs+24µs) by Perl::Critic::Config::_init at line 104 # once (22µs+24µs) by Perl::Critic::Config::_init at line 108
sub _validate_and_save_color_severity {
70155µs my ($self, $option_name, $args_value, $default_value, $errors) = @_;
702
7035300ns my $source;
7045200ns my $color_severity;
7055200ns my $full_option_name;
706
70751µs if (defined $args_value) {
708 $full_option_name = "-$option_name";
709 $color_severity = lc $args_value;
710 }
711 else {
7125800ns $full_option_name = $option_name;
713512µs1014µs $source = $self->_profile()->source();
# spent 8µs making 5 calls to Perl::Critic::UserProfile::source, avg 2µs/call # spent 6µs making 5 calls to Perl::Critic::Config::_profile, avg 1µs/call
71453µs $color_severity = lc $default_value;
715 }
716512µs54µs $color_severity =~ s/ \s+ / /xmsg;
# spent 4µs making 5 calls to Perl::Critic::Config::CORE:subst, avg 760ns/call
717511µs54µs $color_severity =~ s/ \A\s+ //xms;
# spent 4µs making 5 calls to Perl::Critic::Config::CORE:subst, avg 720ns/call
718510µs53µs $color_severity =~ s/ \s+\z //xms;
# spent 3µs making 5 calls to Perl::Critic::Config::CORE:subst, avg 680ns/call
719517µs59µs $full_option_name =~ s/ _ /-/xmsg;
# spent 9µs making 5 calls to Perl::Critic::Config::CORE:subst, avg 2µs/call
720
721 # Should we really be validating this?
7225500ns my $found_errors;
723515µs1035µs if (
# spent 23µs making 5 calls to Term::ANSIColor::colorvalid, avg 5µs/call # spent 12µs making 5 calls to Perl::Critic::Utils::words_from_string, avg 2µs/call
724 eval {
7255110µs require Term::ANSIColor;
726588µs20119µs Term::ANSIColor->VERSION( $_MODULE_VERSION_TERM_ANSICOLOR );
# spent 101µs making 5 calls to UNIVERSAL::VERSION, avg 20µs/call # spent 18µs making 15 calls to Readonly::Scalar::FETCH, avg 1µs/call
72752µs 1;
728 }
729 ) {
730 $found_errors =
731 not Term::ANSIColor::colorvalid( words_from_string($color_severity) );
732 }
733
734 # If we do not have Term::ANSIColor we can not validate, but we store the
735 # values anyway for the benefit of Perl::Critic::ProfilePrototype.
736
7375800ns if ($found_errors) {
738 $errors->add_exception(
739 $self->_new_global_value_exception(
740 option_name => $full_option_name,
741 option_value => $color_severity,
742 source => $source,
743 message_suffix => 'is not valid.',
744 )
745 );
746 }
747 else {
74851µs my $option_key = $option_name;
749512µs54µs $option_key =~ s/ - /_/xmsg;
# spent 4µs making 5 calls to Perl::Critic::Config::CORE:subst, avg 720ns/call
750
75157µs $self->{"_$option_key"} = $color_severity;
752 }
753
754515µs return;
755}
756
757#-----------------------------------------------------------------------------
758
759
# spent 31µs (24+7) within Perl::Critic::Config::_validate_and_save_program_extensions which was called: # once (24µs+7µs) by Perl::Critic::Config::_init at line 118
sub _validate_and_save_program_extensions {
7601800ns my ($self, $args_value, $errors) = @_;
761
7621900ns delete $self->{_program_extensions_as_regexes};
763
764 my $extension_list = q{ARRAY} eq ref $args_value ?
76515µs34µs [map {words_from_string($_)} @{ $args_value }] :
# spent 2µs making 1 call to Perl::Critic::OptionsProcessor::program_extensions # spent 1µs making 1 call to Perl::Critic::Config::_profile # spent 1µs making 1 call to Perl::Critic::UserProfile::options_processor
766 $self->_profile()->options_processor()->program_extensions();
767
76813µs12µs my %program_extensions = hashify( @{ $extension_list } );
# spent 2µs making 1 call to Perl::Critic::Utils::hashify
769
77012µs $self->{_program_extensions} = [keys %program_extensions];
771
77213µs return;
773
774}
775
776#-----------------------------------------------------------------------------
777# Begin ACCESSSOR methods
778
779
# spent 317µs within Perl::Critic::Config::_profile which was called 297 times, avg 1µs/call: # 141 times (151µs+0s) by Perl::Critic::Config::_policy_is_disabled at line 264, avg 1µs/call # 141 times (148µs+0s) by Perl::Critic::Config::_policy_is_enabled at line 272, avg 1µs/call # 5 times (6µs+0s) by Perl::Critic::Config::_validate_and_save_color_severity at line 713, avg 1µs/call # 3 times (4µs+0s) by Perl::Critic::Config::_validate_and_save_regex at line 384, avg 1µs/call # once (2µs+0s) by Perl::Critic::Config::_validate_and_save_profile_strictness at line 441 # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_top at line 583 # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_program_extensions at line 765 # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_severity at line 524 # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_verbosity at line 482 # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_theme at line 621 # once (1µs+0s) by Perl::Critic::Config::_validate_and_save_pager at line 684
sub _profile {
78029733µs my ($self) = @_;
781297590µs return $self->{_profile};
782}
783
784#-----------------------------------------------------------------------------
785
786sub all_policies_enabled_or_not {
787 my ($self) = @_;
788 return @{ $self->{_all_policies_enabled_or_not} };
789}
790
791#-----------------------------------------------------------------------------
792
793
# spent 1.07ms within Perl::Critic::Config::policies which was called 289 times, avg 4µs/call: # 145 times (430µs+0s) by Perl::Critic::policies at line 68 of Perl/Critic.pm, avg 3µs/call # 144 times (643µs+0s) by Perl::Critic::_gather_violations at line 133 of Perl/Critic.pm, avg 4µs/call
sub policies {
794289106µs my ($self) = @_;
7952891.19ms return @{ $self->{_policies} };
796}
797
798#-----------------------------------------------------------------------------
799
800
# spent 171µs within Perl::Critic::Config::exclude which was called 141 times, avg 1µs/call: # 141 times (171µs+0s) by Perl::Critic::Config::_policy_is_excluded at line 307, avg 1µs/call
sub exclude {
80114123µs my ($self) = @_;
802141274µs return @{ $self->{_exclude} };
803}
804
805#-----------------------------------------------------------------------------
806
807
# spent 342µs within Perl::Critic::Config::force which was called 144 times, avg 2µs/call: # 144 times (342µs+0s) by Perl::Critic::_gather_violations at line 128 of Perl/Critic.pm, avg 2µs/call
sub force {
80814453µs my ($self) = @_;
809144392µs return $self->{_force};
810}
811
812#-----------------------------------------------------------------------------
813
814
# spent 184µs within Perl::Critic::Config::include which was called 141 times, avg 1µs/call: # 141 times (184µs+0s) by Perl::Critic::Config::_policy_is_included at line 298, avg 1µs/call
sub include {
81514120µs my ($self) = @_;
816141287µs return @{ $self->{_include} };
817}
818
819#-----------------------------------------------------------------------------
820
821
# spent 193µs within Perl::Critic::Config::only which was called 141 times, avg 1µs/call: # 141 times (193µs+0s) by Perl::Critic::Config::_load_policies at line 237, avg 1µs/call
sub only {
82214125µs my ($self) = @_;
823141267µs return $self->{_only};
824}
825
826#-----------------------------------------------------------------------------
827
828
# spent 2µs within Perl::Critic::Config::profile_strictness which was called: # once (2µs+0s) by Perl::Critic::Config::_init at line 137
sub profile_strictness {
8291400ns my ($self) = @_;
83013µs return $self->{_profile_strictness};
831}
832
833#-----------------------------------------------------------------------------
834
835sub severity {
836 my ($self) = @_;
837 return $self->{_severity};
838}
839
840#-----------------------------------------------------------------------------
841
842
# spent 211µs within Perl::Critic::Config::single_policy which was called 142 times, avg 1µs/call: # 141 times (210µs+0s) by Perl::Critic::Config::_load_policies at line 226, avg 1µs/call # once (1µs+0s) by Perl::Critic::Config::_load_policies at line 253
sub single_policy {
84314227µs my ($self) = @_;
8441423.82ms return @{ $self->{_single_policy} };
845}
846
847#-----------------------------------------------------------------------------
848
849
# spent 154µs within Perl::Critic::Config::theme which was called 141 times, avg 1µs/call: # 141 times (154µs+0s) by Perl::Critic::Config::_policy_is_thematic at line 280, avg 1µs/call
sub theme {
85014116µs my ($self) = @_;
851141272µs return $self->{_theme};
852}
853
854#-----------------------------------------------------------------------------
855
856sub top {
857 my ($self) = @_;
858 return $self->{_top};
859}
860
861#-----------------------------------------------------------------------------
862
863sub verbose {
864 my ($self) = @_;
865 return $self->{_verbose};
866}
867
868#-----------------------------------------------------------------------------
869
870sub color {
871 my ($self) = @_;
872 return $self->{_color};
873}
874
875#-----------------------------------------------------------------------------
876
877
# spent 3µs within Perl::Critic::Config::pager which was called: # once (3µs+0s) by Perl::Critic::Command::_critique at line 241 of Perl/Critic/Command.pm
sub pager {
8781400ns my ($self) = @_;
87914µs return $self->{_pager};
880}
881
882#-----------------------------------------------------------------------------
883
884sub unsafe_allowed {
885 my ($self) = @_;
886 return $self->{_unsafe_allowed};
887}
888
889#-----------------------------------------------------------------------------
890
891sub criticism_fatal {
892 my ($self) = @_;
893 return $self->{_criticism_fatal};
894}
895
896#-----------------------------------------------------------------------------
897
898sub site_policy_names {
899 return Perl::Critic::PolicyFactory::site_policy_names();
900}
901
902#-----------------------------------------------------------------------------
903
904sub color_severity_highest {
905 my ($self) = @_;
906 return $self->{_color_severity_highest};
907}
908
909#-----------------------------------------------------------------------------
910
911sub color_severity_high {
912 my ($self) = @_;
913 return $self->{_color_severity_high};
914}
915
916#-----------------------------------------------------------------------------
917
918sub color_severity_medium {
919 my ($self) = @_;
920 return $self->{_color_severity_medium};
921}
922
923#-----------------------------------------------------------------------------
924
925sub color_severity_low {
926 my ($self) = @_;
927 return $self->{_color_severity_low};
928}
929
930#-----------------------------------------------------------------------------
931
932sub color_severity_lowest {
933 my ($self) = @_;
934 return $self->{_color_severity_lowest};
935}
936
937#-----------------------------------------------------------------------------
938
939
# spent 3µs within Perl::Critic::Config::program_extensions which was called: # once (3µs+0s) by Perl::Critic::Config::program_extensions_as_regexes at line 952
sub program_extensions {
9401400ns my ($self) = @_;
94114µs return @{ $self->{_program_extensions} };
942}
943
944#-----------------------------------------------------------------------------
945
946
# spent 549µs (530+18) within Perl::Critic::Config::program_extensions_as_regexes which was called 144 times, avg 4µs/call: # 144 times (530µs+18µs) by Perl::Critic::critique at line 104 of Perl/Critic.pm, avg 4µs/call
sub program_extensions_as_regexes {
94714450µs my ($self) = @_;
948
9491442.63ms return @{ $self->{_program_extensions_as_regexes} }
950 if $self->{_program_extensions_as_regexes};
951
95214µs24µs my %program_extensions = hashify( $self->program_extensions() );
# spent 3µs making 1 call to Perl::Critic::Config::program_extensions # spent 2µs making 1 call to Perl::Critic::Utils::hashify
9531800ns $program_extensions{'.PL'} = 1;
954 return @{
95514µs $self->{_program_extensions_as_regexes} = [
956232µs314µs map { qr< @{[quotemeta $_]} \z >smx } sort keys %program_extensions
# spent 11µs making 1 call to Perl::Critic::Config::CORE:regcomp # spent 2µs making 1 call to Perl::Critic::Config::CORE:qr # spent 1µs making 1 call to Perl::Critic::Config::CORE:sort
957 ]
958 };
959}
960
96113µs1;
962
963#-----------------------------------------------------------------------------
964
965__END__
 
# spent 300ns within Perl::Critic::Config::CORE:match which was called: # once (300ns+0s) by Perl::Critic::Config::_validate_and_save_theme at line 626
sub Perl::Critic::Config::CORE:match; # opcode
# spent 2µs within Perl::Critic::Config::CORE:qr which was called: # once (2µs+0s) by Perl::Critic::Config::program_extensions_as_regexes at line 956
sub Perl::Critic::Config::CORE:qr; # opcode
# spent 19µs (18+1) within Perl::Critic::Config::CORE:regcomp which was called 2 times, avg 9µs/call: # once (11µs+0s) by Perl::Critic::Config::program_extensions_as_regexes at line 956 # once (7µs+1µs) by Perl::Critic::Config::_validate_and_save_theme at line 626
sub Perl::Critic::Config::CORE:regcomp; # opcode
# spent 1µs within Perl::Critic::Config::CORE:sort which was called: # once (1µs+0s) by Perl::Critic::Config::program_extensions_as_regexes at line 956
sub Perl::Critic::Config::CORE:sort; # opcode
# spent 27µs within Perl::Critic::Config::CORE:subst which was called 29 times, avg 934ns/call: # 5 times (9µs+0s) by Perl::Critic::Config::_validate_and_save_color_severity at line 719, avg 2µs/call # 5 times (4µs+0s) by Perl::Critic::Config::_validate_and_save_color_severity at line 716, avg 760ns/call # 5 times (4µs+0s) by Perl::Critic::Config::_validate_and_save_color_severity at line 749, avg 720ns/call # 5 times (4µs+0s) by Perl::Critic::Config::_validate_and_save_color_severity at line 717, avg 720ns/call # 5 times (3µs+0s) by Perl::Critic::Config::_validate_and_save_color_severity at line 718, avg 680ns/call # 3 times (3µs+0s) by Perl::Critic::Config::_validate_and_save_regex at line 417, avg 1µs/call # once (300ns+0s) by Perl::Critic::Config::_validate_and_save_theme at line 641
sub Perl::Critic::Config::CORE:subst; # opcode