| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/Perl/Critic/UserProfile.pm |
| Statements | Executed 2649 statements in 4.41ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 141 | 1 | 1 | 1.09ms | 8.91ms | Perl::Critic::UserProfile::policy_params |
| 1 | 1 | 1 | 1.05ms | 5.38ms | Perl::Critic::UserProfile::BEGIN@20 |
| 141 | 1 | 1 | 1.03ms | 3.98ms | Perl::Critic::UserProfile::raw_policy_params |
| 141 | 1 | 1 | 742µs | 2.56ms | Perl::Critic::UserProfile::policy_is_disabled |
| 1 | 1 | 1 | 728µs | 761µs | Perl::Critic::UserProfile::BEGIN@17 |
| 141 | 1 | 1 | 649µs | 2.30ms | Perl::Critic::UserProfile::policy_is_enabled |
| 1 | 1 | 1 | 29µs | 187µs | Perl::Critic::UserProfile::_load_profile_from_file |
| 13 | 7 | 1 | 20µs | 20µs | Perl::Critic::UserProfile::source |
| 1 | 1 | 1 | 16µs | 625µs | Perl::Critic::UserProfile::_init |
| 1 | 1 | 1 | 16µs | 205µs | Perl::Critic::UserProfile::_load_profile |
| 1 | 1 | 1 | 15µs | 15µs | Perl::Critic::UserProfile::BEGIN@10 |
| 1 | 1 | 1 | 14µs | 400µs | Perl::Critic::UserProfile::_set_options_processor |
| 8 | 8 | 1 | 11µs | 11µs | Perl::Critic::UserProfile::options_processor |
| 1 | 1 | 1 | 11µs | 45µs | Perl::Critic::UserProfile::BEGIN@23 |
| 1 | 1 | 1 | 11µs | 11µs | Perl::Critic::UserProfile::listed_policies |
| 1 | 1 | 1 | 10µs | 15µs | Perl::Critic::UserProfile::BEGIN@12 |
| 1 | 1 | 1 | 10µs | 635µs | Perl::Critic::UserProfile::new |
| 1 | 1 | 1 | 9µs | 30µs | Perl::Critic::UserProfile::BEGIN@22 |
| 1 | 1 | 1 | 8µs | 274µs | Perl::Critic::UserProfile::BEGIN@21 |
| 1 | 1 | 1 | 8µs | 26µs | Perl::Critic::UserProfile::BEGIN@15 |
| 1 | 1 | 1 | 7µs | 394µs | Perl::Critic::UserProfile::BEGIN@14 |
| 1 | 1 | 1 | 6µs | 6µs | Perl::Critic::UserProfile::BEGIN@24 |
| 1 | 1 | 1 | 6µs | 6µs | Perl::Critic::UserProfile::_fix_defaults_key |
| 1 | 1 | 1 | 6µs | 17µs | Perl::Critic::UserProfile::BEGIN@11 |
| 1 | 1 | 1 | 6µs | 6µs | Perl::Critic::UserProfile::_set_source |
| 1 | 1 | 1 | 5µs | 5µs | Perl::Critic::UserProfile::BEGIN@18 |
| 1 | 1 | 1 | 4µs | 4µs | Perl::Critic::UserProfile::_find_profile_path |
| 1 | 1 | 1 | 400ns | 400ns | Perl::Critic::UserProfile::CORE:sort (opcode) |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::UserProfile::_find_home_dir |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::UserProfile::_load_profile_from_array |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::UserProfile::_load_profile_from_hash |
| 0 | 0 | 0 | 0s | 0s | Perl::Critic::UserProfile::_load_profile_from_string |
| 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::UserProfile; | ||||
| 9 | |||||
| 10 | 2 | 38µs | 1 | 15µs | # spent 15µs within Perl::Critic::UserProfile::BEGIN@10 which was called:
# once (15µs+0s) by Perl::Critic::Config::BEGIN@26 at line 10 # spent 15µs making 1 call to Perl::Critic::UserProfile::BEGIN@10 |
| 11 | 2 | 19µs | 2 | 28µs | # spent 17µs (6+11) within Perl::Critic::UserProfile::BEGIN@11 which was called:
# once (6µs+11µs) by Perl::Critic::Config::BEGIN@26 at line 11 # spent 17µs making 1 call to Perl::Critic::UserProfile::BEGIN@11
# spent 11µs making 1 call to strict::import |
| 12 | 2 | 21µs | 2 | 20µs | # spent 15µs (10+5) within Perl::Critic::UserProfile::BEGIN@12 which was called:
# once (10µs+5µs) by Perl::Critic::Config::BEGIN@26 at line 12 # spent 15µs making 1 call to Perl::Critic::UserProfile::BEGIN@12
# spent 5µs making 1 call to warnings::import |
| 13 | |||||
| 14 | 2 | 26µs | 2 | 780µs | # spent 394µs (7+387) within Perl::Critic::UserProfile::BEGIN@14 which was called:
# once (7µs+387µs) by Perl::Critic::Config::BEGIN@26 at line 14 # spent 394µs making 1 call to Perl::Critic::UserProfile::BEGIN@14
# spent 387µs making 1 call to English::import |
| 15 | 2 | 20µs | 2 | 44µs | # spent 26µs (8+18) within Perl::Critic::UserProfile::BEGIN@15 which was called:
# once (8µs+18µs) by Perl::Critic::Config::BEGIN@26 at line 15 # spent 26µs making 1 call to Perl::Critic::UserProfile::BEGIN@15
# spent 18µs making 1 call to Exporter::import |
| 16 | |||||
| 17 | 2 | 89µs | 1 | 761µs | # spent 761µs (728+33) within Perl::Critic::UserProfile::BEGIN@17 which was called:
# once (728µs+33µs) by Perl::Critic::Config::BEGIN@26 at line 17 # spent 761µs making 1 call to Perl::Critic::UserProfile::BEGIN@17 |
| 18 | 2 | 20µs | 1 | 5µs | # spent 5µs within Perl::Critic::UserProfile::BEGIN@18 which was called:
# once (5µs+0s) by Perl::Critic::Config::BEGIN@26 at line 18 # spent 5µs making 1 call to Perl::Critic::UserProfile::BEGIN@18 |
| 19 | |||||
| 20 | 2 | 93µs | 1 | 5.38ms | # spent 5.38ms (1.05+4.33) within Perl::Critic::UserProfile::BEGIN@20 which was called:
# once (1.05ms+4.33ms) by Perl::Critic::Config::BEGIN@26 at line 20 # spent 5.38ms making 1 call to Perl::Critic::UserProfile::BEGIN@20 |
| 21 | 2 | 25µs | 2 | 541µs | # spent 274µs (8+266) within Perl::Critic::UserProfile::BEGIN@21 which was called:
# once (8µs+266µs) by Perl::Critic::Config::BEGIN@26 at line 21 # spent 274µs making 1 call to Perl::Critic::UserProfile::BEGIN@21
# spent 266µs making 1 call to Exporter::import |
| 22 | 2 | 24µs | 2 | 51µs | # spent 30µs (9+21) within Perl::Critic::UserProfile::BEGIN@22 which was called:
# once (9µs+21µs) by Perl::Critic::Config::BEGIN@26 at line 22 # spent 30µs making 1 call to Perl::Critic::UserProfile::BEGIN@22
# spent 21µs making 1 call to Exporter::import |
| 23 | 2 | 25µs | 2 | 80µs | # spent 45µs (11+34) within Perl::Critic::UserProfile::BEGIN@23 which was called:
# once (11µs+34µs) by Perl::Critic::Config::BEGIN@26 at line 23 # spent 45µs making 1 call to Perl::Critic::UserProfile::BEGIN@23
# spent 34µs making 1 call to Exporter::import |
| 24 | 2 | 913µs | 1 | 6µs | # spent 6µs within Perl::Critic::UserProfile::BEGIN@24 which was called:
# once (6µs+0s) by Perl::Critic::Config::BEGIN@26 at line 24 # spent 6µs making 1 call to Perl::Critic::UserProfile::BEGIN@24 |
| 25 | |||||
| 26 | 1 | 600ns | our $VERSION = '1.121'; | ||
| 27 | |||||
| 28 | #----------------------------------------------------------------------------- | ||||
| 29 | |||||
| 30 | # spent 635µs (10+625) within Perl::Critic::UserProfile::new which was called:
# once (10µs+625µs) by Perl::Critic::Config::_init at line 70 of Perl/Critic/Config.pm | ||||
| 31 | |||||
| 32 | 1 | 1µs | my ( $class, %args ) = @_; | ||
| 33 | 1 | 1µs | my $self = bless {}, $class; | ||
| 34 | 1 | 3µs | 1 | 625µs | $self->_init( %args ); # spent 625µs making 1 call to Perl::Critic::UserProfile::_init |
| 35 | 1 | 6µs | return $self; | ||
| 36 | } | ||||
| 37 | |||||
| 38 | #----------------------------------------------------------------------------- | ||||
| 39 | |||||
| 40 | # spent 625µs (16+609) within Perl::Critic::UserProfile::_init which was called:
# once (16µs+609µs) by Perl::Critic::UserProfile::new at line 34 | ||||
| 41 | |||||
| 42 | 1 | 800ns | my ( $self, %args ) = @_; | ||
| 43 | # The profile can be defined, undefined, or an empty string. | ||||
| 44 | 1 | 3µs | 1 | 4µs | my $profile = defined $args{-profile} ? $args{-profile} : _find_profile_path(); # spent 4µs making 1 call to Perl::Critic::UserProfile::_find_profile_path |
| 45 | 1 | 3µs | 1 | 205µs | $self->_load_profile( $profile ); # spent 205µs making 1 call to Perl::Critic::UserProfile::_load_profile |
| 46 | 1 | 2µs | 1 | 400µs | $self->_set_options_processor(); # spent 400µs making 1 call to Perl::Critic::UserProfile::_set_options_processor |
| 47 | 1 | 4µs | return $self; | ||
| 48 | } | ||||
| 49 | |||||
| 50 | #----------------------------------------------------------------------------- | ||||
| 51 | |||||
| 52 | # spent 11µs within Perl::Critic::UserProfile::options_processor which was called 8 times, avg 1µs/call:
# once (2µs+0s) by Perl::Critic::Config::_init at line 71 of Perl/Critic/Config.pm
# once (2µs+0s) by Perl::Critic::Config::_validate_and_save_verbosity at line 484 of Perl/Critic/Config.pm
# once (1µs+0s) by Perl::Critic::Config::_validate_and_save_profile_strictness at line 443 of Perl/Critic/Config.pm
# once (1µs+0s) by Perl::Critic::Config::_validate_and_save_pager at line 685 of Perl/Critic/Config.pm
# once (1µs+0s) by Perl::Critic::Config::_validate_and_save_theme at line 623 of Perl/Critic/Config.pm
# once (1µs+0s) by Perl::Critic::Config::_validate_and_save_program_extensions at line 765 of Perl/Critic/Config.pm
# once (1µs+0s) by Perl::Critic::Config::_validate_and_save_severity at line 526 of Perl/Critic/Config.pm
# once (1µs+0s) by Perl::Critic::Config::_validate_and_save_top at line 585 of Perl/Critic/Config.pm | ||||
| 53 | |||||
| 54 | 8 | 1µs | my ($self) = @_; | ||
| 55 | 8 | 24µs | return $self->{_options_processor}; | ||
| 56 | } | ||||
| 57 | |||||
| 58 | #----------------------------------------------------------------------------- | ||||
| 59 | |||||
| 60 | # spent 8.91ms (1.09+7.83) within Perl::Critic::UserProfile::policy_params which was called 141 times, avg 63µs/call:
# 141 times (1.09ms+7.83ms) by Perl::Critic::PolicyFactory::create_policy at line 198 of Perl/Critic/PolicyFactory.pm, avg 63µs/call | ||||
| 61 | |||||
| 62 | 141 | 30µs | my ( $self, $policy ) = @_; | ||
| 63 | |||||
| 64 | 141 | 137µs | 141 | 1.48ms | my $short_name = policy_short_name($policy); # spent 1.48ms making 141 calls to Perl::Critic::Utils::policy_short_name, avg 10µs/call |
| 65 | |||||
| 66 | 141 | 609µs | 282 | 6.35ms | return Perl::Critic::PolicyConfig->new( # spent 3.98ms making 141 calls to Perl::Critic::UserProfile::raw_policy_params, avg 28µs/call
# spent 2.37ms making 141 calls to Perl::Critic::PolicyConfig::new, avg 17µs/call |
| 67 | $short_name, | ||||
| 68 | $self->raw_policy_params($policy), | ||||
| 69 | ); | ||||
| 70 | } | ||||
| 71 | |||||
| 72 | #----------------------------------------------------------------------------- | ||||
| 73 | |||||
| 74 | # spent 3.98ms (1.03+2.95) within Perl::Critic::UserProfile::raw_policy_params which was called 141 times, avg 28µs/call:
# 141 times (1.03ms+2.95ms) by Perl::Critic::UserProfile::policy_params at line 66, avg 28µs/call | ||||
| 75 | |||||
| 76 | 141 | 33µs | my ( $self, $policy ) = @_; | ||
| 77 | 141 | 44µs | my $profile = $self->{_profile}; | ||
| 78 | 141 | 153µs | 141 | 1.44ms | my $long_name = ref $policy || policy_long_name( $policy ); # spent 1.44ms making 141 calls to Perl::Critic::Utils::policy_long_name, avg 10µs/call |
| 79 | 141 | 164µs | 141 | 1.51ms | my $short_name = policy_short_name( $long_name ); # spent 1.51ms making 141 calls to Perl::Critic::Utils::policy_short_name, avg 11µs/call |
| 80 | |||||
| 81 | return | ||||
| 82 | 141 | 467µs | $profile->{$short_name} | ||
| 83 | || $profile->{$long_name} | ||||
| 84 | || $profile->{"-$short_name"} | ||||
| 85 | || $profile->{"-$long_name"} | ||||
| 86 | || {}; | ||||
| 87 | } | ||||
| 88 | |||||
| 89 | #----------------------------------------------------------------------------- | ||||
| 90 | |||||
| 91 | # spent 2.56ms (742µs+1.82) within Perl::Critic::UserProfile::policy_is_disabled which was called 141 times, avg 18µs/call:
# 141 times (742µs+1.82ms) by Perl::Critic::Config::_policy_is_disabled at line 265 of Perl/Critic/Config.pm, avg 18µs/call | ||||
| 92 | |||||
| 93 | 141 | 36µs | my ( $self, $policy ) = @_; | ||
| 94 | 141 | 32µs | my $profile = $self->{_profile}; | ||
| 95 | 141 | 49µs | my $long_name = ref $policy || policy_long_name( $policy ); | ||
| 96 | 141 | 164µs | 141 | 1.82ms | my $short_name = policy_short_name( $long_name ); # spent 1.82ms making 141 calls to Perl::Critic::Utils::policy_short_name, avg 13µs/call |
| 97 | |||||
| 98 | 141 | 419µs | return exists $profile->{"-$short_name"} | ||
| 99 | || exists $profile->{"-$long_name"}; | ||||
| 100 | } | ||||
| 101 | |||||
| 102 | #----------------------------------------------------------------------------- | ||||
| 103 | |||||
| 104 | # spent 2.30ms (649µs+1.65) within Perl::Critic::UserProfile::policy_is_enabled which was called 141 times, avg 16µs/call:
# 141 times (649µs+1.65ms) by Perl::Critic::Config::_policy_is_enabled at line 273 of Perl/Critic/Config.pm, avg 16µs/call | ||||
| 105 | |||||
| 106 | 141 | 24µs | my ( $self, $policy ) = @_; | ||
| 107 | 141 | 32µs | my $profile = $self->{_profile}; | ||
| 108 | 141 | 43µs | my $long_name = ref $policy || policy_long_name( $policy ); | ||
| 109 | 141 | 148µs | 141 | 1.65ms | my $short_name = policy_short_name( $long_name ); # spent 1.65ms making 141 calls to Perl::Critic::Utils::policy_short_name, avg 12µs/call |
| 110 | |||||
| 111 | 141 | 343µs | return exists $profile->{$short_name} | ||
| 112 | || exists $profile->{$long_name}; | ||||
| 113 | } | ||||
| 114 | |||||
| 115 | #----------------------------------------------------------------------------- | ||||
| 116 | |||||
| 117 | # spent 11µs (11+400ns) within Perl::Critic::UserProfile::listed_policies which was called:
# once (11µs+400ns) by Perl::Critic::PolicyFactory::_validate_policies_in_profile at line 307 of Perl/Critic/PolicyFactory.pm | ||||
| 118 | |||||
| 119 | 1 | 500ns | my ( $self, $policy ) = @_; | ||
| 120 | 1 | 400ns | my @normalized_policy_names = (); | ||
| 121 | |||||
| 122 | 1 | 8µs | 1 | 400ns | for my $policy_name ( sort keys %{$self->{_profile}} ) { # spent 400ns making 1 call to Perl::Critic::UserProfile::CORE:sort |
| 123 | $policy_name =~ s/\A - //xmso; #Chomp leading "-" | ||||
| 124 | my $policy_long_name = policy_long_name( $policy_name ); | ||||
| 125 | push @normalized_policy_names, $policy_long_name; | ||||
| 126 | } | ||||
| 127 | |||||
| 128 | 1 | 4µs | return @normalized_policy_names; | ||
| 129 | } | ||||
| 130 | |||||
| 131 | #----------------------------------------------------------------------------- | ||||
| 132 | |||||
| 133 | # spent 20µs within Perl::Critic::UserProfile::source which was called 13 times, avg 2µs/call:
# 5 times (8µs+0s) by Perl::Critic::Config::_validate_and_save_color_severity at line 713 of Perl/Critic/Config.pm, avg 2µs/call
# 3 times (4µs+0s) by Perl::Critic::Config::_validate_and_save_regex at line 384 of Perl/Critic/Config.pm, avg 1µs/call
# once (2µs+0s) by Perl::Critic::Config::_validate_and_save_profile_strictness at line 442 of Perl/Critic/Config.pm
# once (1µs+0s) by Perl::Critic::Config::_validate_and_save_theme at line 622 of Perl/Critic/Config.pm
# once (1µs+0s) by Perl::Critic::Config::_validate_and_save_severity at line 525 of Perl/Critic/Config.pm
# once (1µs+0s) by Perl::Critic::Config::_validate_and_save_verbosity at line 483 of Perl/Critic/Config.pm
# once (1µs+0s) by Perl::Critic::Config::_validate_and_save_top at line 584 of Perl/Critic/Config.pm | ||||
| 134 | 13 | 2µs | my ( $self ) = @_; | ||
| 135 | |||||
| 136 | 13 | 34µs | return $self->{_source}; | ||
| 137 | } | ||||
| 138 | |||||
| 139 | # spent 6µs within Perl::Critic::UserProfile::_set_source which was called:
# once (6µs+0s) by Perl::Critic::UserProfile::_load_profile_from_file at line 194 | ||||
| 140 | 1 | 600ns | my ( $self, $source ) = @_; | ||
| 141 | |||||
| 142 | 1 | 4µs | $self->{_source} = $source; | ||
| 143 | |||||
| 144 | 1 | 3µs | return; | ||
| 145 | } | ||||
| 146 | |||||
| 147 | #----------------------------------------------------------------------------- | ||||
| 148 | # Begin PRIVATE methods | ||||
| 149 | |||||
| 150 | 1 | 3µs | 1 | 40µs | Readonly::Hash my %LOADER_FOR => ( # spent 40µs making 1 call to Readonly::Hash |
| 151 | ARRAY => \&_load_profile_from_array, | ||||
| 152 | DEFAULT => \&_load_profile_from_file, | ||||
| 153 | HASH => \&_load_profile_from_hash, | ||||
| 154 | SCALAR => \&_load_profile_from_string, | ||||
| 155 | ); | ||||
| 156 | |||||
| 157 | # spent 205µs (16+189) within Perl::Critic::UserProfile::_load_profile which was called:
# once (16µs+189µs) by Perl::Critic::UserProfile::_init at line 45 | ||||
| 158 | |||||
| 159 | 1 | 600ns | my ( $self, $profile ) = @_; | ||
| 160 | |||||
| 161 | 1 | 600ns | my $ref_type = ref $profile || 'DEFAULT'; | ||
| 162 | 1 | 5µs | 1 | 2µs | my $loader = $LOADER_FOR{$ref_type}; # spent 2µs making 1 call to Readonly::Hash::FETCH |
| 163 | |||||
| 164 | 1 | 400ns | if (not $loader) { | ||
| 165 | throw_internal qq{Can't load UserProfile from type "$ref_type"}; | ||||
| 166 | } | ||||
| 167 | |||||
| 168 | 1 | 3µs | 1 | 187µs | $self->{_profile} = $loader->($self, $profile); # spent 187µs making 1 call to Perl::Critic::UserProfile::_load_profile_from_file |
| 169 | 1 | 3µs | return $self; | ||
| 170 | } | ||||
| 171 | |||||
| 172 | #----------------------------------------------------------------------------- | ||||
| 173 | |||||
| 174 | # spent 400µs (14+386) within Perl::Critic::UserProfile::_set_options_processor which was called:
# once (14µs+386µs) by Perl::Critic::UserProfile::_init at line 46 | ||||
| 175 | |||||
| 176 | 1 | 400ns | my ($self) = @_; | ||
| 177 | 1 | 500ns | my $profile = $self->{_profile}; | ||
| 178 | 1 | 900ns | my $defaults = delete $profile->{__defaults__} || {}; | ||
| 179 | $self->{_options_processor} = | ||||
| 180 | 1 | 5µs | 1 | 386µs | Perl::Critic::OptionsProcessor->new( %{ $defaults } ); # spent 386µs making 1 call to Perl::Critic::OptionsProcessor::new |
| 181 | 1 | 4µs | return $self; | ||
| 182 | } | ||||
| 183 | |||||
| 184 | #----------------------------------------------------------------------------- | ||||
| 185 | |||||
| 186 | # spent 187µs (29+159) within Perl::Critic::UserProfile::_load_profile_from_file which was called:
# once (29µs+159µs) by Perl::Critic::UserProfile::_load_profile at line 168 | ||||
| 187 | 1 | 800ns | my ( $self, $file ) = @_; | ||
| 188 | |||||
| 189 | # Handle special cases. | ||||
| 190 | 1 | 300ns | return {} if not defined $file; | ||
| 191 | 1 | 4µs | 1 | 2µs | return {} if $file eq $EMPTY; # spent 2µs making 1 call to Readonly::Scalar::FETCH |
| 192 | 1 | 400ns | return {} if $file eq 'NONE'; | ||
| 193 | |||||
| 194 | 1 | 2µs | 1 | 6µs | $self->_set_source( $file ); # spent 6µs making 1 call to Perl::Critic::UserProfile::_set_source |
| 195 | |||||
| 196 | 1 | 4µs | 1 | 144µs | my $profile = Config::Tiny->read( $file ); # spent 144µs making 1 call to Config::Tiny::read |
| 197 | 1 | 300ns | if (not defined $profile) { | ||
| 198 | my $errstr = Config::Tiny::errstr(); | ||||
| 199 | throw_generic | ||||
| 200 | message => qq{Could not parse profile "$file": $errstr}, | ||||
| 201 | source => $file; | ||||
| 202 | } | ||||
| 203 | |||||
| 204 | 1 | 2µs | 1 | 6µs | _fix_defaults_key( $profile ); # spent 6µs making 1 call to Perl::Critic::UserProfile::_fix_defaults_key |
| 205 | |||||
| 206 | 1 | 4µs | return $profile; | ||
| 207 | } | ||||
| 208 | |||||
| 209 | #----------------------------------------------------------------------------- | ||||
| 210 | |||||
| 211 | sub _load_profile_from_array { | ||||
| 212 | my ( $self, $array_ref ) = @_; | ||||
| 213 | my $joined = join qq{\n}, @{ $array_ref }; | ||||
| 214 | my $profile = Config::Tiny->read_string( $joined ); | ||||
| 215 | |||||
| 216 | if (not defined $profile) { | ||||
| 217 | throw_generic 'Profile error: ' . Config::Tiny::errstr(); | ||||
| 218 | } | ||||
| 219 | |||||
| 220 | _fix_defaults_key( $profile ); | ||||
| 221 | |||||
| 222 | return $profile; | ||||
| 223 | } | ||||
| 224 | |||||
| 225 | #----------------------------------------------------------------------------- | ||||
| 226 | |||||
| 227 | sub _load_profile_from_string { | ||||
| 228 | my ( $self, $string ) = @_; | ||||
| 229 | my $profile = Config::Tiny->read_string( ${ $string } ); | ||||
| 230 | |||||
| 231 | if (not defined $profile) { | ||||
| 232 | throw_generic 'Profile error: ' . Config::Tiny::errstr(); | ||||
| 233 | } | ||||
| 234 | |||||
| 235 | _fix_defaults_key( $profile ); | ||||
| 236 | |||||
| 237 | return $profile; | ||||
| 238 | } | ||||
| 239 | |||||
| 240 | #----------------------------------------------------------------------------- | ||||
| 241 | |||||
| 242 | sub _load_profile_from_hash { | ||||
| 243 | my ( $self, $hash_ref ) = @_; | ||||
| 244 | return $hash_ref; | ||||
| 245 | } | ||||
| 246 | |||||
| 247 | #----------------------------------------------------------------------------- | ||||
| 248 | |||||
| 249 | # spent 4µs within Perl::Critic::UserProfile::_find_profile_path which was called:
# once (4µs+0s) by Perl::Critic::UserProfile::_init at line 44 | ||||
| 250 | |||||
| 251 | #Define default filename | ||||
| 252 | 1 | 500ns | my $rc_file = '.perlcriticrc'; | ||
| 253 | |||||
| 254 | #Check explicit environment setting | ||||
| 255 | 1 | 5µs | return $ENV{PERLCRITIC} if exists $ENV{PERLCRITIC}; | ||
| 256 | |||||
| 257 | #Check current directory | ||||
| 258 | return $rc_file if -f $rc_file; | ||||
| 259 | |||||
| 260 | #Check home directory | ||||
| 261 | if ( my $home_dir = _find_home_dir() ) { | ||||
| 262 | my $path = File::Spec->catfile( $home_dir, $rc_file ); | ||||
| 263 | return $path if -f $path; | ||||
| 264 | } | ||||
| 265 | |||||
| 266 | #No profile defined | ||||
| 267 | return; | ||||
| 268 | } | ||||
| 269 | |||||
| 270 | #----------------------------------------------------------------------------- | ||||
| 271 | |||||
| 272 | sub _find_home_dir { | ||||
| 273 | |||||
| 274 | # Try using File::HomeDir | ||||
| 275 | if ( eval { require File::HomeDir } ) { | ||||
| 276 | return File::HomeDir->my_home(); | ||||
| 277 | } | ||||
| 278 | |||||
| 279 | # Check usual environment vars | ||||
| 280 | for my $key (qw(HOME USERPROFILE HOMESHARE)) { | ||||
| 281 | next if not defined $ENV{$key}; | ||||
| 282 | return $ENV{$key} if -d $ENV{$key}; | ||||
| 283 | } | ||||
| 284 | |||||
| 285 | # No home directory defined | ||||
| 286 | return; | ||||
| 287 | } | ||||
| 288 | |||||
| 289 | #----------------------------------------------------------------------------- | ||||
| 290 | |||||
| 291 | # !$%@$%^ Config::Tiny uses a completely non-descriptive name for global | ||||
| 292 | # values. | ||||
| 293 | # spent 6µs within Perl::Critic::UserProfile::_fix_defaults_key which was called:
# once (6µs+0s) by Perl::Critic::UserProfile::_load_profile_from_file at line 204 | ||||
| 294 | 1 | 500ns | my ( $profile ) = @_; | ||
| 295 | |||||
| 296 | 1 | 3µs | my $defaults = delete $profile->{_}; | ||
| 297 | 1 | 300ns | if ($defaults) { | ||
| 298 | $profile->{__defaults__} = $defaults; | ||||
| 299 | } | ||||
| 300 | |||||
| 301 | 1 | 7µs | return; | ||
| 302 | } | ||||
| 303 | |||||
| 304 | 1 | 4µs | 1; | ||
| 305 | |||||
| 306 | __END__ | ||||
# spent 400ns within Perl::Critic::UserProfile::CORE:sort which was called:
# once (400ns+0s) by Perl::Critic::UserProfile::listed_policies at line 122 |