Treex/Core/Common.pm

filter: Statementstmt 97.1% 69 / 71 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 19 / 19 Podpod 100% 1 / 1 totaltotal 94.1% 96 / 102 CC 4 SCAR 4.4
CC
4
Cov
95%
pos_validated_list
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« Treex/Core/WildAttr.pm ↑ Summary Treex/Block/Read/Text.pm »
1 package Treex::Core::Common;
2 70 $Treex::Core::Common::VERSION = '2.20210102';
3 70 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 70 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 70 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 70 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 70 ▶use Moose::Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 70 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 70 ▶use MooseX::SemiAffordanceAccessor::Role::Attribute 0.09;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 70 ▶use Treex::Core::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 70 ▶use Treex::Core::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 70 ▶use Treex::Core::Resource;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 70 ▶use Treex::Core::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 70 ▶use Treex::Core::Files;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 70 ▶use List::MoreUtils;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 70 ▶use List::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 70 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 70 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 70 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 # sub reference for validating of params
23 # Sets default values for unspecified params
24 70 my $validation_sub;
25  
26 # Quick alternative for MooseX::Params::Validate::pos_validated_list
27 3585 ▶sub pos_validated_list {
Subroutine pos_validated_list: called CC=4 SCAR=13.9
Pod documented
28 3585 my $args_ref = shift;
29 3585 my @args = @{$args_ref};
30 3585 my $i = 0;
31 3585 ▶ while ( ref $_[0] eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq "HASH") 4314 3585 7899
32 4314 my $spec = shift;
33 4314 ▶ if ( defined $spec->{default} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $spec->{"default"}) 135 4179 4314
34 135 ▶ $args[$i] //= $spec->{default};
Condition66%2/3
$args[$i] //= $spec->{"default"}
l!l&&r!l&&!r
90450
MC/DC0%0/2
$args[$i] //= $spec->{"default"}
$args[$i] $spec->{"default"}
Truth table66%2/3
A //= B
A= $args[$i]B= $spec->{"default"}
ABresult
1X1
011
000
35 }
36 4314 $i++;
37 }
38 3585 return @args;
39 }
40  
41 # Choose which variant to use according to $Treex::Core::Config::params_validate
42 70 ▶if ( $Treex::Core::Config::params_validate == 2 ) { ## no critic (ProhibitPackageVars)
Branch: 1 branch
BranchTrueFalseTotal
if ($Treex::Core::Config::params_validate == 2) { } 0 70 70
43 0 require MooseX::Params::Validate;
44 0 $validation_sub = \&MooseX::Params::Validate::pos_validated_list;
45 }
46 else {
47 70 $validation_sub = \&pos_validated_list;
48 }
49  
50 70 my ( $import, $unimport, $init_meta ) =
51 Moose::Exporter->build_import_methods(
52 install => [qw(unimport init_meta)],
53 class_metaroles => { attribute => ['MooseX::SemiAffordanceAccessor::Role::Attribute'] },
54 as_is => [
55 \&Treex::Core::Log::log_fatal,
56 \&Treex::Core::Log::log_warn,
57 \&Treex::Core::Log::log_debug,
58 \&Treex::Core::Log::log_set_error_level,
59 \&Treex::Core::Log::log_info,
60 \&Treex::Core::Types::get_lang_name,
61 \&Treex::Core::Types::is_lang_code,
62 \&Treex::Core::Resource::require_file_from_share,
63 \&List::MoreUtils::first_index,
64 \&List::MoreUtils::all,
65 \&List::MoreUtils::any,
66 \&List::MoreUtils::none,
67 \&List::MoreUtils::uniq,
68 \&List::Util::first,
69 \&List::Util::min,
70 \&List::Util::max,
71 \&Readonly::Readonly,
72 \&Scalar::Util::weaken,
73 \&Data::Dumper::Dumper,
74 \&Moose::Util::TypeConstraints::enum,
75 $validation_sub,
76 ]
77 );
78  
79 457 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
80 457 feature->import(':5.10');
81 457 utf8::import();
82 457 goto &$import;
83 }
84  
85 70 1;
86  
87 __END__
« Treex/Core/WildAttr.pm ↑ Summary Treex/Block/Read/Text.pm »