DMOSS/Plugin/VerifyLicense.pm

filter: Statementstmt 50.0% 21 / 42 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 6 / 12 Podpod 100% 6 / 6 totaltotal 45.8% 33 / 72 CC 7 SCAR 19.0
CC
7
Cov
39%
process
12.0
reduce
12.0
grade
12.0
CRAP 6.7
« DMOSS/Plugin/LinkValidator.pm ↑ Summary DMOSS/Attr.pm »
1 package DMOSS::Plugin::VerifyLicense;
2 1 $DMOSS::Plugin::VerifyLicense::VERSION = '0.01_2';
3 # ABSTRACT: DMOSS fix me description
4 1 ▶use parent qw/DMOSS::Plugin/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Software::License;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Software::LicenseUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use File::Slurp qw/read_file/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 our @types = qw/README LICENSE/;
14  
15 0 ▶sub name { 'Verify License' }
Subroutine name: not called CC=1 SCAR=6.9
Pod documented
16  
17 0 ▶sub process {
Subroutine process: not called CC=3 SCAR=24.8
Pod documented
18 0 my ($self, $dmoss, $file) = @_;
19 0 my $content = read_file $file->fullpath;
20 0 ▶ return unless $content =~ m/\b(licen[cs]e|licensing|copyright|legal)\b/;
Branch: 1 branch
BranchTrueFalseTotal
unless $content =~ /\b(licen[cs]e|licensing|copyright|legal)\b/ 0 0 0
21  
22 # guess license
23 0 $content = "=head1 license\n" . $content . "\n=cut";
24 0 my @guesses = Software::LicenseUtils->guess_license_from_pod($content);
25 0 my $top = shift @guesses;
26  
27 0 ▶ if ($top) {
Branch: 1 branch
BranchTrueFalseTotal
if ($top) 0 0 0
28 0 my $license = $top->name;
29 0 $dmoss->add_attr('license', $license);
30 }
31 }
32  
33 0 ▶sub reduce {
Subroutine reduce: not called CC=3 SCAR=24.8
Pod documented
34 0 my ($self, $dmoss, @attrs) = @_;
35 0 ▶ return unless @attrs;
Branch: 1 branch
BranchTrueFalseTotal
unless @attrs 0 0 0
36  
37 0 ▶ if (@attrs > 1) { # more than one license was found
Branch: 1 branch
BranchTrueFalseTotal
if (@attrs > 1) { } 0 0 0
38 # FIXME
39 }
40 else {
41 0 $dmoss->add_attr('license', $attrs[0]->value);
42 }
43 }
44  
45 0 ▶sub report {
Subroutine report: not called CC=1 SCAR=6.9
Pod documented
46 0 my ($self, $dmoss, $attr) = @_;
47  
48 0 return [ $attr->file->{path}, $attr->value ];
49 }
50  
51 0 ▶sub report_headers {
Subroutine report_headers: not called CC=1 SCAR=6.9
Pod documented
52 0 my ($self, $dmoss) = @_;
53  
54 0 return [ 'File', 'License' ];
55 }
56  
57 0 ▶sub grade {
Subroutine grade: not called CC=3 SCAR=24.8
Pod documented
58 0 my ($self, $dmoss, $attr) = @_;
59 0 ▶ return 0 unless $attr;
Branch: 1 branch
BranchTrueFalseTotal
unless $attr 0 0 0
60  
61 0 ▶ return ( $attr->value ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$attr->value ? : 0 0 0
62 }
63  
64 1 1;
65  
66 __END__
« DMOSS/Plugin/LinkValidator.pm ↑ Summary DMOSS/Attr.pm »