File Coverage

blib/lib/App/DBCritic/Violation.pm
Criterion Covered Total %
statement 32 32 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod n/a
total 42 42 100.0


line stmt bran cond sub pod time code
1             package App::DBCritic::Violation;
2              
3 5     5   38 use strict;
  5         109  
  5         153  
4 5     5   28 use utf8;
  5         7  
  5         33  
5 5     5   124 use Modern::Perl '2011'; ## no critic (Modules::ProhibitUseQuotedVersion)
  5         11  
  5         43  
6              
7             our $VERSION = '0.022'; # VERSION
8 5     5   3878 use Const::Fast;
  5         5794  
  5         38  
9 5     5   389 use English '-no_match_vars';
  5         10  
  5         29  
10 5     5   1592 use Moo;
  5         11  
  5         38  
11 5     5   2177 use Sub::Quote;
  5         10  
  5         530  
12 5     5   41 use overload q{""} => sub { shift->as_string };
  5     4   12  
  5         52  
  4         86  
13              
14             const my @TEXT_FIELDS => qw(description explanation details);
15             for (@TEXT_FIELDS) {
16             has $_ => ( is => 'ro', default => quote_sub q{q{}} );
17             }
18              
19             has element => ( is => 'ro' );
20             has as_string => ( is => 'ro', lazy => 1, default => \&_build_as_string );
21              
22             sub _build_as_string {
23 4     4   48 my $self = shift;
24 4         16 my $element = $self->element;
25 4         12 my $type = ref $element;
26              
27 4         25 $type =~ s/\A .* :://xms;
28 4         39 const my %TYPE_MAP => (
29             Table => $element->from,
30             ResultSet => $element->result_class,
31             Schema => 'schema',
32             );
33             return "[$type $TYPE_MAP{$type}] " . join "\n",
34 4         553 map { $self->$_ } @TEXT_FIELDS;
  12         78  
35             }
36              
37             1;
38              
39             # ABSTRACT: A violation of a App::DBCritic::Policy
40              
41             __END__