ZofCMS/Plugin/RandomPasswordGeneratorPurePerl.pm

filter: Statementstmt 50.0% 14 / 28 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 57.1% 4 / 7 Podpod n/a totaltotal 39.1% 18 / 46 CC 7 SCAR 34.3
CC
7
Cov
37%
_do
56.0
_key
2.0
_defaults
2.0
CRAP 30.8
« ZofCMS/Plugin/GoogleCalculator.pm ↑ Summary ZofCMS/Plugin/Cookies.pm »
1 package App::ZofCMS::Plugin::RandomPasswordGeneratorPurePerl;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '1.001010'; # VERSION
7  
8 1 ▶use Digest::MD5 (qw/md5_hex/);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use base 'App::ZofCMS::Plugin::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub _key { 'plug_random_password_generator_pure_perl_pure_perl' }
Subroutine _key: not called CC=1 SCAR=6.9
12 0 ▶sub _defaults {
Subroutine _defaults: not called CC=1 SCAR=6.9
13 return (
14 0 length => 8,
15 chars => [ 0..9, 'a'..'z', 'A'..'Z' ],
16 cell => 'd',
17 key => 'random_pass',
18 md5_hex => 0,
19 pass_num => 1,
20 );
21 }
22 0 ▶sub _do {
Subroutine _do: not called CC=7 SCAR=40.3
23 0 my ( $self, $conf, $template, $query, $config ) = @_;
24  
25 0 my @passwords;
26  
27 0 for ( 1 .. $conf->{pass_num} ) {
28 0 ▶ my @chars = @{ $conf->{chars} || ['0'] };
Condition0%0/2
$conf->{'chars'} || ['0']
l!l
00
MC/DC0%0/1
$conf->{'chars'} || ['0']
$conf->{'chars'}
Truth table0%0/2
A
A= $conf->{'chars'}
Aresult
11
00
29 0 ▶ @chars = '0'
Branch: 1 branch
BranchTrueFalseTotal
unless @chars 0 0 0
30 unless @chars;
31  
32 0 my $password = '';
33  
34 0 ▶ while ( $conf->{length} > length $password ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{"length"} > length $password) 0 0 0
35 0 $password .= @chars[ rand @chars ];
36 }
37  
38 $password = [ $password, md5_hex($password) ]
39 0 ▶ if $conf->{md5_hex};
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"md5_hex"} 0 0 0
40  
41 0 push @passwords, $password;
42 }
43  
44 $template->{ $conf->{cell} }{ $conf->{key} }
45 0 ▶ = @passwords > 1 ? \@passwords : $passwords[0];
Branch: 1 branch
BranchTrueFalseTotal
@passwords > 1 ? : 0 0 0
46 }
47  
48  
49 1 1;
50 __END__
« ZofCMS/Plugin/GoogleCalculator.pm ↑ Summary ZofCMS/Plugin/Cookies.pm »