| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::DBCritic::Violation; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: A violation of a App::DBCritic::Policy |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
#pod |
|
7
|
|
|
|
|
|
|
#pod use App::DBCritic::Violation; |
|
8
|
|
|
|
|
|
|
#pod |
|
9
|
|
|
|
|
|
|
#pod my $violation = App::DBCritic::Violation->new( |
|
10
|
|
|
|
|
|
|
#pod description => 'Violated policy', |
|
11
|
|
|
|
|
|
|
#pod explanation => 'Consult the rulebook', |
|
12
|
|
|
|
|
|
|
#pod description => 'The frob table is improperly swizzled.', |
|
13
|
|
|
|
|
|
|
#pod ); |
|
14
|
|
|
|
|
|
|
#pod print "$violation\n"; |
|
15
|
|
|
|
|
|
|
#pod |
|
16
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
17
|
|
|
|
|
|
|
#pod |
|
18
|
|
|
|
|
|
|
#pod This class represents L |
|
19
|
|
|
|
|
|
|
#pod violations flagged by L. |
|
20
|
|
|
|
|
|
|
#pod |
|
21
|
|
|
|
|
|
|
#pod =cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
5
|
|
|
5
|
|
36
|
use strict; |
|
|
5
|
|
|
|
|
114
|
|
|
|
5
|
|
|
|
|
141
|
|
|
24
|
5
|
|
|
5
|
|
26
|
use utf8; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
24
|
|
|
25
|
5
|
|
|
5
|
|
112
|
use Modern::Perl '2011'; ## no critic (Modules::ProhibitUseQuotedVersion) |
|
|
5
|
|
|
|
|
18
|
|
|
|
5
|
|
|
|
|
42
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our $VERSION = '0.023'; # VERSION |
|
28
|
5
|
|
|
5
|
|
3646
|
use Const::Fast; |
|
|
5
|
|
|
|
|
5674
|
|
|
|
5
|
|
|
|
|
34
|
|
|
29
|
5
|
|
|
5
|
|
418
|
use English '-no_match_vars'; |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
29
|
|
|
30
|
5
|
|
|
5
|
|
1545
|
use Moo; |
|
|
5
|
|
|
|
|
12
|
|
|
|
5
|
|
|
|
|
36
|
|
|
31
|
5
|
|
|
5
|
|
2172
|
use Sub::Quote; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
452
|
|
|
32
|
5
|
|
|
5
|
|
32
|
use overload q{""} => sub { shift->as_string }; |
|
|
5
|
|
|
4
|
|
11
|
|
|
|
5
|
|
|
|
|
51
|
|
|
|
4
|
|
|
|
|
87
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
const my @TEXT_FIELDS => qw(description explanation details); |
|
35
|
|
|
|
|
|
|
for (@TEXT_FIELDS) { |
|
36
|
|
|
|
|
|
|
has $_ => ( is => 'ro', default => quote_sub q{q{}} ); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#pod =attr description |
|
40
|
|
|
|
|
|
|
#pod |
|
41
|
|
|
|
|
|
|
#pod A short string briefly describing what's wrong. |
|
42
|
|
|
|
|
|
|
#pod Only settable at construction. |
|
43
|
|
|
|
|
|
|
#pod |
|
44
|
|
|
|
|
|
|
#pod =attr explanation |
|
45
|
|
|
|
|
|
|
#pod |
|
46
|
|
|
|
|
|
|
#pod A string giving a longer general description of the problem. |
|
47
|
|
|
|
|
|
|
#pod Only settable at construction. |
|
48
|
|
|
|
|
|
|
#pod |
|
49
|
|
|
|
|
|
|
#pod =attr details |
|
50
|
|
|
|
|
|
|
#pod |
|
51
|
|
|
|
|
|
|
#pod A string describing the issue as it specifically applies to the L |
|
52
|
|
|
|
|
|
|
#pod being critiqued. |
|
53
|
|
|
|
|
|
|
#pod |
|
54
|
|
|
|
|
|
|
#pod =cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has element => ( is => 'ro' ); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#pod =attr element |
|
59
|
|
|
|
|
|
|
#pod |
|
60
|
|
|
|
|
|
|
#pod The schema element that violated a |
|
61
|
|
|
|
|
|
|
#pod L. |
|
62
|
|
|
|
|
|
|
#pod Only settable at construction. |
|
63
|
|
|
|
|
|
|
#pod |
|
64
|
|
|
|
|
|
|
#pod =cut |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
has as_string => ( is => 'ro', lazy => 1, default => \&_build_as_string ); |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub _build_as_string { |
|
69
|
4
|
|
|
4
|
|
81
|
my $self = shift; |
|
70
|
4
|
|
|
|
|
18
|
my $element = $self->element; |
|
71
|
4
|
|
|
|
|
13
|
my $type = ref $element; |
|
72
|
|
|
|
|
|
|
|
|
73
|
4
|
|
|
|
|
22
|
$type =~ s/\A .* :://xms; |
|
74
|
4
|
|
|
|
|
37
|
const my %TYPE_MAP => ( |
|
75
|
|
|
|
|
|
|
Table => $element->from, |
|
76
|
|
|
|
|
|
|
ResultSet => $element->result_class, |
|
77
|
|
|
|
|
|
|
Schema => 'schema', |
|
78
|
|
|
|
|
|
|
); |
|
79
|
|
|
|
|
|
|
return "[$type $TYPE_MAP{$type}] " . join "\n", |
|
80
|
4
|
|
|
|
|
544
|
map { $self->$_ } @TEXT_FIELDS; |
|
|
12
|
|
|
|
|
79
|
|
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
#pod =attr as_string |
|
84
|
|
|
|
|
|
|
#pod |
|
85
|
|
|
|
|
|
|
#pod Returns a string representation of the object. The same method is called if |
|
86
|
|
|
|
|
|
|
#pod the object appears in double quotes. |
|
87
|
|
|
|
|
|
|
#pod |
|
88
|
|
|
|
|
|
|
#pod =cut |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |