File: | lib/Code/Statistics/Metric.pm |
Coverage: | 90.6% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | 1 1 1 | 0 0 0 | use strict; | ||||
2 | 1 1 1 | 0 0 0 | use warnings; | ||||
3 | |||||||
4 | package Code::Statistics::Metric; | ||||||
5 | |||||||
6 | # ABSTRACT: base class for Code::Statistic metrics | ||||||
7 | |||||||
8 | 1 1 1 | 0 0 0 | use 5.004; | ||||
9 | |||||||
10 | 1 1 1 | 0 0 0 | use Module::Pluggable search_path => __PACKAGE__, require => 1, sub_name => 'all'; | ||||
11 | |||||||
12 - 18 | =head2 measure Returns the metric of the given target. Is called with the metric class name and a target object of unspecified type. This function should be overridden with specific logic to actually retrieve the metric data. =cut | ||||||
19 | |||||||
20 | sub measure { | ||||||
21 | 0 | 0 | my ( $class, $target ) = @_; | ||||
22 | 0 | 0 | return; | ||||
23 | } | ||||||
24 | |||||||
25 - 30 | =head2 incompatible_with Returns true if the given target is explicitly not supported by this metric. Is called with the metric class name and a string representing the target identifiers after 'Code::Statistics::Target::'. Default is that all metrics are compatible with all targets. =cut | ||||||
31 | |||||||
32 | sub incompatible_with { | ||||||
33 | 120 | 0 | my ( $class, $target ) = @_; | ||||
34 | 120 | 0 | return 0; | ||||
35 | } | ||||||
36 | |||||||
37 - 45 | =head2 force_support Returns true if the given target is forcibly supported by this metric. Is called with the metric class name and a string representing the target identifiers after 'Code::Statistics::Target::'. Default is that no forcing happens. Has higher precedence than 'incompatible_with' and should be used to override incompatibilities set by other targets. =cut | ||||||
46 | |||||||
47 | sub force_support { | ||||||
48 | 168 | 0 | my ( $class, $target ) = @_; | ||||
49 | 168 | 0 | return 0; | ||||
50 | } | ||||||
51 | |||||||
52 - 57 | =head2 short_name Allows a metric to return a short name, which can be used by shell report builders for example. Default is the class name, with 'Code::Statistics::Metric::' stripped out. Override to customize. =cut | ||||||
58 | |||||||
59 | sub short_name { | ||||||
60 | 84 | 0 | my ( $class ) = @_; | ||||
61 | 84 | 0 | $class =~ s/Code::Statistics::Metric:://; | ||||
62 | 84 | 0 | return $class; | ||||
63 | } | ||||||
64 | |||||||
65 - 68 | =head2 is_insignificant Returns true if the metric is considered statistically insignificant. Default is false. =cut | ||||||
69 | |||||||
70 | sub is_insignificant { | ||||||
71 | 9 | 0 | my ( $class ) = @_; | ||||
72 | 9 | 0 | return 0; | ||||
73 | } | ||||||
74 | |||||||
75 | 1; |