File Coverage

blib/lib/App/DBCritic/Policy/BidirectionalRelationship.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 28 28 100.0


line stmt bran cond sub pod time code
1             package App::DBCritic::Policy::BidirectionalRelationship;
2              
3 5     5   3571 use strict;
  5         19  
  5         198  
4 5     5   31 use utf8;
  5         12  
  5         64  
5 5     5   144 use Modern::Perl '2011'; ## no critic (Modules::ProhibitUseQuotedVersion)
  5         11  
  5         33  
6              
7             our $VERSION = '0.022'; # VERSION
8 5     5   703 use English '-no_match_vars';
  5         11  
  5         34  
9 5     5   1881 use Moo;
  5         14  
  5         38  
10 5     5   2084 use Sub::Quote;
  5         22  
  5         503  
11 5     5   40 use namespace::autoclean -also => qr{\A _}xms;
  5         11  
  5         51  
12              
13             has description => (
14             is => 'ro',
15             default => quote_sub q{'Missing bidirectional relationship'},
16             );
17             has explanation => (
18             is => 'ro',
19             default => quote_sub
20             q{'Related tables should have relationships defined in both classes.'},
21             );
22              
23             sub violates {
24             my $source = shift->element;
25              
26             return join "\n",
27             map { _message( $source->name, $source->related_source($_)->name ) }
28             grep { !keys %{ $source->reverse_relationship_info($_) } }
29             $source->relationships;
30             }
31              
32             sub _message { return "$_[0] to $_[1] not reciprocated" }
33              
34             with 'App::DBCritic::PolicyType::ResultSource';
35             1;
36              
37             # ABSTRACT: Check for missing bidirectional relationships in ResultSources
38              
39             __END__