.htmlgen/FunctionalPerl/Htmlgen/PerlTidy.pm

filter: Statementstmt 80.5% 29 / 36 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 2 totaltotal 67.2% 39 / 58 CC 4 SCAR 18.6
CC
4
Cov
67%
map_element
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.4
« lib/FP/HashSet.pm ↑ Summary lib/FP/Struct.pm »
1 #
2 # Copyright (c) 2019-2021 Christian Jaeger, copying@christianjaeger.ch
3 #
4 # This is free software, offered under either the same terms as perl 5
5 # or the terms of the Artistic License version 2 or the terms of the
6 # MIT License (Expat version). See the file COPYING.md that came
7 # bundled with this file.
8 #
9  
10 =head1 NAME
11  
12 FunctionalPerl::Htmlgen::PerlTidy -- code formatting for Perl snippets
13  
14 =head1 SYNOPSIS
15  
16 =head1 DESCRIPTION
17  
18 =head1 SEE ALSO
19  
20 This is a L<FunctionalPerl::Htmlgen::PXMLMapper>
21  
22 =head1 NOTE
23  
24 This is alpha software! Read the status section in the package README
25 or on the L<website|http://functional-perl.org/>.
26  
27 =cut
28  
29 package FunctionalPerl::Htmlgen::PerlTidy;
30  
31 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 2 ▶use warnings FATAL => 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
34 2 ▶use experimental "signatures";
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 2 ▶use FP::Show;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 2 ▶use Perl::Tidy;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 2 ▶use FunctionalPerl::Htmlgen::Htmlparse ":all";
Subroutine BEGIN: called CC=1 SCAR=0.0
39 2 ▶use FunctionalPerl::Htmlgen::Sourcelang;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 sub tidyhtml {
42 my ($source) = @_;
43 my ($dest, $errorfile);
44 my $error = Perl::Tidy::perltidy(
45 argv => '--html -ntoc',
46 source => \$source,
47 destination => \$dest,
48 errorfile => \$errorfile
49 );
50 if ($error) {
51 warn "perltidy error: " . show($error) . " (" . show($errorfile) . ")";
52 ()
53 } else {
54 htmlparse $dest, "pre"
55 }
56 }
57  
58 2 ▶use FP::Struct [] => "FunctionalPerl::Htmlgen::PXMLMapper";
Subroutine BEGIN: called CC=1 SCAR=0.0
59  
60 4 ▶sub match_element_names($self) { [qw(code)] }
Subroutine match_element_names: called CC=1 SCAR=0.0
Pod undocumented
61  
62 0 ▶sub map_element ($self, $e, $uplist) {
Subroutine map_element: not called CC=4 SCAR=30.0
Pod undocumented
63  
64 # warn "hm: "
65 # . show($e->name)
66 # . ", uplist= "
67 # . show($uplist->map(the_method "name"));
68 0 ▶ if (not $uplist->is_null and $uplist->first->lcname eq "pre") {
Branch: 1 branch
BranchTrueFalseTotal
if (not $uplist->is_null and $uplist->first->lcname eq 'pre') { } 0 0 0
Condition0%0/3
not $uplist->is_null and $uplist->first->lcname eq "pre"
!ll&&!rl&&r
000
MC/DC0%0/2
not $uplist->is_null and $uplist->first->lcname eq "pre"
not $uplist->is_null $uplist->first->lcname eq "pre"
Truth table0%0/3
not(A) and B
A= not $uplist->is_nullB= $uplist->first->lcname eq "pre"
ABresult
0X0
100
111
69 0 my $txt = $e->text;
70 0 ▶ if (sourcelang($txt) eq "Perl") {
Branch: 1 branch
BranchTrueFalseTotal
if (sourcelang($txt) eq 'Perl') { } 0 0 0
71 0 my $pre = tidyhtml $txt;
72  
73 #use FP::Repl;repl;
74 0 $pre->body
75 } else {
76  
77 # do not handle this element, leave up to pointer_eq to
78 # detect that
79 0 $e
80 }
81 } else {
82  
83 # do not handle this element, leave up to pointer_eq to detect
84 # that
85 0 $e
86 }
87 }
88  
89 2 _END_ # _END__ for dev
« lib/FP/HashSet.pm ↑ Summary lib/FP/Struct.pm »