Policy/Documentation/ProhibitBadAproposMarkup.pm

filter: Statementstmt 100% 57 / 57 Branchbran 100% 8 / 8 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 16 / 16 Podpod 100% 1 / 1 totaltotal 97.8% 90 / 92 CC 7 SCAR 6.0
CC
7
Cov
99%
textblock
3.0
command
3.0
interior_sequence
3.0
CRAP 1.8
« Policy/Compatibility/PodMinimumVersion.pm ↑ Summary Policy/Documentation/ProhibitParagraphTwoDots.pm »
1 # Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2021 Kevin Ryde
2  
3 # This file is part of Perl-Critic-Pulp.
4  
5 # Perl-Critic-Pulp is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # Perl-Critic-Pulp is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with Perl-Critic-Pulp. If not, see <http://www.gnu.org/licenses/>.
17  
18  
19 package Perl::Critic::Policy::Documentation::ProhibitBadAproposMarkup;
20 40 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 40 ▶use base 'Perl::Critic::Policy';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 40 ▶use Perl::Critic::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 # uncomment this to run the ### lines
27 # use Smart::Comments;
28  
29 40 our $VERSION = 100;
30  
31 40 ▶use constant supported_parameters => ();
Subroutine BEGIN: called CC=1 SCAR=0.0
32 40 ▶use constant default_severity => $Perl::Critic::Utils::SEVERITY_LOW;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 40 ▶use constant default_themes => qw(pulp cosmetic);
Subroutine BEGIN: called CC=1 SCAR=0.0
34 40 ▶use constant applies_to => 'PPI::Document';
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 13 ▶sub violates {
Subroutine violates: called CC=1 SCAR=0.0
Pod documented
37 13 my ($self, $elem, $document) = @_;
38 13 my $parser = Perl::Critic::Pulp::PodParser::ProhibitBadAproposMarkup->new
39 (policy => $self);
40 13 $parser->parse_from_elem ($elem);
41 13 return $parser->violations;
42 }
43  
44 package Perl::Critic::Pulp::PodParser::ProhibitBadAproposMarkup;
45 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 40 ▶use base 'Perl::Critic::Pulp::PodParser';
Subroutine BEGIN: called CC=1 SCAR=0.0
48  
49 23 ▶sub command {
Subroutine command: called CC=3 SCAR=11.0
50 23 my $self = shift;
51 23 my ($command, $text, $linenum, $paraobj) = @_;
52 ### command: $command
53 ### $text
54 23 $self->SUPER::command(@_); # maintain 'in_begin'
55  
56 23 ▶ if ($command eq 'head1') {
Branch: 1 branch
BranchTrueFalseTotal
if ($command eq "head1") 14 9 23
57 14 ▶ $self->{'in_NAME'} = ($text =~ /^NAME\s*$/ ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
$text =~ /^NAME\s*$/ ? : 11 3 14
58 }
59 ### in_NAME now: $self->{'in_NAME'}
60 23 return '';
61 }
62  
63 16 ▶sub textblock {
Subroutine textblock: called CC=3 SCAR=11.0
64 16 my ($self, $text, $linenum, $paraobj) = @_;
65 ### textblock ...
66 ### in_begin: $self->{'in_begin'}
67 ### $text
68  
69 # Pod::Man accept_targets() are man, MAN, roff, ROFF. Only those =begin
70 # bits are put through to the man page and therefore only those are bad.
71 16 ▶ unless ($self->{'in_begin'} eq '' || $self->{'in_begin'} =~ /^:(man|MAN|roff|ROFF)$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"in_begin"} eq "" or $self->{"in_begin"} =~ /^:(man|MAN|roff|ROFF)$/) 3 13 16
Condition66%2/3
$self->{"in_begin"} eq "" or $self->{"in_begin"} =~ /^:(man|MAN|roff|ROFF)$/
l!l&&r!l&&!r
1303
MC/DC50%1/2
$self->{"in_begin"} eq "" or $self->{"in_begin"} =~ /^:(man|MAN|roff|ROFF)$/
$self->{"in_begin"} eq "" $self->{"in_begin"} =~ /^:(man|MAN|roff|ROFF)$/
Truth table66%2/3
A or B
A= $self->{"in_begin"} eq ""B= $self->{"in_begin"} =~ /^:(man|MAN|roff|ROFF)$/
ABresult
1X1
011
000
72 3 return '';
73 }
74  
75 13 $self->interpolate ($text, $linenum);
76 13 return '';
77 }
78  
79 12 ▶sub interior_sequence {
Subroutine interior_sequence: called CC=3 SCAR=11.0
80 12 my ($self, $command, $arg, $seq_obj) = @_;
81 ### interior: $command
82 ### $arg
83 ### $seq_obj
84 ### seq raw_text: $seq_obj->raw_text
85 ### seq left_delimiter: $seq_obj->left_delimiter
86 ### seq outer: do {my $outer=$seq_obj->nested; $outer&&$outer->cmd_name}
87  
88 12 ▶ if ($self->{'in_NAME'} && $command eq 'C') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"in_NAME"} and $command eq "C") 8 4 12
Condition100%3/3
$self->{"in_NAME"} and $command eq "C"
!ll&&!rl&&r
318
MC/DC100%2/2
$self->{"in_NAME"} and $command eq "C"
$self->{"in_NAME"} $command eq "C"
Truth table100%3/3
A and B
A= $self->{"in_NAME"}B= $command eq "C"
ABresult
0X0
100
111
89 8 my ($filename, $linenum) = $seq_obj->file_line;
90  
91 8 $self->violation_at_linenum
92 ('C<> markup in NAME section is bad for "apropos".',
93 $linenum);
94 }
95 12 return '';
96 }
97  
98 40 1;
99 __END__
« Policy/Compatibility/PodMinimumVersion.pm ↑ Summary Policy/Documentation/ProhibitParagraphTwoDots.pm »