Plugin/RandomPasswordGenerator.pm

filter: Statementstmt 58.6% 17 / 29 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 62.5% 5 / 8 Podpod n/a totaltotal 50.0% 22 / 44 CC 5 SCAR 25.8
CC
5
Cov
49%
_do
30.0
_key
2.0
_defaults
2.0
CRAP 13.2
↑ Summary Plugin/ImageResize.pm »
1 package App::ZofCMS::Plugin::RandomPasswordGenerator;
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.001003'; # VERSION
7  
8 1 ▶use base 'App::ZofCMS::Plugin::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Data::SimplePassword;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Digest::MD5 (qw/md5_hex/);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 0 ▶sub _key { 'plug_random_password_generator' }
Subroutine _key: not called CC=1 SCAR=6.9
13 0 ▶sub _defaults {
Subroutine _defaults: not called CC=1 SCAR=6.9
14 return (
15 0 length => 8,
16 chars => [ 0..9, 'a'..'z', 'A'..'Z' ],
17 cell => 'd',
18 key => 'random_pass',
19 md5_hex => 0,
20 pass_num => 1,
21 );
22 }
23 0 ▶sub _do {
Subroutine _do: not called CC=5 SCAR=34.0
24 0 my ( $self, $conf, $template, $query, $config ) = @_;
25  
26 0 my @passwords;
27  
28 0 for ( 1 .. $conf->{pass_num} ) {
29 0 my $sp = Data::SimplePassword->new;
30 0 ▶ $sp->chars( @{ $conf->{chars} || [] } );
Condition0%0/2
$conf->{'chars'} || []
l!l
00
MC/DC0%0/1
$conf->{'chars'} || []
$conf->{'chars'}
Truth table0%0/2
A
A= $conf->{'chars'}
Aresult
11
00
31 0 my $password = $sp->make_password( $conf->{length} );
32  
33 $password = [ $password, md5_hex($password) ]
34 0 ▶ if $conf->{md5_hex};
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"md5_hex"} 0 0 0
35  
36 0 push @passwords, $password;
37 }
38  
39 $template->{ $conf->{cell} }{ $conf->{key} }
40 0 ▶ = @passwords > 1 ? \@passwords : $passwords[0];
Branch: 1 branch
BranchTrueFalseTotal
@passwords > 1 ? : 0 0 0
41 }
42  
43 1 1;
44 __END__
↑ Summary Plugin/ImageResize.pm »