Helper/Schema/DidYouMean.pm

filter: Statementstmt 96.5% 28 / 29 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 95.3% 41 / 43 CC 3 SCAR 4.5
CC
3
Cov
94%
__ANON__
3.1
source
1.0
BEGIN
1.0
CRAP 1.6
« Helper/Schema/Verifier/RelationshipColumnName.pm ↑ Summary Helper/Schema/Verifier/Parent.pm »
1 package DBIx::Class::Helper::Schema::DidYouMean;
2 56 $DBIx::Class::Helper::Schema::DidYouMean::VERSION = '2.037000';
3 # ABSTRACT: Nice error messages when you misspell the name of a ResultSet
4  
5 56 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 56 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 56 ▶use parent 'DBIx::Class::Schema';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 56 ▶use Text::Brew 'distance';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 56 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 56 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1978 ▶sub source {
Subroutine source: called CC=1 SCAR=0.0
Pod documented
15 1978 my ($self, @rest) = @_;
16  
17 1978 my $method = $self->next::can;
18  
19 1978 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
20 1978 $self->$method(@rest)
21 1 ▶ } catch {
Subroutine __ANON__: called CC=3 SCAR=11.3
22 1 ▶ if (m/Can't find source for (.+?) at/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/Can't find source for (.+?) at/) 1 0 1
23 my @presentsources = map {
24 1 ▶ (distance($_, $1))[0] < 3 ? " * $_ <-- Possible Match\n" : " $_\n";
Branch: 1 branch
BranchTrueFalseTotal
(distance($_, $1))[0] < 3 ? : 1 10 11
25 } sort $self->storage->schema->sources;
26  
27 1 die <<"ERR";
28 $_
29 The ResultSet "$1" is not part of your schema.
30  
31 To help you debug this issue, here's a list of the actual sources that the
32 schema knows about:
33  
34 @presentsources
35 ERR
36 }
37 0 die $_;
38 }
39 1978 }
40  
41 56 1;
42  
43 __END__
« Helper/Schema/Verifier/RelationshipColumnName.pm ↑ Summary Helper/Schema/Verifier/Parent.pm »