DMOSS/Plugin/FunctionIdsDoc.pm

filter: Statementstmt 31.3% 16 / 51 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 40.0% 4 / 10 Podpod 100% 6 / 6 totaltotal 30.2% 26 / 86 CC 12 SCAR 30.3
CC
12
Cov
24%
process
42.0
report
30.0
reduce
6.0
CRAP 20.7
« DMOSS/Report/HTML.pm ↑ Summary DMOSS/Plugin.pm »
1 package DMOSS::Plugin::FunctionIdsDoc;
2 1 $DMOSS::Plugin::FunctionIdsDoc::VERSION = '0.01_2';
3 # ABSTRACT: DMOSS number identifiers found in docs plugin
4 1 ▶use parent qw/DMOSS::Plugin/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use File::Slurp qw/read_file/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our @types = qw/_SOURCE/;
11  
12 0 ▶sub name { 'Function Identifiers Found in Documentation' }
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
13  
14 1 my $TMPDIR = '/tmp'; # FIXME
15 0 ▶sub process {
Subroutine process: not called CC=6 SCAR=37.4
Pod documented
16 0 my ($self, $dmoss, $file) = @_;
17  
18 0 my $run = "curl -s -F \"upload_file=\@".$file->fullpath.';filename='.$file->path."\" http://conclave.di.uminho.pt/clang/ws";
19 0 my $res = `$run`;
20  
21 0 my @ids;
22 0 foreach (split /\n+/, $res) {
23 0 ▶ if ($_ =~ m/^Function/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^Function/) 0 0 0
24 0 my @l = split /,/, $_;
25 0 push @ids, $l[2];
26 }
27 }
28  
29 0 my $corpus = join('/', $TMPDIR, $dmoss->{meta}->{dist}) . '.txt';
30 0 ▶ unless (-e $corpus) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $corpus) 0 0 0
31 0 `dmoss-corpus $dmoss->{basedir} > $corpus`;
32 }
33  
34 0 my $content = read_file $corpus;
35 0 my $found = 0;
36 0 foreach (@ids) {
37 0 ▶ $found++ if ($content =~ m/\b$_\b/);
Branch: 1 branch
BranchTrueFalseTotal
if $content =~ /\b$_\b/ 0 0 0
38 }
39  
40 0 $dmoss->add_attr('ids', {found=>$found, total=>scalar(@ids) } );
41 }
42  
43 0 ▶sub reduce {
Subroutine reduce: not called CC=2 SCAR=17.9
Pod documented
44 0 my ($self, $dmoss, @attrs) = @_;
45 0 my ($total, $found) = (0, 0);
46  
47 0 foreach (@attrs) {
48 0 $total += $_->value->{total};
49 0 $found += $_->value->{found};
50 }
51  
52 0 $dmoss->add_attr('ids', {found=>$found, total=>$total} );
53 }
54  
55 0 ▶sub report {
Subroutine report: not called CC=5 SCAR=34.0
Pod documented
56 0 my ($self, $dmoss, $attr) = @_;
57 0 ▶ return unless ($attr->value and keys %{$attr->value});
Branch: 1 branch
BranchTrueFalseTotal
unless $attr->value and keys %{$attr->value;} 0 0 0
Condition0%0/3
$attr->value and keys %{$attr->value;}
!ll&&!rl&&r
000
MC/DC0%0/2
$attr->value and keys %{$attr->value;}
$attr->value keys %{$attr->value;}
Truth table0%0/3
A and B
A= $attr->valueB= keys %{$attr->value;}
ABresult
0X0
100
111
58 0 ▶ return unless $attr->value->{total};
Branch: 1 branch
BranchTrueFalseTotal
unless $attr->value->{"total"} 0 0 0
59 0 my ($found, $total) = ($attr->value->{found}, $attr->value->{total});
60  
61 0 ▶ my $p = $total ? int($found/$total*100) : 0;
Branch: 1 branch
BranchTrueFalseTotal
$total ? : 0 0 0
62 0 return [ $attr->file->path, $found, $total, "$p%" ];
63  
64 }
65  
66 0 ▶sub report_headers {
Subroutine report_headers: not called CC=1 SCAR=6.9
Pod documented
67 0 my ($self, $dmoss) = @_;
68  
69 0 return [ '', 'Ids Found', 'Total Ids', '% Found' ];
70 }
71  
72 0 ▶sub grade {
Subroutine grade: not called CC=2 SCAR=17.9
Pod documented
73 0 my ($self, $dmoss, $attr) = @_;
74 0 my ($found, $total) = ($attr->value->{found}, $attr->value->{total});
75  
76 0 ▶ return ($total ? ($found/$total) : 0);
Branch: 1 branch
BranchTrueFalseTotal
$total ? : 0 0 0
77  
78 }
79  
80 1 1;
81  
82 __END__
« DMOSS/Report/HTML.pm ↑ Summary DMOSS/Plugin.pm »