line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::Critic::CognitiveComplexity; |
2
|
1
|
|
|
1
|
|
430
|
use 5.010; |
|
1
|
|
|
|
|
2
|
|
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
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 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
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=back |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 Configuration |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
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. |
35
|
|
|
|
|
|
|
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 |
36
|
|
|
|
|
|
|
values as code metrics. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
[Perl::Critic::Policy::CognitiveComplexity::ProhibitExcessCognitiveComplexity] |
39
|
|
|
|
|
|
|
warn_level = 10 |
40
|
|
|
|
|
|
|
info_level = 1 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SEE ALSO |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
L<Perl::Critic> |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 COPYRIGHT |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Copyright (C) 2017 Oliver Trosien |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
53
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 AUTHOR |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Oliver Trosien E<lt>cpan@pocket-design.deE<gt> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|