| 1 | package CPANTS::Kwalitee::Report::Indicator; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | $CPANTS::Kwalitee::Report::Indicator::VERSION = '0.11'; | |||||||||||||||||||||||||||
| 4 | 3 | $CPANTS::Kwalitee::Report::Indicator::AUTHORITY = 'cpan:MANWAR'; | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | =head1 NAME | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | CPANTS::Kwalitee::Report::Indicator - Interface to Kwalitee Indicator. | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 VERSION | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | Version 0.11 | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =cut | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 3 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use List::Util qw(any); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use overload q{""} => 'as_string', fallback => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 3 | has [qw(types error remedy)] => (is => 'ro'); | |||||||||||||||||||||||||||
| 26 | 3 | has 'name' => (is => 'ro', required => 1); | |||||||||||||||||||||||||||
| 27 | 3 | has 'verbose' => (is => 'lazy'); | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub _build_verbose { 0 } | ||||||||||||||||||||||||||
|
Subroutine
_build_verbose: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | It represents Kwalitee Indicator. | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | use strict; use warnings; | ||||||||||||||||||||||||||||
| 38 | use CPANTS::Kwalitee::Report; | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | my $report = CPANTS::Kwalitee::Report->new; | ||||||||||||||||||||||||||||
| 41 | my $generators = $report->generators; | ||||||||||||||||||||||||||||
| 42 | my $indicators = $generators->[0]->indicators; | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | print sprintf("Name : %s\n", $indicators->[0]->name); | ||||||||||||||||||||||||||||
| 45 | print sprintf("Description: %s\n", $indicators->[0]->description); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =head1 METHODS | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head2 name() | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | Returns indicator name. | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =head2 description() | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | Returns indicator name with types. | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =cut | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | sub description { | ||||||||||||||||||||||||||
|
Subroutine
description: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | my $types = $self->types; | |||||||||||||||||||||||||||
| 63 | 0 | ▶ | if (scalar(@$types)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 0 | return sprintf("%s (%s)", $self->name, join(", ", @$types)); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | else { | ||||||||||||||||||||||||||||
| 67 | 0 | return $self->name; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head2 category() | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | Returns the indicator's category i.e core, optional or experimental. | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =cut | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub category { | ||||||||||||||||||||||||||
|
Subroutine
category: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($self->is_optional) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 81 | 0 | return 'optional'; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | elsif ($self->is_experimental) { | ||||||||||||||||||||||||||||
| 84 | 0 | return 'experimental'; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | else { | ||||||||||||||||||||||||||||
| 87 | 0 | return 'core'; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =head2 is_core() | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | Returns true/false depending if the indicator is core. | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =cut | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub is_core { | ||||||||||||||||||||||||||
|
Subroutine
is_core: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 98 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | return (!$self->is_optional && !$self->is_experimental); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->is_optional || $self->is_experimental
MC/DC0%0/2
$self->is_optional || $self->is_experimental
$self->is_optional
$self->is_experimental
Truth table0%0/3
A || B
A= $self->is_optionalB= $self->is_experimental
| |||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =head2 is_optional() | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | Returns true/false depending if the indicator is optional. | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | =cut | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub is_optional { | ||||||||||||||||||||||||||
|
Subroutine
is_optional: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 110 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | 0 | ▶ | return any { /is_extra/ } @{$self->types}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | =head2 is_experimental() | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | Returns true/false depending if the indicator is experimental. | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub is_experimental { | ||||||||||||||||||||||||||
|
Subroutine
is_experimental: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 122 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | ▶ | return any { /is_experimental/ } @{$self->types}; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | =head2 types() | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | Returns an array ref of indiator types like below: | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | =over 4 | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | =item * is_extra | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =item * is_experimental | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =item * needs_db | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =back | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =head2 error() | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | Returns indicator error string. | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =head2 remedy() | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | Returns indicator error remedy. | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =cut | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 152 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | my $description = $self->description; | |||||||||||||||||||||||||||
| 155 | 0 | ▶ | my $error = $self->error || 'N/A'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->error || 'N/A'
MC/DC0%0/1
$self->error || 'N/A'
$self->error
Truth table0%0/2
A
A= $self->error
| |||||||||||||||||||||||||||||
| 156 | 0 | ▶ | my $remedy = $self->remedy || 'N/A'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->remedy || 'N/A'
MC/DC0%0/1
$self->remedy || 'N/A'
$self->remedy
Truth table0%0/2
A
A= $self->remedy
| |||||||||||||||||||||||||||||
| 157 | 0 | my $verbose = $self->verbose; | |||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if ($verbose) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if (defined $error && defined $remedy) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $error and defined $remedy
MC/DC0%0/2
defined $error and defined $remedy
defined $error
defined $remedy
Truth table0%0/3
A and B
A= defined $errorB= defined $remedy
| |||||||||||||||||||||||||||||
| 161 | 0 | return sprintf("%s\n error: %s\n remedy: %s", $description, $error, $remedy); | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | else { | ||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if (defined $error) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 165 | 0 | return sprintf("%s\n error: %s", $description, $error); | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | elsif (defined $remedy) { | ||||||||||||||||||||||||||||
| 168 | 0 | return sprintf("%s\n remedy: %s", $description, $remedy); | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | else { | ||||||||||||||||||||||||||||
| 173 | 0 | return $description; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | Mohammad S Anwar, C<< <mohammad.anwar at yahoo.com> >> | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | =head1 REPOSITORY | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | L<https://github.com/manwar/CPANTS-Kwalitee-Report> | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | =head1 BUGS | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | Please report any bugs or feature requests to C<bug-cpants-kwalitee-report at rt.cpan.org>, | ||||||||||||||||||||||||||||
| 188 | or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPANTS-Kwalitee-Report>. | ||||||||||||||||||||||||||||
| 189 | I will be notified and then you'll automatically be notified of progress on your | ||||||||||||||||||||||||||||
| 190 | bug as I make changes. | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | perldoc CPANTS::Kwalitee::Report::Indicator | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | You can also look for information at: | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | =over 4 | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CPANTS-Kwalitee-Report> | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | L<http://annocpan.org/dist/CPANTS-Kwalitee-Report> | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | L<http://cpanratings.perl.org/d/CPANTS-Kwalitee-Report> | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | L<http://search.cpan.org/dist/CPANTS-Kwalitee-Report/> | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | =back | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | Copyright (C) 2017 Mohammad S Anwar. | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | This program is free software; you can redistribute it and / or modify it under | ||||||||||||||||||||||||||||
| 225 | the terms of the the Artistic License (2.0). You may obtain a copy of the full | ||||||||||||||||||||||||||||
| 226 | license at: | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | Any use, modification, and distribution of the Standard or Modified Versions is | ||||||||||||||||||||||||||||
| 231 | governed by this Artistic License.By using, modifying or distributing the Package, | ||||||||||||||||||||||||||||
| 232 | you accept this license. Do not use, modify, or distribute the Package, if you do | ||||||||||||||||||||||||||||
| 233 | not accept this license. | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | If your Modified Version has been derived from a Modified Version made by someone | ||||||||||||||||||||||||||||
| 236 | other than you,you are nevertheless required to ensure that your Modified Version | ||||||||||||||||||||||||||||
| 237 | complies with the requirements of this license. | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | This license does not grant you the right to use any trademark, service mark, | ||||||||||||||||||||||||||||
| 240 | tradename, or logo of the Copyright Holder. | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | This license includes the non-exclusive, worldwide, free-of-charge patent license | ||||||||||||||||||||||||||||
| 243 | to make, have made, use, offer to sell, sell, import and otherwise transfer the | ||||||||||||||||||||||||||||
| 244 | Package with respect to any patent claims licensable by the Copyright Holder that | ||||||||||||||||||||||||||||
| 245 | are necessarily infringed by the Package. If you institute patent litigation | ||||||||||||||||||||||||||||
| 246 | (including a cross-claim or counterclaim) against any party alleging that the | ||||||||||||||||||||||||||||
| 247 | Package constitutes direct or contributory patent infringement,then this Artistic | ||||||||||||||||||||||||||||
| 248 | License to you shall terminate on the date that such litigation is filed. | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND | ||||||||||||||||||||||||||||
| 251 | CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED | ||||||||||||||||||||||||||||
| 252 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR | ||||||||||||||||||||||||||||
| 253 | NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS | ||||||||||||||||||||||||||||
| 254 | REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, | ||||||||||||||||||||||||||||
| 255 | INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE | ||||||||||||||||||||||||||||
| 256 | OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | =cut | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 3 | 1; # End of CPANTS::Kwalitee::Report::Indicator | |||||||||||||||||||||||||||