GitHubActions/ErrorAggregate.pm

filter: Statementstmt 100% 33 / 33 Branchbran n/a Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 12 / 12 Podpod 100% 3 / 3 totaltotal 94.3% 50 / 53 CC 3 SCAR 2.5
CC
3
Cov
97%
_ensure_group_in_line
2.0
add
2.0
BEGIN
1.0
CRAP 1.3
« GitHubActions/Error.pm ↑ Summary
1 package TAP::Formatter::GitHubActions::ErrorAggregate;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use v5.16;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use base 'TAP::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use TAP::Formatter::GitHubActions::ErrorGroup;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 my @ATTR;
10  
11 2 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 @ATTR = qw(groups);
13 2 __PACKAGE__->mk_methods(@ATTR);
14 }
15  
16 7 ▶sub _initialize {
Subroutine _initialize: called CC=1 SCAR=0.0
17 7 my ($self) = @_;
18 7 $self->{groups} = {};
19 7 return $self;
20 }
21  
22 40 ▶sub _ensure_group_in_line {
Subroutine _ensure_group_in_line: called CC=2 SCAR=7.1
23 40 my ($self, $line) = @_;
24 40 ▶ return $self->groups->{$line} //= (
Condition66%2/3
$self->groups->{$line} //= "TAP::Formatter::GitHubActions::ErrorGroup"->new("line", $line)
l!l&&r!l&&!r
2380
MC/DC0%0/2
$self->groups->{$line} //= "TAP::Formatter::GitHubActions::ErrorGroup"->new("line", $line)
$self->groups->{$line} "TAP::Formatter::GitHubActions::ErrorGroup"->new("line", $line)
Truth table66%2/3
A //= B
A= $self->groups->{$line}B= "TAP::Formatter::GitHubActions::ErrorGroup"->new("line", $line)
ABresult
1X1
011
000
25 TAP::Formatter::GitHubActions::ErrorGroup->new(line => $line)
26 );
27 }
28  
29 22 ▶sub add {
Subroutine add: called CC=2 SCAR=6.9
Pod documented
30 22 my ($self, @errors) = @_;
31 22 $self->group($_->line)->add($_) for @errors;
32 22 return $self;
33 }
34  
35 40 ▶sub group {
Subroutine group: called CC=1 SCAR=0.0
Pod documented
36 40 my ($self, $key) = @_;
37 40 return $self->_ensure_group_in_line($key);
38 }
39  
40 5 ▶sub as_sorted_array {
Subroutine as_sorted_array: called CC=1 SCAR=0.0
Pod documented
41 5 my ($self) = @_;
42  
43 5 return map { $self->groups->{$_} } sort _by_lexical_sortable_numbers keys %{$self->groups};
44 }
45  
46 62 ▶sub _by_lexical_sortable_numbers {
Subroutine _by_lexical_sortable_numbers: called CC=1 SCAR=0.0
47 62 sprintf("%04d", $a) <=> sprintf("%04d", $b);
48 }
49  
50 2 1;
51 =head1 NAME
52  
53 TAP::Formatter::GitHubActions::ErrorAggregate - An aggregate of errrors.
54  
55 It groups C<TAP::Formatter::GitHubActions::ErrorGroup> and makes it easier to
56 access groups and loop all of them in oder.
57  
58 =head1 METHODS
59  
60 =head2 add(@errors)
61  
62 Saves C<@errors> into a respective C<TAP::Formatter::GitHubActions::ErrorGroup>.
63  
64 =head2 group($line)
65  
66 Get's C<TAP::Formatter::GitHubActions::ErrorGroup> for a given C<$line>.
67  
68 =head2 as_sorted_array()
69  
70 Returns an array of C<TAP::Formatter::GitHubActions::ErrorGroup> sorted by line.
71  
72 =cut
« GitHubActions/Error.pm ↑ Summary