« lib/Perl/Critic/Policy/Miscellanea/ProhibitUnrestrictedNoCritic.pm
↑ Summary
lib/Perl/Critic/Policy/Variables/ProhibitAugmentedAssignmentInDeclaration.pm »
| 1 | package Perl::Critic::PolicyParameter::Behavior::StringList; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 40 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 40 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 40 | ▶ | use Perl::Critic::Utils qw( :characters words_from_string hashify ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 40 | ▶ | use parent qw{ Perl::Critic::PolicyParameter::Behavior }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 40 | our $VERSION = '1.156'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 3576 | ▶ | sub initialize_parameter { | ||||||||||||||||||||||||||
|
Subroutine
initialize_parameter: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 3576 | my (undef, $parameter, $specification) = @_; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # Unfortunately, this has to be kept as a reference, rather than a regular | ||||||||||||||||||||||||||||
| 19 | # array, due to a problem in Devel::Cycle | ||||||||||||||||||||||||||||
| 20 | # (http://rt.cpan.org/Ticket/Display.html?id=25360) which causes | ||||||||||||||||||||||||||||
| 21 | # t/92_memory_leaks.t to fall over. | ||||||||||||||||||||||||||||
| 22 | 3576 | my $always_present_values = $specification->{list_always_present_values}; | |||||||||||||||||||||||||||
| 23 | $parameter->_get_behavior_values()->{always_present_values} = | ||||||||||||||||||||||||||||
| 24 | 3576 | $always_present_values; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 3576 | ▶ | if ( not $always_present_values ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 2484 | $always_present_values = []; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | $parameter->_set_parser( | ||||||||||||||||||||||||||||
| 31 | 3544 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 32 | # Normally bad thing, obscuring a variable in an outer scope | ||||||||||||||||||||||||||||
| 33 | # with a variable with the same name is being done here in | ||||||||||||||||||||||||||||
| 34 | # order to remain consistent with the parser function interface. | ||||||||||||||||||||||||||||
| 35 | 3544 | my ($policy, $parameter, $config_string) = @_; ## no critic(Variables::ProhibitReusedNames) | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 3544 | my @values = @{$always_present_values}; | |||||||||||||||||||||||||||
| 38 | 3544 | ▶ | my $value_string = $config_string // $parameter->get_default_string(); | ||||||||||||||||||||||||||
|
Condition100%3/3
$config_string // $parameter->get_default_string
MC/DC100%2/2
$config_string // $parameter->get_default_string
$config_string
$parameter->get_default_string
Truth table100%3/3
A // B
A= $config_stringB= $parameter->get_default_string
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 3544 | ▶ | if ( defined $value_string ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 3096 | push @values, words_from_string($value_string); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 3544 | my %values = hashify(@values); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 3544 | $policy->__set_parameter_value($parameter, \%values); | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 3544 | return; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | 3576 | ); | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 3576 | return; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 189 | ▶ | sub generate_parameter_description { | ||||||||||||||||||||||||||
|
Subroutine
generate_parameter_description: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 189 | my (undef, $parameter) = @_; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | my $always_present_values = | ||||||||||||||||||||||||||||
| 61 | 189 | $parameter->_get_behavior_values()->{always_present_values}; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 189 | my $description = $parameter->_get_description_with_trailing_period(); | |||||||||||||||||||||||||||
| 64 | 189 | ▶ | if ( $description and $always_present_values ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$description and $always_present_values
MC/DC50%1/2
$description and $always_present_values
$description
$always_present_values
Truth table66%2/3
A and B
A= $descriptionB= $always_present_values
| |||||||||||||||||||||||||||||
| 65 | 60 | $description .= qq{\n}; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 189 | ▶ | if ( $always_present_values ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 60 | $description .= 'Values that are always included: '; | |||||||||||||||||||||||||||
| 70 | 60 | $description .= join ', ', sort @{ $always_present_values }; | |||||||||||||||||||||||||||
| 71 | 60 | $description .= $PERIOD; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 189 | return $description; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 40 | 1; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | __END__ | ||||||||||||||||||||||||||||