Cme/Command/check.pm

filter: Statementstmt 88.8% 40 / 45 Branchbran 66.6% 8 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 100% 5 / 5 totaltotal 86.4% 64 / 74 CC 7 SCAR 13.1
CC
7
Cov
84%
execute
7.9
description
2.0
BEGIN
1.0
CRAP 3.7
« Cme/Command/modify.pm ↑ Summary Cme/Command/shell.pm »
1 #
2 # This file is part of App-Cme
3 #
4 # This software is Copyright (c) 2014-2022 by Dominique Dumont <ddumont@cpan.org>.
5 #
6 # This is free software, licensed under:
7 #
8 # The GNU Lesser General Public License, Version 2.1, February 1999
9 #
10 # ABSTRACT: Check the configuration of an application
11  
12 package App::Cme::Command::check ;
13 1 $App::Cme::Command::check::VERSION = '1.049';
14 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use 5.10.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 ▶use App::Cme -command ;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶use base qw/App::Cme::Common/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use Config::Model::ObjTreeScanner;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 2 ▶sub validate_args {
Subroutine validate_args: called CC=1 SCAR=0.0
Pod documented
25 2 my ($self, $opt, $args) = @_;
26  
27 2 $self->check_unknown_args($args);
28 2 $self->process_args($opt,$args);
29 2 return;
30 }
31  
32 2 ▶sub opt_spec {
Subroutine opt_spec: called CC=1 SCAR=0.0
Pod documented
33 2 my ( $class, $app ) = @_;
34 return (
35 2 [ "strict!" => "cme will exit 1 if warnings are found during check" ],
36 $class->cme_global_options,
37 );
38 }
39  
40 2 ▶sub usage_desc {
Subroutine usage_desc: called CC=1 SCAR=0.0
Pod documented
41 2 my ($self) = @_;
42 2 my $desc = $self->SUPER::usage_desc; # "%c COMMAND %o"
43 2 return "$desc [application] [ config_file ]";
44 }
45  
46 0 ▶sub description {
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
47 0 my ($self) = @_;
48 0 return $self->get_documentation;
49 }
50  
51 2 ▶sub execute {
Subroutine execute: called CC=7 SCAR=20.6
Pod documented
52 2 my ($self, $opt, $args) = @_;
53  
54 2 my ($model, $inst, $root) = $self->init_cme($opt,$args);
55 2 ▶ my $check = $opt->{force_load} ? 'no' : 'yes' ;
Branch: 1 branch
BranchTrueFalseTotal
$opt->{'force_load'} ? : 0 2 2
56 2 ▶ say "Loading data..." if $opt->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->{"verbose"} 1 1 2
57  
58 Config::Model::ObjTreeScanner->new(
59 18 ▶ leaf_cb => sub { },
Subroutine __ANON__: called CC=1 SCAR=0.0
60 2 check => $check,
61 )->scan_node( undef, $root );
62  
63 2 ▶ say "Checking data.." if $opt->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->{"verbose"} 1 1 2
64 2 $root->dump_tree( mode => 'full' ); # light check (value per value)
65 2 $root->deep_check; # consistency check
66 2 ▶ say "Check done." if $opt->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->{"verbose"} 1 1 2
67  
68 2 my $ouch = $inst->has_warning;
69  
70 2 ▶ if ( $ouch ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ouch) 0 2 2
71 0 my $app = $inst->application;
72 0 warn "you can try 'cme fix $app' to fix the warnings shown above\n";
73 0 ▶ die "Found $ouch warnings in strict mode\n" if $opt->{strict};
Branch: 1 branch
BranchTrueFalseTotal
if $opt->{"strict"} 0 0 0
74 }
75  
76 2 return;
77 }
78  
79 1 1;
80  
81 __END__
« Cme/Command/modify.pm ↑ Summary Cme/Command/shell.pm »