| 1 | ## no critic (ProhibitMultiplePackages, RequireExplicitPackage) | ||||||||||||
| 2 | |||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | package Gherkin::Exceptions; | ||||||||||||
| 7 | 2 | $Gherkin::Exceptions::VERSION = '42.0.1'; | |||||||||||
| 8 | 0 | ▶ | sub stringify { my $self = shift; $self->message } | ||||||||||
|
Subroutine
stringify: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 9 | 0 | ▶ | sub throw { my $class = shift; die $class->new(@_) } | ||||||||||
|
Subroutine
throw: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 10 | |||||||||||||
| 11 | # Parent of single and composite exceptions | ||||||||||||
| 12 | package Gherkin::Exceptions::Parser; | ||||||||||||
| 13 | 2 | $Gherkin::Exceptions::Parser::VERSION = '42.0.1'; | |||||||||||
| 14 | 2 | ▶ | use base 'Gherkin::Exceptions'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | |||||||||||||
| 16 | # Composite exceptions | ||||||||||||
| 17 | package Gherkin::Exceptions::CompositeParser; | ||||||||||||
| 18 | 2 | $Gherkin::Exceptions::CompositeParser::VERSION = '42.0.1'; | |||||||||||
| 19 | 2 | ▶ | use base 'Gherkin::Exceptions::Parser'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | 2 | ▶ | use Class::XSAccessor accessors => [qw/errors/]; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 21 | |||||||||||||
| 22 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||
| 23 | 0 | my ( $class, @errors ) = @_; | |||||||||||
| 24 | 0 | bless { errors => \@errors }, $class; | |||||||||||
| 25 | } | ||||||||||||
| 26 | |||||||||||||
| 27 | 0 | ▶ | sub message { | ||||||||||
|
Subroutine
message: not called CC=1 SCAR=6.9
| |||||||||||||
| 28 | 0 | my $self = shift; | |||||||||||
| 29 | return join "\n", | ||||||||||||
| 30 | 0 | ( 'Parser errors:', map { $_->message } @{ $self->errors } ); | |||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | 0 | ▶ | sub throw { my $class = shift; die $class->new(@_) } | ||||||||||
|
Subroutine
throw: not called CC=1 SCAR=6.9
| |||||||||||||
| 34 | |||||||||||||
| 35 | # | ||||||||||||
| 36 | # Various non-composite exceptions | ||||||||||||
| 37 | # | ||||||||||||
| 38 | package Gherkin::Exceptions::SingleParser; | ||||||||||||
| 39 | 2 | $Gherkin::Exceptions::SingleParser::VERSION = '42.0.1'; | |||||||||||
| 40 | 2 | ▶ | use base 'Gherkin::Exceptions::Parser'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 41 | 2 | ▶ | use Class::XSAccessor accessors => [qw/detailed_message location/]; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 42 | |||||||||||||
| 43 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||
| 44 | 0 | my ( $class, %args ) = @_; | |||||||||||
| 45 | 0 | bless { %args }, $class; | |||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | 0 | ▶ | sub message { | ||||||||||
|
Subroutine
message: not called CC=2 SCAR=17.9
| |||||||||||||
| 49 | 0 | my $self = shift; | |||||||||||
| 50 | return sprintf( '(%i:%i): %s', | ||||||||||||
| 51 | $self->location->{'line'}, | ||||||||||||
| 52 | 0 | ▶ | ( $self->location->{'column'} || 0 ), | ||||||||||
|
Condition0%0/2
$self->location->{'column'} || 0
MC/DC0%0/1
$self->location->{'column'} || 0
$self->location->{'column'}
Truth table0%0/2
A
A= $self->location->{'column'}
| |||||||||||||
| 53 | $self->detailed_message ); | ||||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | package Gherkin::Exceptions::NoSuchLanguage; | ||||||||||||
| 57 | 2 | $Gherkin::Exceptions::NoSuchLanguage::VERSION = '42.0.1'; | |||||||||||
| 58 | 2 | ▶ | use base 'Gherkin::Exceptions::SingleParser'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 59 | 2 | ▶ | use Class::XSAccessor accessors => [qw/language location/]; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 60 | |||||||||||||
| 61 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||
| 62 | 0 | my ( $class, $language, $location ) = @_; | |||||||||||
| 63 | 0 | return bless { language => $language, location => $location }, $class; | |||||||||||
| 64 | } | ||||||||||||
| 65 | |||||||||||||
| 66 | 0 | ▶ | sub detailed_message { | ||||||||||
|
Subroutine
detailed_message: not called CC=1 SCAR=6.9
| |||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||
| 68 | 0 | return "Language not supported: " . $self->language; | |||||||||||
| 69 | } | ||||||||||||
| 70 | |||||||||||||
| 71 | package Gherkin::Exceptions::AstBuilder; | ||||||||||||
| 72 | 2 | $Gherkin::Exceptions::AstBuilder::VERSION = '42.0.1'; | |||||||||||
| 73 | 2 | ▶ | use base 'Gherkin::Exceptions::SingleParser'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 74 | 2 | ▶ | use Class::XSAccessor accessors => [qw/location ast_message/]; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 75 | |||||||||||||
| 76 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||
| 77 | 0 | my ( $class, $ast_message, $location ) = @_; | |||||||||||
| 78 | 0 | return bless { ast_message => $ast_message, location => $location }, | |||||||||||
| 79 | $class; | ||||||||||||
| 80 | } | ||||||||||||
| 81 | |||||||||||||
| 82 | 0 | ▶ | sub detailed_message { | ||||||||||
|
Subroutine
detailed_message: not called CC=1 SCAR=6.9
| |||||||||||||
| 83 | 0 | my $self = shift; | |||||||||||
| 84 | 0 | return $self->ast_message; | |||||||||||
| 85 | } | ||||||||||||
| 86 | |||||||||||||
| 87 | package Gherkin::Exceptions::UnexpectedEOF; | ||||||||||||
| 88 | 2 | $Gherkin::Exceptions::UnexpectedEOF::VERSION = '42.0.1'; | |||||||||||
| 89 | 2 | ▶ | use base 'Gherkin::Exceptions::SingleParser'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 90 | 2 | ▶ | use Class::XSAccessor accessors => [qw/location expected_token_types/]; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 91 | |||||||||||||
| 92 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||
| 93 | 0 | my ( $class, $received_token, $expected_token_types ) = @_; | |||||||||||
| 94 | 0 | return bless { | |||||||||||
| 95 | location => $received_token->location, | ||||||||||||
| 96 | received_token => $received_token, | ||||||||||||
| 97 | expected_token_types => $expected_token_types | ||||||||||||
| 98 | }, $class; | ||||||||||||
| 99 | } | ||||||||||||
| 100 | |||||||||||||
| 101 | 0 | ▶ | sub detailed_message { | ||||||||||
|
Subroutine
detailed_message: not called CC=1 SCAR=6.9
| |||||||||||||
| 102 | 0 | my $self = shift; | |||||||||||
| 103 | return "unexpected end of file, expected: " . join ', ', | ||||||||||||
| 104 | 0 | @{ $self->expected_token_types }; | |||||||||||
| 105 | } | ||||||||||||
| 106 | |||||||||||||
| 107 | package Gherkin::Exceptions::UnexpectedToken; | ||||||||||||
| 108 | 2 | $Gherkin::Exceptions::UnexpectedToken::VERSION = '42.0.1'; | |||||||||||
| 109 | 2 | ▶ | use base 'Gherkin::Exceptions::SingleParser'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 110 | 2 | ▶ | use Class::XSAccessor accessors => | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 111 | 2 | [qw/location received_token_value expected_token_types state_comment/]; | |||||||||||
| 112 | |||||||||||||
| 113 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
| |||||||||||||
| 114 | 0 | my ( $class, $received_token, $expected_token_types, $state_comment ) | |||||||||||
| 115 | = @_; | ||||||||||||
| 116 | |||||||||||||
| 117 | 0 | my $received_token_value = $received_token->token_value; | |||||||||||
| 118 | 0 | $received_token_value =~ s/^\s+//; | |||||||||||
| 119 | 0 | $received_token_value =~ s/\s+$//; | |||||||||||
| 120 | |||||||||||||
| 121 | 0 | my %location = %{ $received_token->location }; | |||||||||||
| 122 | $location{'column'} = $received_token->line->indent + 1 | ||||||||||||
| 123 | 0 | ▶ | unless defined $location{'column'}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 124 | |||||||||||||
| 125 | 0 | return bless { | |||||||||||
| 126 | location => \%location, | ||||||||||||
| 127 | received_token_value => $received_token_value, | ||||||||||||
| 128 | expected_token_types => $expected_token_types, | ||||||||||||
| 129 | state_comment => $state_comment, | ||||||||||||
| 130 | }, $class; | ||||||||||||
| 131 | } | ||||||||||||
| 132 | |||||||||||||
| 133 | 0 | ▶ | sub detailed_message { | ||||||||||
|
Subroutine
detailed_message: not called CC=1 SCAR=6.9
| |||||||||||||
| 134 | 0 | my $self = shift; | |||||||||||
| 135 | return sprintf( | ||||||||||||
| 136 | "expected: %s, got '%s'", | ||||||||||||
| 137 | 0 | ( join ', ', @{ $self->expected_token_types } ), | |||||||||||
| 138 | $self->received_token_value, | ||||||||||||
| 139 | ); | ||||||||||||
| 140 | } | ||||||||||||
| 141 | |||||||||||||
| 142 | 2 | 1; | |||||||||||