line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::CognitiveComplexity; |
2
|
1
|
|
|
1
|
|
405
|
use 5.010; |
|
1
|
|
|
|
|
2
|
|
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.5'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
1; |
10
|
|
|
|
|
|
|
__END__ |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=encoding utf-8 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Perl::Critic::CognitiveComplexity - Cognitive Complexity, Because Testability != Understandability |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Perl::Critic::Policy::CognitiveComplexity::ProhibitExcessCognitiveComplexity is a rule that checks the |
21
|
|
|
|
|
|
|
cognitive complexity score of your subroutines. It is based on a new scoring algorithm introduced by |
22
|
|
|
|
|
|
|
SonarSource. See L<SonarSource blog entry|https://blog.sonarsource.com/cognitive-complexity-because-testability-understandability/>. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 Rules |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over 1 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item L<CognitiveComplexity::ProhibitExcessCognitiveComplexity|Perl::Critic::Policy::CognitiveComplexity::ProhibitExcessCognitiveComplexity> - Avoid code that is nested, and thus difficult to grasp. |
29
|
|
|
|
|
|
|
Examples can be seen in the Policy POD. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=back |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 Configuration |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
The default complexity score before code starts to be reported with medium severity, is 10. This can be changed by changing the C<warn_level> parameter. |
36
|
|
|
|
|
|
|
By default all subroutines with complexity level of more than 0 are reported in lowest severity level. This allows third-party tools to pick up these |
37
|
|
|
|
|
|
|
values as code metrics. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
[Perl::Critic::Policy::CognitiveComplexity::ProhibitExcessCognitiveComplexity] |
40
|
|
|
|
|
|
|
warn_level = 10 |
41
|
|
|
|
|
|
|
info_level = 1 |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SEE ALSO |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
L<Perl::Critic> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 COPYRIGHT |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Copyright (C) 2017 Oliver Trosien |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
54
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 AUTHOR |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Oliver Trosien E<lt>cpan@pocket-design.deE<gt> |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|