Benchmark-Perl-Formance-Cargo
view release on metacpan or search on metacpan
share/PerlCritic/Critic/Policy/Documentation/RequirePodSections.pm view on Meta::CPAN
'NAME',
'VERSION',
'USAGE',
'REQUIRED ARGUMENTS',
'OPTIONS',
'DESCRIPTION',
'DIAGNOSTICS',
'CONFIGURATION AND ENVIRONMENT',
'DEPENDENCIES',
'INCOMPATIBILITIES',
'BUGS AND LIMITATIONS',
'AUTHOR',
'LICENSE AND COPYRIGHT',
'DISCLAIMER OF WARRANTY',
],
},
);
#-----------------------------------------------------------------------------
sub supported_parameters {
return (
{
name => 'lib_sections',
description => 'The sections to require for modules (separated by qr/\s* [|] \s*/xms).',
default_string => $EMPTY,
parser => \&_parse_lib_sections,
},
{
name => 'script_sections',
description => 'The sections to require for programs (separated by qr/\s* [|] \s*/xms).',
default_string => $EMPTY,
parser => \&_parse_script_sections,
},
{
name => 'source',
description => 'The origin of sections to use.',
default_string => $DEFAULT_SOURCE,
behavior => 'enumeration',
enumeration_values => [ keys %SOURCE_TRANSLATION ],
},
{
name => 'language',
description => 'The spelling of sections to use.',
default_string => $EMPTY,
behavior => 'enumeration',
enumeration_values => [ $EN_AU, $EN_US ],
},
);
}
sub default_severity { return $SEVERITY_LOW }
sub default_themes { return qw(core pbp maintenance) }
sub applies_to { return 'PPI::Document' }
#-----------------------------------------------------------------------------
sub _parse_sections {
my $config_string = shift;
my @sections = split m{ \s* [|] \s* }xms, $config_string;
return map { uc $_ } @sections; # Normalize CaSe!
}
sub _parse_lib_sections {
my ($self, $parameter, $config_string) = @_;
if ( defined $config_string ) {
$self->{_lib_sections} = [ _parse_sections( $config_string ) ];
}
return;
}
sub _parse_script_sections {
my ($self, $parameter, $config_string) = @_;
if ( defined $config_string ) {
$self->{_script_sections} = [ _parse_sections( $config_string ) ];
}
return;
}
#-----------------------------------------------------------------------------
sub initialize_if_enabled {
my ($self, $config) = @_;
my $source = $self->{_source};
if ( not defined $source or not defined $DEFAULT_LIB_SECTIONS{$source} ) {
$source = $DEFAULT_SOURCE;
}
my $language = $self->{_language};
if (
not defined $language
or not defined $DEFAULT_LIB_SECTIONS{$source}{$language}
) {
$language = $SOURCE_DEFAULT_LANGUAGE{$source};
}
if ( not $self->_sections_specified('_lib_sections') ) {
$self->{_lib_sections} = $DEFAULT_LIB_SECTIONS{$source}{$language};
}
if ( not $self->_sections_specified('_script_sections') ) {
$self->{_script_sections} =
$DEFAULT_SCRIPT_SECTIONS{$source}{$language};
}
return $TRUE;
}
sub _sections_specified {
my ( $self, $sections_key ) = @_;
my $sections = $self->{$sections_key};
return 0 if not defined $sections;
( run in 0.439 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )