blib/lib/String/Nudge.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 4 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 100% 45 / 45 CC 4 SCAR 9.2
CC
4
Cov
100%
nudge
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.5
↑ Summary
1 2 ▶use 5.10.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package String::Nudge;
6  
7 # ABSTRACT: Indents all lines in a multi-line string
8 2 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 2 our $VERSION = '1.0002';
10  
11 2 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 our @EXPORT = qw/nudge/;
13  
14 11 ▶sub nudge ($;$) {
Subroutine nudge: called CC=4 SCAR=13.9
Pod documented
15 11 my $first = shift;
16 11 my $second = shift;
17  
18 11 my $indent = 4;
19 11 my $string;
20  
21 11 ▶ if(defined $second) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $second) { } 8 3 11
22 8 ▶ if(int $first eq $first && int $first >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (int $first eq $first and int $first >= 0) { } 6 2 8
Condition100%3/3
int $first eq $first and int $first >= 0
!ll&&!rl&&r
116
MC/DC100%2/2
int $first eq $first and int $first >= 0
int $first eq $first int $first >= 0
Truth table100%3/3
A and B
A= int $first eq $firstB= int $first >= 0
ABresult
0X0
100
111
23 6 $indent = int $first;
24 6 $string = $second;
25 }
26 else {
27 2 warnings::warn(numeric => q{first argument to nudge not an integer >= 0.});
28 2 $string = $second;
29 }
30 }
31 else {
32 3 $string = $first;
33  
34 }
35 11 my $nudgement = ' ' x $indent;
36  
37 11 $string =~ s{^(?=\V)}{$nudgement}gms;
38 11 $string =~ s{^\h*$}{}gms;
39 11 return $string;
40 }
41  
42  
43 2 1;
44  
45 __END__
↑ Summary