« lib/Perl/Critic/Policy/ValuesAndExpressions/ProhibitImplicitNewlines.pm
↑ Summary
lib/Perl/Critic/Policy/ClassHierarchies/ProhibitAutoloading.pm »
| 1 | package Perl::Critic::Policy::Modules::ProhibitExcessMainComplexity; | ||||||||||
| 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 | 40 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 40 | ▶ | use Perl::Critic::Utils qw{ :severities }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 40 | ▶ | use Perl::Critic::Utils::McCabe qw{ calculate_mccabe_of_main }; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 40 | ▶ | use parent 'Perl::Critic::Policy'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | #----------------------------------------------------------------------------- | ||||||||||
| 14 | |||||||||||
| 15 | 40 | our $VERSION = '1.156'; | |||||||||
| 16 | |||||||||||
| 17 | #----------------------------------------------------------------------------- | ||||||||||
| 18 | |||||||||||
| 19 | 40 | Readonly::Scalar my $EXPL => q{Consider refactoring}; | |||||||||
| 20 | |||||||||||
| 21 | #----------------------------------------------------------------------------- | ||||||||||
| 22 | |||||||||||
| 23 | 91 | ▶ | sub supported_parameters { | ||||||||
|
Subroutine
supported_parameters: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 24 | return ( | ||||||||||
| 25 | { | ||||||||||
| 26 | 91 | name => 'max_mccabe', | |||||||||
| 27 | description => 'The maximum complexity score allowed.', | ||||||||||
| 28 | default_string => '20', | ||||||||||
| 29 | behavior => 'integer', | ||||||||||
| 30 | integer_minimum => 1, | ||||||||||
| 31 | }, | ||||||||||
| 32 | ); | ||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 74 | ▶ | sub default_severity { return $SEVERITY_MEDIUM } | ||||||||
|
Subroutine
default_severity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 36 | 73 | ▶ | sub default_themes { return qw(core complexity maintenance) } | ||||||||
|
Subroutine
default_themes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 37 | 31 | ▶ | sub applies_to { return 'PPI::Document' } | ||||||||
|
Subroutine
applies_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 38 | |||||||||||
| 39 | #----------------------------------------------------------------------------- | ||||||||||
| 40 | |||||||||||
| 41 | 31 | ▶ | sub violates { | ||||||||
|
Subroutine
violates: called CC=2 SCAR=8.4
Pod
documented
| |||||||||||
| 42 | 31 | my ( $self, $doc, undef ) = @_; | |||||||||
| 43 | |||||||||||
| 44 | 31 | my $score = calculate_mccabe_of_main( $doc ); | |||||||||
| 45 | |||||||||||
| 46 | # Is it too complex? | ||||||||||
| 47 | 31 | ▶ | return if $score <= $self->{_max_mccabe}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | |||||||||||
| 49 | 0 | my $desc = qq{Main code has high complexity score ($score)}; | |||||||||
| 50 | 0 | return $self->violation( $desc, $EXPL, $doc ); | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | |||||||||||
| 54 | 40 | 1; | |||||||||
| 55 | |||||||||||
| 56 | __END__ | ||||||||||