VCI/Abstract/Diff.pm

filter: Statementstmt 56.2% 18 / 32 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 57.1% 4 / 7 Podpod n/a totaltotal 50.0% 22 / 44 CC 4 SCAR 21.7
CC
4
Cov
50%
_build_files
20.0
_build__parsed
2.0
_transform_filename
2.0
CRAP 8.8
« VCI/Abstract/Committable.pm ↑ Summary VCI/Abstract/History.pm »
1 package VCI::Abstract::Diff;
2 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 with 'VCI::Abstract::ProjectItem';
4  
5 3 ▶use Text::Diff::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use VCI::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use VCI::Abstract::Diff::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 has 'files' => (is => 'ro', isa => 'ArrayRef[VCI::Abstract::Diff::File]',
11 lazy_build => 1);
12 3 has 'raw' => (is => 'ro', isa => 'Str', required => 1);
13 3 has '_parsed' => (is => 'ro', isa => 'Text::Diff::Parser', lazy_build => 1);
14  
15 0 ▶sub _build__parsed {
Subroutine _build__parsed: not called CC=1 SCAR=6.9
16 0 my $self = shift;
17 0 return Text::Diff::Parser->new(Diff => $self->raw);
18 }
19  
20 0 ▶sub _build_files {
Subroutine _build_files: not called CC=4 SCAR=30.0
21 0 my $self = shift;
22 0 my %files;
23 0 foreach my $change ($self->_parsed->changes) {
24 0 my $file1 = $self->_transform_filename($change->filename1);
25 0 my $file2 = $self->_transform_filename($change->filename2);
26 # We access filename2 directly to avoid things like project names of
27 # "/dev/null"
28 0 ▶ my $changed_file = $change->filename2 eq '/dev/null' ? $file1 : $file2;
Branch: 1 branch
BranchTrueFalseTotal
$change->filename2 eq '/dev/null' ? : 0 0 0
29 0 ▶ $files{$changed_file} ||= { path => $changed_file, changes => [] };
Condition0%0/2
$files{$changed_file} ||= {"path", $changed_file, "changes", []}
l!l
00
MC/DC0%0/1
$files{$changed_file} ||= {"path", $changed_file, "changes", []}
$files{$changed_file}
Truth table0%0/2
A
A= $files{$changed_file}
Aresult
11
00
30 0 push(@{ $files{$changed_file}->{changes} }, $change);
31 }
32 0 return [map { VCI::Abstract::Diff::File->new($files{$_}) } (keys %files)];
33 }
34  
35 0 ▶sub _transform_filename { return $_[1] }
Subroutine _transform_filename: not called CC=1 SCAR=6.9
36  
37 3 __PACKAGE__->meta->make_immutable;
38  
39 3 1;
40  
41 __END__
« VCI/Abstract/Committable.pm ↑ Summary VCI/Abstract/History.pm »