MongoDB/Op/_DropCollection.pm

filter: Statementstmt 67.5% 27 / 40 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 1 totaltotal 53.0% 35 / 66 CC 7 SCAR 32.8
CC
7
Cov
51%
execute
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 26.7
« MongoDB/BulkWrite.pm ↑ Summary MongoDB/Role/_DeprecationWarner.pm »
1 # Copyright 2016 - present MongoDB, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14  
15 59 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 59 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 package MongoDB::Op::_DropCollection;
18  
19 # Implements a collection drop; returns a MongoDB::CommandResult
20  
21 59 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 59 our $VERSION = 'v2.2.2';
23  
24 59 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 59 ▶use MongoDB::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 59 ▶use MongoDB::Op::_Command;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 59 ▶use Safe::Isa;
Subroutine BEGIN: called CC=1 SCAR=0.0
29 59 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 59 with $_ for qw(
32 MongoDB::Role::_PrivateConstructor
33 MongoDB::Role::_CollectionOp
34 MongoDB::Role::_WriteOp
35 );
36  
37 0 ▶sub execute {
Subroutine execute: not called CC=7 SCAR=40.3
Pod undocumented
38 0 my ( $self, $link ) = @_;
39  
40 my $op = MongoDB::Op::_Command->_new(
41 db_name => $self->db_name,
42 query => [
43 drop => $self->coll_name,
44 0 ▶ ( $link->supports_helper_write_concern ? ( @{ $self->write_concern->as_args } ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
$link->supports_helper_write_concern ? : 0 0 0
45 ],
46 query_flags => {},
47 bson_codec => $self->bson_codec,
48 session => $self->session,
49 monitoring_callback => $self->monitoring_callback,
50 );
51  
52 0 my $res;
53 eval {
54 0 $res = $op->execute($link);
55 0 $res->assert_no_write_concern_error;
56 0 1;
57 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $res = $op->execute($link); $res->assert_no_write_concern_error; 1 } } or do { my $error = $@ || "Unknown error"; if ($error->$MongoDB::Op::_DropCollection::_isa("MongoDB::DatabaseError")) { return undef if $error->code == 26 or $error->message =~ /^ns not found/; } ; die $error } 0 0 0
58 0 ▶ my $error = $@ || "Unknown error";
Condition0%0/2
$@ || 'Unknown error'
l!l
00
MC/DC0%0/1
$@ || 'Unknown error'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
59 0 ▶ if ( $error->$_isa("MongoDB::DatabaseError") ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error->$MongoDB::Op::_DropCollection::_isa("MongoDB::DatabaseError")) 0 0 0
60 0 ▶ return undef if $error->code == NAMESPACE_NOT_FOUND() || $error->message =~ /^ns not found/; ## no critic: make $res undef
Branch: 1 branch
BranchTrueFalseTotal
if $error->code == 26 or $error->message =~ /^ns not found/ 0 0 0
Condition0%0/3
$error->code == 26 or $error->message =~ /^ns not found/
l!l&&r!l&&!r
000
MC/DC0%0/2
$error->code == 26 or $error->message =~ /^ns not found/
$error->code == 26 $error->message =~ /^ns not found/
Truth table0%0/3
A or B
A= $error->code == 26B= $error->message =~ /^ns not found/
ABresult
1X1
011
000
61 }
62 0 die $error;
63 };
64  
65 0 return $res;
66 }
67  
68 59 1;
« MongoDB/BulkWrite.pm ↑ Summary MongoDB/Role/_DeprecationWarner.pm »