| File: | lib/Code/Statistics/Metric.pm |
| Coverage: | 82.9% |
| line | stmt | bran | cond | sub | pod | time | code |
|---|---|---|---|---|---|---|---|
| 1 | 2 2 2 | 0 0 0 | use strict; | ||||
| 2 | 2 2 2 | 0 0 0 | use warnings; | ||||
| 3 | |||||||
| 4 | package Code::Statistics::Metric; | ||||||
| 5 | |||||||
| 6 | # ABSTRACT: base class for Code::Statistic metrics | ||||||
| 7 | |||||||
| 8 | 2 2 2 | 0 0 0 | use 5.004; | ||||
| 9 | |||||||
| 10 | 2 2 2 | 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 | 240 | 0 | my ( $class, $target ) = @_; | ||||
| 34 | 240 | 0 | return 0; | ||||
| 35 | } | ||||||
| 36 | |||||||
| 37 - 45 | =head2 supports
Returns true if the given target is 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.
Has higher precedence than 'incompatible_with' and should be used to
incompatibilities set by other targets.
=cut | ||||||
| 46 | |||||||
| 47 | sub supports { | ||||||
| 48 | 240 | 0 | my ( $class, $target ) = @_; | ||||
| 49 | 240 | 0 | return 0; | ||||
| 50 | } | ||||||
| 51 | |||||||
| 52 - 57 | =head2 column_name
Allows a metric to return a column 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 column_name { | ||||||
| 60 | 108 | 0 | my ( $class ) = @_; | ||||
| 61 | 108 | 0 | $class =~ s/Code::Statistics::Metric:://; | ||||
| 62 | 108 | 0 | return $class; | ||||
| 63 | } | ||||||
| 64 | |||||||
| 65 - 67 | =head2 is_type
Returns a Moose type as in Moose::Manual::Types. Default is 'Num'.
=cut | ||||||
| 68 | |||||||
| 69 | sub is_type { | ||||||
| 70 | 0 | 0 | my ( $class ) = @_; | ||||
| 71 | 0 | 0 | return 'Num'; | ||||
| 72 | } | ||||||
| 73 | |||||||
| 74 - 76 | =head2 is_significant
Returns true if the metric is considered statistically significant.
=cut | ||||||
| 77 | |||||||
| 78 | sub is_significant { | ||||||
| 79 | 18 | 0 | my ( $class ) = @_; | ||||
| 80 | 18 | 0 | return 1; | ||||
| 81 | } | ||||||
| 82 | |||||||
| 83 | 1; | ||||||