| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my ($year, $ver); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | $year = $1 if $_ =~ m/(\d{4})/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | next unless ($year and $year > 1970 and $year <= $current); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$year and $year > 1970 and $year <= $current
$year and $year > 1970
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
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | $ver = $1 if $_ =~ m/(\d+\.\d+)/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ($ver) { push @{$years->{$year}}, $ver; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | else { $years->{$year} = [] unless $years->{$year}; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$attr->value and keys %{$attr->value;}
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;}
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my @l = @{$attr->value->{years}->{$_}}; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | push @$final, [ $_, @l ? join(', ', @l) : 'Unknown' ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $last = $attr->value->{last}; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return 0 unless $last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my @local = localtime; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $current = $local[5]+1900; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | return 0 unless $current; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | return 1 if ($last == $current); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | return 0.9 if ($last+1 == $current); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | return 0.5 if ($last < $current); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | __END__ | ||||||||||||||||||||||||||||||||||||||||||