File Coverage

blib/lib/App/DBCritic/Policy/NoPrimaryKey.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 24 24 100.0


line stmt bran cond sub pod time code
1             package App::DBCritic::Policy::NoPrimaryKey;
2              
3 5     5   3665 use strict;
  5         11  
  5         160  
4 5     5   27 use utf8;
  5         11  
  5         29  
5 5     5   131 use Modern::Perl '2011'; ## no critic (Modules::ProhibitUseQuotedVersion)
  5         10  
  5         30  
6              
7             our $VERSION = '0.022'; # VERSION
8 5     5   717 use Moo;
  5         12  
  5         34  
9 5     5   1809 use Sub::Quote;
  5         20  
  5         457  
10 5     5   40 use namespace::autoclean -also => qr{\A _}xms;
  5         20  
  5         47  
11              
12             has description => ( is => 'ro', default => quote_sub q{'No primary key'} );
13             has explanation => (
14             is => 'ro',
15             default => quote_sub
16             q{'Tables should have one or more columns defined as a primary key.'},
17             );
18              
19             sub violates {
20             my $source = shift->element;
21             return $source->name . ' has no primary key' if !$source->primary_columns;
22             return;
23             }
24              
25             with 'App::DBCritic::PolicyType::ResultSource';
26             1;
27              
28             # ABSTRACT: Check for DBIx::Class::Schema::ResultSources without primary keys
29              
30             __END__