| 1 | package File::Codeowners; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Read and write CODEOWNERS files | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use v5.10.1; # defined-or | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Encode qw(encode); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Path::Tiny 0.089; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Scalar::Util qw(openhandle); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Text::Gitignore qw(build_gitignore_matcher); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | our $VERSION = '0.53'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub _croak { require Carp; Carp::croak(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_croak: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub _usage { _croak("Usage: @_\n") } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_usage: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | sub parse { | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=6 SCAR=18.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | ▶ | my $input = shift or _usage(q{$codeowners->parse($input)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | return $self->parse_from_array($input, @_) if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | ▶ | return $self->parse_from_array($input) if ref($input) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 4 | ▶ | return $self->parse_from_string($input) if ref($input) eq 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | ▶ | return $self->parse_from_fh($input) if openhandle($input); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | return $self->parse_from_filepath($input); | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | sub parse_from_filepath { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_from_filepath: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 4 | ▶ | my $path = shift or _usage(q{$codeowners->parse_from_filepath($filepath)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 4 | ▶ | $self = bless({}, $self) if !ref($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 4 | return $self->parse_from_fh(path($path)->openr_utf8); | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | sub parse_from_fh { | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_from_fh: called CC=15 SCAR=27.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | ▶ | my $fh = shift or _usage(q{$codeowners->parse_from_fh($fh)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | ▶ | $self = bless({}, $self) if !ref($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 8 | my @lines; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | my $parse_unowned; | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 8 | my %unowned; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | my $current_project; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 8 | ▶ | while (my $line = <$fh>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 45 | my $lineno = $. - 1; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 45 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 45 | ▶ | if ($line eq '### UNOWNED (File::Codeowners)') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 2 | $parse_unowned++; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | elsif ($line =~ /^\h*#(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 11 | my $comment = $1; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 11 | my $project; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 11 | ▶ | if ($comment =~ /^\h*Project:\h*(.+?)\h*$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | ▶ | $project = $current_project = $1 || undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$1 || undef
MC/DC0%0/1
$1 || undef
$1
Truth table50%1/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 11 | ▶ | $lines[$lineno] = { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | comment => $comment, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | $project ? (project => $project) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 75 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | elsif ($line =~ /^\h*$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 78 | # blank line | ||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | elsif ($line =~ /^\h*(.+?)(?<!\\)\h+(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 17 | my $pattern = $1; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 17 | my @owners = $2 =~ /( (?:\@+"[^"]*") | (?:\H+) )/gx; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 17 | ▶ | $lines[$lineno] = { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | pattern => $pattern, | ||||||||||||||||||||||||||||||||||||||||||
| 85 | owners => \@owners, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | $current_project ? (project => $current_project) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||
| 89 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | die "Parse error on line $.: $line\n"; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 7 | ▶ | if ($parse_unowned) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | while (my $line = <$fh>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | ▶ | if ($line =~ /# (.+)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | my $filepath = $1; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | $unowned{$filepath}++; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 7 | $self->{lines} = \@lines; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 7 | $self->{unowned} = \%unowned; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | sub parse_from_array { | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_from_array: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | my $arr = shift or _usage(q{$codeowners->parse_from_array(\@lines)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | $self = bless({}, $self) if !ref($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | $arr = [$arr, @_] if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | my $str = join("\n", @$arr); | |||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | return $self->parse_from_string(\$str); | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | sub parse_from_string { | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_from_string: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | ▶ | my $str = shift or _usage(q{$codeowners->parse_from_string(\$string)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 3 | ▶ | $self = bless({}, $self) if !ref($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | ▶ | my $ref = ref($str) eq 'SCALAR' ? $str : \$str; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 3 | ▶ | open(my $fh, '<:encoding(UTF-8)', $ref) or die "open failed: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 3 | return $self->parse_from_fh($fh); | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | sub write_to_filepath { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_to_filepath: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | my $path = shift or _usage(q{$codeowners->write_to_filepath($filepath)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | path($path)->spew_utf8([map { "$_\n" } @{$self->write_to_array}]); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | sub write_to_fh { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_to_fh: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $fh = shift or _usage(q{$codeowners->write_to_fh($fh)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $charset = shift; | |||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | for my $line (@{$self->write_to_array($charset)}) { | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | print $fh "$line\n"; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | sub write_to_string { | ||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_to_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $charset = shift; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $str = join("\n", @{$self->write_to_array($charset)}) . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | return \$str; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | sub write_to_array { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_to_array: called CC=9 SCAR=22.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | my $charset = shift; | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | my @format; | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | for my $line (@{$self->_lines}) { | |||||||||||||||||||||||||||||||||||||||||
| 171 | 4 | ▶ | if (my $comment = $line->{comment}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | push @format, "#$comment"; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | elsif (my $pattern = $line->{pattern}) { | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 2 | my $owners = join(' ', @{$line->{owners}}); | |||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | push @format, "$pattern $owners"; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | push @format, ''; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | my @unowned = sort keys %{$self->_unowned}; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | if (@unowned) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | ▶ | push @format, '' if $format[-1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | push @format, '### UNOWNED (File::Codeowners)'; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | for my $unowned (@unowned) { | |||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | push @format, "# $unowned"; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | ▶ | if (defined $charset) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $_ = encode($charset, $_) for @format; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | return \@format; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | sub match { | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
match: called CC=9 SCAR=22.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 4 | ▶ | my $filepath = shift or _usage(q{$codeowners->match($filepath)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 4 | ▶ | my $lines = $self->{match_lines} ||= [reverse grep { ($_ || {})->{pattern} } @{$self->_lines}]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition75%3/4
$self->{"match_lines"} ||= [reverse(grep({+($_ || {})->{"pattern"};} @{$self->_lines;}))]
$_ || {}
MC/DC100%1/1
$self->{"match_lines"} ||= [reverse(grep({+($_ || {})->{"pattern"};} @{$self->_lines;}))]
$self->{"match_lines"}
MC/DC0%0/1
$_ || {}
$_
Truth table100%2/2
A
A= $self->{"match_lines"}
Truth table50%1/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 4 | for my $line (@$lines) { | |||||||||||||||||||||||||||||||||||||||||
| 206 | 13 | ▶ | my $matcher = $line->{matcher} ||= build_gitignore_matcher([$line->{pattern}]); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$line->{"matcher"} ||= build_gitignore_matcher([$line->{"pattern"}])
MC/DC0%0/2
$line->{"matcher"} ||= build_gitignore_matcher([$line->{"pattern"}])
$line->{"matcher"}
build_gitignore_matcher([$line->{"pattern"}])
Truth table66%2/3
A ||= B
A= $line->{"matcher"}B= build_gitignore_matcher([$line->{"pattern"}])
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | return { # deep copy | ||||||||||||||||||||||||||||||||||||||||||
| 208 | pattern => $line->{pattern}, | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 4 | ▶ | owners => [@{$line->{owners} || []}], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 13 | ▶ | $line->{project} ? (project => $line->{project}) : (), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | } if $matcher->($filepath); | ||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | return undef; ## no critic (Subroutines::ProhibitExplicitReturn) | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | sub owners { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
owners: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | my $pattern = shift; | |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 5 | ▶ | return $self->{owners} if !$pattern && $self->{owners}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $pattern and $self->{"owners"}
MC/DC100%2/2
not $pattern and $self->{"owners"}
not $pattern
$self->{"owners"}
Truth table100%3/3
not(A) and B
A= not $patternB= $self->{"owners"}
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 4 | my %owners; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 4 | for my $line (@{$self->_lines}) { | |||||||||||||||||||||||||||||||||||||||||
| 226 | 44 | ▶ | next if $pattern && $line->{pattern} && $pattern ne $line->{pattern}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$pattern and $line->{"pattern"} and $pattern ne $line->{"pattern"}
$pattern and $line->{"pattern"}
MC/DC100%3/3
$pattern and $line->{"pattern"} and $pattern ne $line->{"pattern"}
$pattern
$line->{"pattern"}
$pattern ne $line->{"pattern"}
Truth table100%4/4
A and B and C
A= $patternB= $line->{"pattern"}C= $pattern ne $line->{"pattern"}
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 39 | ▶ | $owners{$_}++ for (@{$line->{owners} || []}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 4 | my $owners = [sort keys %owners]; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 4 | ▶ | $self->{owners} = $owners if !$pattern; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 4 | return $owners; | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | sub patterns { | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
patterns: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | my $owner = shift; | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | ▶ | return $self->{patterns} if !$owner && $self->{patterns}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $owner and $self->{"patterns"}
MC/DC0%0/2
not $owner and $self->{"patterns"}
not $owner
$self->{"patterns"}
Truth table66%2/3
not(A) and B
A= not $ownerB= $self->{"patterns"}
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | my %patterns; | |||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | for my $line (@{$self->_lines}) { | |||||||||||||||||||||||||||||||||||||||||
| 245 | 28 | ▶ | next if $owner && !grep { $_ eq $owner } @{$line->{owners} || []}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$owner and not grep({$_ eq $owner;} @{$line->{"owners"} or [];})
MC/DC100%2/2
$owner and not grep({$_ eq $owner;} @{$line->{"owners"} or [];})
$owner
not grep({$_ eq $owner;} @{$line->{"owners"} or [];})
Truth table100%3/3
A and not(B)
A= $ownerB= not grep({$_ eq $owner;} @{$line->{"owners"} or [];})
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 16 | my $pattern = $line->{pattern}; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 16 | ▶ | $patterns{$pattern}++ if $pattern; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | my $patterns = [sort keys %patterns]; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 2 | ▶ | $self->{patterns} = $patterns if !$owner; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | return $patterns; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | sub projects { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
projects: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 2 | ▶ | return $self->{projects} if $self->{projects}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 2 | my %projects; | |||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | for my $line (@{$self->_lines}) { | |||||||||||||||||||||||||||||||||||||||||
| 264 | 28 | my $project = $line->{project}; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 28 | ▶ | $projects{$project}++ if $project; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | my $projects = [sort keys %projects]; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | $self->{projects} = $projects; | |||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 2 | return $projects; | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | sub update_owners { | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_owners: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 2 | my $pattern = shift; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 2 | my $owners = shift; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | ▶ | $pattern && $owners or _usage(q{$codeowners->update_owners($pattern => \@owners)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$pattern and $owners
MC/DC0%0/2
$pattern and $owners
$pattern
$owners
Truth table33%1/3
A and B
A= $patternB= $owners
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 2 | ▶ | $owners = [$owners] if ref($owners) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 2 | $self->_clear; | |||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 2 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 2 | for my $line (@{$self->_lines}) { | |||||||||||||||||||||||||||||||||||||||||
| 288 | 4 | ▶ | next if !$line->{pattern}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 2 | ▶ | next if $pattern ne $line->{pattern}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | $line->{owners} = [@$owners]; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | ++$count; | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 2 | return $count; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | sub update_owners_by_project { | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_owners_by_project: called CC=8 SCAR=21.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 1 | my $project = shift; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 1 | my $owners = shift; | |||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | $project && $owners or _usage(q{$codeowners->update_owners_by_project($project => \@owners)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$project and $owners
MC/DC0%0/2
$project and $owners
$project
$owners
Truth table33%1/3
A and B
A= $projectB= $owners
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | ▶ | $owners = [$owners] if ref($owners) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | $self->_clear; | |||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 1 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 1 | for my $line (@{$self->_lines}) { | |||||||||||||||||||||||||||||||||||||||||
| 311 | 14 | ▶ | next if !$line->{project} || !$line->{owners}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$line->{"project"} and $line->{"owners"}
MC/DC100%2/2
$line->{"project"} and $line->{"owners"}
$line->{"project"}
$line->{"owners"}
Truth table100%3/3
A and B
A= $line->{"project"}B= $line->{"owners"}
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | ▶ | next if $project ne $line->{project}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | $line->{owners} = [@$owners]; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | ++$count; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | return $count; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | sub rename_owner { | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rename_owner: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | my $old_owner = shift; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $new_owner = shift; | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | $old_owner && $new_owner or _usage(q{$codeowners->rename_owner($owner => $new_owner)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$old_owner and $new_owner
MC/DC0%0/2
$old_owner and $new_owner
$old_owner
$new_owner
Truth table0%0/3
A and B
A= $old_ownerB= $new_owner
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $self->_clear; | |||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | for my $line (@{$self->_lines}) { | |||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | next if !exists $line->{owners}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | for (my $i = 0; $i < @{$line->{owners}}; ++$i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | next if $line->{owners}[$i] ne $old_owner; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | $line->{owners}[$i] = $new_owner; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ++$count; | |||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | return $count; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | sub rename_project { | ||||||||||||||||||||||||||||||||||||||||||
| 345 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rename_project: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 1 | my $old_project = shift; | |||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | my $new_project = shift; | |||||||||||||||||||||||||||||||||||||||||
| 348 | 1 | ▶ | $old_project && $new_project or _usage(q{$codeowners->rename_project($project => $new_project)}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$old_project and $new_project
MC/DC0%0/2
$old_project and $new_project
$old_project
$new_project
Truth table33%1/3
A and B
A= $old_projectB= $new_project
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 1 | $self->_clear; | |||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 1 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | for my $line (@{$self->_lines}) { | |||||||||||||||||||||||||||||||||||||||||
| 355 | 14 | ▶ | next if !exists $line->{project} || $old_project ne $line->{project}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not exists $line->{"project"} or $old_project ne $line->{"project"}
MC/DC50%1/2
not exists $line->{"project"} or $old_project ne $line->{"project"}
not exists $line->{"project"}
$old_project ne $line->{"project"}
Truth table66%2/3
not(A) or B
A= not exists $line->{"project"}B= $old_project ne $line->{"project"}
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | $line->{project} = $new_project; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 2 | ▶ | $line->{comment} = " Project: $new_project" if exists $line->{comment}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 2 | ++$count; | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | return $count; | |||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | sub append { | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 1 | $self->_clear; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 1 | ▶ | push @{$self->_lines}, (@_ ? {@_} : undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | sub prepend { | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepend: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | $self->_clear; | |||||||||||||||||||||||||||||||||||||||||
| 375 | 1 | ▶ | unshift @{$self->_lines}, (@_ ? {@_} : undef); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | sub unowned { | ||||||||||||||||||||||||||||||||||||||||||
| 380 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unowned: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 4 | ▶ | [sort keys %{$self->{unowned} || {}}]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | sub add_unowned { | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_unowned: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 1 | $self->_unowned->{$_}++ for @_; | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | sub remove_unowned { | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_unowned: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | delete $self->_unowned->{$_} for @_; | |||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | sub is_unowned { | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_unowned: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my $filepath = shift; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $self->_unowned->{$filepath}; | |||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | sub clear_unowned { | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_unowned: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | 1 | $self->{unowned} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 24 | ▶ | sub _lines { shift->{lines} ||= [] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lines: called CC=2 SCAR=7.6
Condition50%1/2
+(shift())->{"lines"} ||= []
MC/DC0%0/1
+(shift())->{"lines"} ||= []
+(shift())->{"lines"}
Truth table50%1/2
A
A= +(shift())->{"lines"}
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 4 | ▶ | sub _unowned { shift->{unowned} ||= {} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_unowned: called CC=2 SCAR=7.6
Condition50%1/2
+(shift())->{"unowned"} ||= {}
MC/DC0%0/1
+(shift())->{"unowned"} ||= {}
+(shift())->{"unowned"}
Truth table50%1/2
A
A= +(shift())->{"unowned"}
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | sub _clear { | ||||||||||||||||||||||||||||||||||||||||||
| 414 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clear: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 6 | delete $self->{match_lines}; | |||||||||||||||||||||||||||||||||||||||||
| 416 | 6 | delete $self->{owners}; | |||||||||||||||||||||||||||||||||||||||||
| 417 | 6 | delete $self->{patterns}; | |||||||||||||||||||||||||||||||||||||||||
| 418 | 6 | delete $self->{projects}; | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | __END__ | ||||||||||||||||||||||||||||||||||||||||||