demo.pl untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 55 CC 1 SCAR 6.9
CC
1
Cov
0%
show
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #! /usr/bin/env polyperl
2  
3 use 5.010; use warnings;
4  
5 use Lingua::EN::Grammarian ':all';
6 use Data::Dumper 'Dumper';
7  
8 sub show {
9 my $text = Dumper(@_);
10 $text =~ s/^.{8}|;\s*$//g;
11 return join q{ }, split /\s+/, $text;
12 }
13  
14 my $TEXT;
15  
16 for my $caution (extract_cautions_from $TEXT) {
17 say "[" . $caution->match . "] from ", show($caution->from),
18 " to ", show($caution->to);
19 my $explanation = $caution->explanation;
20 $explanation =~ s{^}{\t}gxms;
21 say $explanation;
22 say "\tConsider:";
23 say "\t\t$_" for $caution->suggestions;
24 say q{};
25 }
26  
27 say '_' x 60;
28  
29 for my $error (extract_errors_from $TEXT) {
30 say "[$error] from ", show($error->from),
31 " to ", show($error->to);
32 my $explanation = $error->explanation;
33 $explanation =~ s{^}{\t}gxms;
34 say $explanation;
35 say "\tReplace wth:";
36 say "\t\t$_" for $error->suggestions;
37 say q{};
38 }
39  
40 say show( get_coverage_stats() );
41  
42  
43 for my $index (7, 8, 11, 75, 295, 296, 300, 449, 505) {
44 my $problem = get_error_at($TEXT,$index)
45 // get_caution_at($TEXT,$index);
46  
47 if ($problem) {
48 say "At index $index: '$problem' --> ", $problem->explanation;
49 }
50 else {
51 say "No problems detected at index $index";
52 }
53 }
54  
55 BEGIN {
56 $TEXT = <<'END_TEXT';
57 And so had began his tortuous experience, as he is be waited their
58 with baited breathe while the courtroom dramas we're unfolding.
59  
60 He were sentenced after a summery judgement under a
61 RETROSPECTIVELY applied ordnance, using suspicious evidence. He
62 he had be given no chance to refute it, so he begun his interment. Where
63 upon he were subject to THE MOST UNIQUE and unspeakable horrors.
64  
65 The he couldn't hardly believe it. Not only was he striped and kept
66 stationery in a prone position in a pit who's contents comprised of
67 leaches; his perverse tormentors were not reticent about to insisted he
68 better learn EMACS.
69  
70 He have resisted and he sworn the experience would prove most fatal
71 the him. "I are innocent", he had say.
72  
73 END_TEXT
74 }
75  
76 __END__