Skip to content

Commit

Permalink
Format all modules
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcj committed Apr 25, 2024
1 parent d501b9d commit f2da73c
Show file tree
Hide file tree
Showing 42 changed files with 5,162 additions and 5,112 deletions.
1,987 changes: 999 additions & 988 deletions lib/Devel/Cover.pm

Large diffs are not rendered by default.

137 changes: 68 additions & 69 deletions lib/Devel/Cover/Annotation/Git.pm
Expand Up @@ -15,100 +15,99 @@ use warnings;
use Getopt::Long;

sub new {
my $class = shift;
my $annotate_arg = $ENV{DEVEL_COVER_GIT_ANNOTATE} || "";
my $self = {
annotations => [ qw( version author date ) ],
command => "git blame --porcelain $annotate_arg [[file]]",
@_
};

bless $self, $class
my $class = shift;
my $annotate_arg = $ENV{DEVEL_COVER_GIT_ANNOTATE} || "";
my $self = {
annotations => [qw( version author date )],
command => "git blame --porcelain $annotate_arg [[file]]",
@_,
};

bless $self, $class
}

sub get_annotations {
my $self = shift;
my ($file) = @_;

return if exists $self->{_annotations}{$file};
my $annotations = $self->{_annotations}{$file} = [];

print "cover: Getting git annotation information for $file\n";

my $command = $self->{command};
$command =~ s/\[\[file\]\]/$file/g;
# print "Running [$command]\n";
open my $c, "-|", $command
or warn("cover: Can't run $command: $!\n"), return;
my @annotaiton;
my $start = 1;
while (my $line = <$c>) {
# print "[$_]\n";
if ($line =~ /^\t/) {
push @$annotations, [@annotaiton];
$start = 1;
next;
}

if ($start == 1) {
$annotaiton[0] = substr $1, 0, 8 if /$line =~ ^(\w+)/;
$start = 0;
} else {
$annotaiton[1] = $1 if $line =~ /^author (.*)/;
$annotaiton[2] = localtime $1 if $line =~ /^author-time (.*)/;
}
my $self = shift;
my ($file) = @_;

return if exists $self->{_annotations}{$file};
my $annotations = $self->{_annotations}{$file} = [];

print "cover: Getting git annotation information for $file\n";

my $command = $self->{command};
$command =~ s/\[\[file\]\]/$file/g;
# print "Running [$command]\n";
open my $c, "-|", $command or warn("cover: Can't run $command: $!\n"), return;
my @annotaiton;
my $start = 1;
while (my $line = <$c>) {
# print "[$_]\n";
if ($line =~ /^\t/) {
push @$annotations, [@annotaiton];
$start = 1;
next;
}
close $c or warn "cover: Failed running $command: $!\n"

if ($start == 1) {
$annotaiton[0] = substr $1, 0, 8 if /$line =~ ^(\w+)/;
$start = 0;
} else {
$annotaiton[1] = $1 if $line =~ /^author (.*)/;
$annotaiton[2] = localtime $1 if $line =~ /^author-time (.*)/;
}
}
close $c or warn "cover: Failed running $command: $!\n"
}

sub get_options {
my ($self, $opt) = @_;
$self->{$_} = 1 for @{$self->{annotations}};
die "Bad option" unless
GetOptions($self,
qw(
author
command=s
date
version
));
my ($self, $opt) = @_;
$self->{$_} = 1 for @{ $self->{annotations} };
die "Bad option" unless GetOptions(
$self, qw(
author
command=s
date
version
)
);
}

sub count {
my $self = shift;
$self->{author} + $self->{date} + $self->{version}
my $self = shift;
$self->{author} + $self->{date} + $self->{version}
}

sub header {
my $self = shift;
my ($annotation) = @_;
$self->{annotations}[$annotation]
my $self = shift;
my ($annotation) = @_;
$self->{annotations}[$annotation]
}

sub width {
my $self = shift;
my ($annotation) = @_;
(8, 16, 24)[$annotation]
my $self = shift;
my ($annotation) = @_;
(8, 16, 24)[$annotation]
}

sub text {
my $self = shift;
my ($file, $line, $annotation) = @_;
return "" unless $line;
$self->get_annotations($file);
$self->{_annotations}{$file}[$line - 1][$annotation]
my $self = shift;
my ($file, $line, $annotation) = @_;
return "" unless $line;
$self->get_annotations($file);
$self->{_annotations}{$file}[ $line - 1 ][$annotation]
}

sub error {
my $self = shift;
my ($file, $line, $annotation) = @_;
0
my $self = shift;
my ($file, $line, $annotation) = @_;
0
}

sub class {
my $self = shift;
my ($file, $line, $annotation) = @_;
""
my $self = shift;
my ($file, $line, $annotation) = @_;
""
}

1
Expand Down
60 changes: 30 additions & 30 deletions lib/Devel/Cover/Annotation/Random.pm
Expand Up @@ -15,57 +15,57 @@ use warnings;
use Getopt::Long;

sub new {
my $class = shift;
bless {@_}, $class
my $class = shift;
bless {@_}, $class
}

sub get_options {
my ($self, $opt) = @_;
$self->{count} = 1;
die "Bad option" unless
GetOptions($self,
qw(
count=s
));
my ($self, $opt) = @_;
$self->{count} = 1;
die "Bad option" unless GetOptions(
$self, qw(
count=s
)
);
}

sub count {
my $self = shift;
$self->{count}
my $self = shift;
$self->{count}
}

sub header {
my $self = shift;
my ($annotation) = @_;
"rnd$annotation"
my $self = shift;
my ($annotation) = @_;
"rnd$annotation"
}

sub width {
my $self = shift;
my ($annotation) = @_;
length $self->header($annotation)
my $self = shift;
my ($annotation) = @_;
length $self->header($annotation)
}

sub text {
my $self = shift;
my ($file, $line, $annotation) = @_;
return "" unless $line;
$self->{annotation}{$file}[$line][$annotation] = int rand 10
unless defined $self->{annotation}{$file}[$line][$annotation];
$self->{annotation}{$file}[$line][$annotation]
my $self = shift;
my ($file, $line, $annotation) = @_;
return "" unless $line;
$self->{annotation}{$file}[$line][$annotation] = int rand 10
unless defined $self->{annotation}{$file}[$line][$annotation];
$self->{annotation}{$file}[$line][$annotation]
}

sub error {
my $self = shift;
my ($file, $line, $annotation) = @_;
!$self->text($file, $line, $annotation)
my $self = shift;
my ($file, $line, $annotation) = @_;
!$self->text($file, $line, $annotation)
}

sub class {
my $self = shift;
my ($file, $line, $annotation) = @_;
return "" unless $line;
"c" . int(($self->text($file, $line, $annotation) + 2) / 3)
my $self = shift;
my ($file, $line, $annotation) = @_;
return "" unless $line;
"c" . int(($self->text($file, $line, $annotation) + 2) / 3)
}

1
Expand Down

0 comments on commit f2da73c

Please sign in to comment.