StackTrace/Type/Python.pm

filter: Statementstmt 100% 36 / 36 Branchbran 83.3% 5 / 6 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 7 / 7 Podpod 50.0% 1 / 2 totaltotal 96.7% 59 / 61 CC 6 SCAR 8.5
CC
6
Cov
98%
_handle_block
4.0
thread_number
2.0
_next_line_ends_frame
2.0
CRAP 2.3
« StackTrace/Thread.pm ↑ Summary StackTrace/Type/Python/Thread.pm »
1 package Parse::StackTrace::Type::Python;
2 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 2 extends 'Parse::StackTrace';
5  
6 2 our $VERSION = '0.08';
7  
8 2 ▶use constant HAS_TRACE => qr/^\s*File\s".+"(?:,|\s+in)/ms;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use constant EXCEPTION_REGEX => qr/
Subroutine BEGIN: called CC=1 SCAR=0.0
10 ^
11 (?:Exception \s Type:\s+)? # Django Format
12 \S*(?:Error|Exception) # Actual Exception
13 (?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django)
14 2 /x;
15  
16 10 ▶sub thread_number {
Subroutine thread_number: called CC=2 SCAR=6.9
Pod documented
17 10 my ($self, $number) = @_;
18 10 ▶ return $self->threads->[0] if $number == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $number == 1 5 5 10
19 5 return undef;
20 }
21  
22 67 ▶sub _handle_block {
Subroutine _handle_block: called CC=4 SCAR=13.9
23 67 my $class = shift;
24 67 my %params = @_;
25 my ($frame_lines, $current_thread, $lines, $end, $debug) =
26 67 @params{qw(frame_lines thread lines end_line_number debug)};
27 # If we run into the description of the exception, then we're done parsing
28 # the trace, provided that we've already parsed some frames.
29 67 my $first_line = $frame_lines->[0];
30 67 ▶ if (scalar @{ $current_thread->frames } and $first_line =~ EXCEPTION_REGEX) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$current_thread->frames;} and $first_line =~ / ^ (?:Exception \s Type:\s+)? # Django Format \S*(?:Error|Exception) # Actual Exception (?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django) /x) 5 62 67
Condition100%3/3
scalar @{$current_thread->frames;} and $first_line =~ / ^ (?:Exception \s Type:\s+)? # Django Format \S*(?:Error|Exception) # Actual Exception (?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django) /x
!ll&&!rl&&r
45175
MC/DC100%2/2
scalar @{$current_thread->frames;} and $first_line =~ / ^ (?:Exception \s Type:\s+)? # Django Format \S*(?:Error|Exception) # Actual Exception (?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django) /x
scalar @{$current_thread->frames;} $first_line =~ / ^ (?:Exception \s Type:\s+)? # Django Format \S*(?:Error|Exception) # Actual Exception (?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django) /x
Truth table100%3/3
A and B
A= scalar @{$current_thread->frames;}B= $first_line =~ / ^ (?:Exception \s Type:\s+)? # Django Format \S*(?:Error|Exception) # Actual Exception (?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django) /x
ABresult
0X0
100
111
31 5 $current_thread->{description} = trim($first_line);
32 5 ▶ print STDERR "Thread Exception: $first_line\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 5 5
33 5 pop @$frame_lines;
34 # Don't parse anymore.
35 5 @$lines = ();
36 5 $current_thread->ending_line($end);
37 5 return $current_thread;
38 }
39
40 62 return $class->SUPER::_handle_block(@_);
41 }
42  
43 53 ▶sub _next_line_ends_frame {
Subroutine _next_line_ends_frame: called CC=2 SCAR=6.9
44 53 my $class = shift;
45 53 my ($line) = @_;
46 53 ▶ return ($class->SUPER::_next_line_ends_frame(@_)
Condition100%3/3
$class->SUPER::_next_line_ends_frame(@_) || $line =~ / ^ (?:Exception \s Type:\s+)? # Django Format \S*(?:Error|Exception) # Actual Exception (?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django) /x
l!l&&r!l&&!r
18431
MC/DC100%2/2
$class->SUPER::_next_line_ends_frame(@_) || $line =~ / ^ (?:Exception \s Type:\s+)? # Django Format \S*(?:Error|Exception) # Actual Exception (?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django) /x
$class->SUPER::_next_line_ends_frame(@_) $line =~ / ^ (?:Exception \s Type:\s+)? # Django Format \S*(?:Error|Exception) # Actual Exception (?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django) /x
Truth table100%3/3
A || B
A= $class->SUPER::_next_line_ends_frame(@_)B= $line =~ / ^ (?:Exception \s Type:\s+)? # Django Format \S*(?:Error|Exception) # Actual Exception (?::\s+)|(?:\s+at\b) # Colon (normal python) or "at" (Django) /x
ABresult
1X1
011
000
47 or $line =~ EXCEPTION_REGEX);
48 }
49  
50 5 ▶sub trim {
Subroutine trim: called CC=1 SCAR=0.0
Pod undocumented
51 5 my $str = shift;
52 5 $str =~ s/^s*//;
53 5 $str =~ s/\s*$//;
54 5 return $str;
55 }
56  
57 2 __PACKAGE__->meta->make_immutable;
58  
59 2 1;
60  
61 __END__
« StackTrace/Thread.pm ↑ Summary StackTrace/Type/Python/Thread.pm »