DMOSS/Plugin/VerifyChanges.pm

filter: Statementstmt 27.6% 18 / 65 Branchbran 0.0% 0 / 30 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 45.4% 5 / 11 Podpod 100% 6 / 6 totaltotal 23.0% 29 / 126 CC 20 SCAR 38.9
CC
20
Cov
17%
process
90.0
grade
56.0
report
42.0
CRAP 48.8
« DMOSS/Oracle.pm ↑ Summary DMOSS/Plugin/AutoClassify.pm »
1 package DMOSS::Plugin::VerifyChanges;
2 1 $DMOSS::Plugin::VerifyChanges::VERSION = '0.01_2';
3 # ABSTRACT: DMOSS changes 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 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our @types = qw/CHANGES/;
12  
13 0 ▶sub name { 'Verify Changes' }
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
14  
15 0 ▶sub process {
Subroutine process: not called CC=9 SCAR=45.0
Pod documented
16 0 my ($self, $dmoss, $file) = @_;
17 0 my @local = localtime;
18 0 my $current = $local[5]+1900;
19  
20 0 open(my $fh, '<', $file->fullpath);
21 0 $/ = '';
22 0 my $years;
23 0 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
24 0 my ($year, $ver);
25 0 ▶ $year = $1 if $_ =~ m/(\d{4})/;
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ /(\d{4})/ 0 0 0
26 0 ▶ next unless ($year and $year > 1970 and $year <= $current);
Branch: 1 branch
BranchTrueFalseTotal
unless $year and $year > 1970 and $year <= $current 0 0 0
Condition0%0/6
$year and $year > 1970 and $year <= $current
!ll&&!rl&&r
000
$year and $year > 1970
!ll&&!rl&&r
000
MC/DC0%0/3
$year and $year > 1970 and $year <= $current
$year $year > 1970 $year <= $current
Truth table0%0/4
A and B and C
A= $yearB= $year > 1970C= $year <= $current
ABCresult
0XX0
10X0
1100
1111
27  
28 0 ▶ $ver = $1 if $_ =~ m/(\d+\.\d+)/;
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ /(\d+\.\d+)/ 0 0 0
29  
30 0 ▶ if ($ver) { push @{$years->{$year}}, $ver; }
Branch: 1 branch
BranchTrueFalseTotal
if ($ver) { } 0 0 0
31 0 ▶ else { $years->{$year} = [] unless $years->{$year}; }
Branch: 1 branch
BranchTrueFalseTotal
unless $years->{$year} 0 0 0
32 }
33  
34 0 my @years = sort {$b<=>$a} keys %$years;
35 0 my $last = shift @years;
36  
37 0 $dmoss->add_attr('changes', {years=>$years, last=>$last} );
38 }
39  
40 0 ▶sub reduce {
Subroutine reduce: not called CC=1 SCAR=6.9
Pod documented
41 0 my ($self, $dmoss, $attr) = @_;
42  
43 0 $dmoss->add_attr('links', $attr->value);
44 }
45  
46 0 ▶sub report {
Subroutine report: not called CC=6 SCAR=37.4
Pod documented
47 0 my ($self, $dmoss, $attr) = @_;
48 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
49  
50 0 my $final;
51 0 foreach (sort {$b<=>$a} keys %{ $attr->value->{years} }) {
52 0 ▶ next unless $attr->value->{years}->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $attr->value->{"years"}{$_} 0 0 0
53 0 my @l = @{$attr->value->{years}->{$_}};
54 0 ▶ push @$final, [ $_, @l ? join(', ', @l) : 'Unknown' ];
Branch: 1 branch
BranchTrueFalseTotal
@l ? : 0 0 0
55 }
56  
57 0 return $final;
58 }
59  
60 0 ▶sub report_headers {
Subroutine report_headers: not called CC=1 SCAR=6.9
Pod documented
61 0 my ($self, $dmoss) = @_;
62  
63 0 return ['Year', 'Versions'];
64 }
65  
66 0 ▶sub grade {
Subroutine grade: not called CC=7 SCAR=40.3
Pod documented
67 0 my ($self, $dmoss, $attr) = @_;
68 0 ▶ return 0 unless $attr;
Branch: 1 branch
BranchTrueFalseTotal
unless $attr 0 0 0
69  
70 0 my $last = $attr->value->{last};
71 0 ▶ return 0 unless $last;
Branch: 1 branch
BranchTrueFalseTotal
unless $last 0 0 0
72 0 my @local = localtime;
73 0 my $current = $local[5]+1900;
74 0 ▶ return 0 unless $current;
Branch: 1 branch
BranchTrueFalseTotal
unless $current 0 0 0
75  
76 0 ▶ return 1 if ($last == $current);
Branch: 1 branch
BranchTrueFalseTotal
if $last == $current 0 0 0
77 0 ▶ return 0.9 if ($last+1 == $current);
Branch: 1 branch
BranchTrueFalseTotal
if $last + 1 == $current 0 0 0
78 0 ▶ return 0.5 if ($last < $current);
Branch: 1 branch
BranchTrueFalseTotal
if $last < $current 0 0 0
79 0 return 0;
80 }
81  
82 1 1;
83  
84 __END__
« DMOSS/Oracle.pm ↑ Summary DMOSS/Plugin/AutoClassify.pm »