Diff.pm

filter: Statementstmt 55.2% 21 / 38 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 87.5% 7 / 8 Podpod 100% 1 / 1 totaltotal 46.7% 29 / 62 CC 7 SCAR 33.5
CC
7
Cov
41%
diff
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 28.5
↑ Summary Diff/Hunk.pm »
1 package Git::Repository::Plugin::Diff;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use 5.008_005;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 our $VERSION = '0.01';
8  
9 2 ▶use Git::Repository::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 our @ISA = qw( Git::Repository::Plugin );
11  
12 2 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use Git::Repository::Plugin::Diff::Hunk;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶sub _keywords { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
Subroutine _keywords: called CC=1 SCAR=0.0
17 1 return qw( diff );
18 }
19  
20 0 ▶sub diff {
Subroutine diff: not called CC=7 SCAR=40.3
Pod documented
21 0 my ( $repository, $file, $from_commit, $to_commit ) = @_;
22  
23 0 my $command =
24 $repository->command( 'diff', $from_commit, $to_commit, $file );
25 0 my @output = $command->final_output();
26  
27 0 my @hunks;
28  
29 # Parse the output.
30 my $hunk;
31 0 while (1) {
32 0 my $line = shift @output;
33  
34 0 ▶ if ( !defined $line ) { # eof
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $line) 0 0 0
35 0 ▶ push @hunks, $hunk if $hunk;
Branch: 1 branch
BranchTrueFalseTotal
if $hunk 0 0 0
36 0 last;
37 }
38  
39 0 ▶ if ( !defined($hunk) and $line !~ /^\@\@/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $hunk or $line =~ /^\@\@/) 0 0 0
Condition0%0/3
defined $hunk or $line =~ /^\@\@/
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $hunk or $line =~ /^\@\@/
defined $hunk $line =~ /^\@\@/
Truth table0%0/3
A or B
A= defined $hunkB= $line =~ /^\@\@/
ABresult
1X1
011
000
40 0 next;
41 }
42  
43 0 ▶ if ( $line =~ /^@@/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\@@/) 0 0 0
44 0 ▶ push @hunks, $hunk if $hunk;
Branch: 1 branch
BranchTrueFalseTotal
if $hunk 0 0 0
45 0 $hunk = Git::Repository::Plugin::Diff::Hunk->parse_header($line);
46 0 next;
47 }
48  
49 0 $hunk->add_line($line);
50 }
51  
52 0 return @hunks;
53 }
54  
55 2 1;
56 __END__
↑ Summary Diff/Hunk.pm »