App/CSAF/Validator.pm untested

filter: Statementstmt 0.0% 0 / 62 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 100 CC 9 SCAR 37.8
CC
9
Cov
0%
run
90.0
BEGIN
2.0
BEGIN
2.0
CRAP 43.7
1 package App::CSAF::Validator;
2  
3 use 5.010001;
4 use strict;
5 use warnings;
6 use utf8;
7  
8 use Getopt::Long qw( GetOptionsFromArray :config gnu_compat );
9 use Pod::Usage;
10 use Carp;
11  
12 use CSAF;
13 use CSAF::Util::App qw(cli_error cli_version);
14 use CSAF::Parser;
15  
16 sub run {
17  
18 my ($class, @args) = @_;
19  
20 my %options = ();
21  
22 delete $ENV{CSAF_DEBUG};
23  
24 GetOptionsFromArray(
25 \@args, \%options, qw(
26 file|f=s
27  
28 help|h
29 man
30 version|v
31 )
32 ) or pod2usage(-verbose => 0);
33  
34 pod2usage(-exitstatus => 0, -verbose => 2) if defined $options{man};
35 pod2usage(-exitstatus => 0, -verbose => 0) if defined $options{help};
36  
37 return cli_version if defined $options{version};
38  
39 my $csaf_parser_options = {};
40  
41 # Detect input from STDIN
42 if (-p STDIN || -f STDIN) {
43 $csaf_parser_options->{content} = do { local $/; <STDIN> };
44 }
45  
46 if (defined $options{file}) {
47 $csaf_parser_options->{file} = $options{file};
48 }
49  
50 if (%{$csaf_parser_options}) {
51  
52 my $csaf = eval { CSAF::Parser->new(%{$csaf_parser_options})->parse };
53  
54 if ($@) {
55 cli_error($@);
56 return 255;
57 }
58  
59 if (my @errors = $csaf->validate) {
60 say STDERR $_ for (@errors);
61 return 1;
62 }
63  
64 say STDERR "CSAF Document valid";
65 return 0;
66  
67 }
68  
69 pod2usage(-verbose => 0);
70 return 0;
71  
72 }
73  
74 1;
75  
76 __END__