« blib/lib/Perl/Critic/Policy/NamingConventions/ProhibitAmbiguousNames.pm
↑ Summary
blib/lib/Perl/Critic/Policy/Modules/ProhibitAutomaticExportation.pm »
| 1 | package Perl::Critic::Statistics; | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | 40 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 40 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | 40 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||
| 7 | 40 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||
| 9 | 40 | ▶ | use Perl::Critic::Utils::McCabe qw{ calculate_mccabe_of_sub }; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||
| 11 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||
| 13 | 40 | our $VERSION = '1.150'; | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||
| 15 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||
| 17 | sub new { | ||||||||||||||||||||||||||||||
| 18 | 89 | ▶ | my ( $class ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||
| 20 | 89 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||
| 22 | 89 | $self->{_modules} = 0; | |||||||||||||||||||||||||||||
| 23 | 89 | $self->{_subs} = 0; | |||||||||||||||||||||||||||||
| 24 | 89 | $self->{_statements} = 0; | |||||||||||||||||||||||||||||
| 25 | 89 | $self->{_lines} = 0; | |||||||||||||||||||||||||||||
| 26 | 89 | $self->{_lines_of_blank} = 0; | |||||||||||||||||||||||||||||
| 27 | 89 | $self->{_lines_of_comment} = 0; | |||||||||||||||||||||||||||||
| 28 | 89 | $self->{_lines_of_data} = 0; | |||||||||||||||||||||||||||||
| 29 | 89 | $self->{_lines_of_perl} = 0; | |||||||||||||||||||||||||||||
| 30 | 89 | $self->{_lines_of_pod} = 0; | |||||||||||||||||||||||||||||
| 31 | 89 | $self->{_violations_by_policy} = {}; | |||||||||||||||||||||||||||||
| 32 | 89 | $self->{_violations_by_severity} = {}; | |||||||||||||||||||||||||||||
| 33 | 89 | $self->{_total_violations} = 0; | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||
| 35 | 89 | return $self; | |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||
| 38 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||
| 40 | sub accumulate { | ||||||||||||||||||||||||||||||
| 41 | 85 | ▶ | my ($self, $doc, $violations) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
accumulate: called CC=13 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||
| 43 | 85 | $self->{_modules}++; | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||
| 45 | 85 | my $subs = $doc->find('PPI::Statement::Sub'); | |||||||||||||||||||||||||||||
| 46 | 85 | ▶ | if ($subs) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 47 | 9 | foreach my $sub ( @{$subs} ) { | |||||||||||||||||||||||||||||
| 48 | 10 | $self->{_subs}++; | |||||||||||||||||||||||||||||
| 49 | 10 | $self->{_subs_total_mccabe} += calculate_mccabe_of_sub( $sub ); | |||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||
| 53 | 85 | my $statements = $doc->find('PPI::Statement'); | |||||||||||||||||||||||||||||
| 54 | 85 | ▶ | $self->{_statements} += $statements ? scalar @{$statements} : 0; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||
| 56 | ## no critic (RequireDotMatchAnything, RequireExtendedFormatting, RequireLineBoundaryMatching) | ||||||||||||||||||||||||||||||
| 57 | 85 | my @lines = split /$INPUT_RECORD_SEPARATOR/, $doc->serialize(); | |||||||||||||||||||||||||||||
| 58 | ## use critic | ||||||||||||||||||||||||||||||
| 59 | 85 | $self->{_lines} += scalar @lines; | |||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||
| 61 | 85 | my ( $in_data, $in_pod ); | |||||||||||||||||||||||||||||
| 62 | 85 | foreach ( @lines ) { | |||||||||||||||||||||||||||||
| 63 | 1185 | ▶ | if ( q{=} eq substr $_, 0, 1 ) { ## no critic (ProhibitCascadingIfElse) | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 64 | 64 | $in_pod = not m/ \A \s* =cut \b /smx; | |||||||||||||||||||||||||||||
| 65 | 64 | $self->{_lines_of_pod}++; | |||||||||||||||||||||||||||||
| 66 | } elsif ( $in_pod ) { | ||||||||||||||||||||||||||||||
| 67 | 99 | $self->{_lines_of_pod}++; | |||||||||||||||||||||||||||||
| 68 | ▶ | } elsif ( q{__END__} eq $_ || q{__DATA__} eq $_ ) { | |||||||||||||||||||||||||||||
|
Condition100%3/3
"__END__" eq $_ or "__DATA__" eq $_
MC/DC100%2/2
"__END__" eq $_ or "__DATA__" eq $_
"__END__" eq $_
"__DATA__" eq $_
Truth table100%3/3
A or B
A= "__END__" eq $_B= "__DATA__" eq $_
| |||||||||||||||||||||||||||||||
| 69 | 59 | $in_data = 1; | |||||||||||||||||||||||||||||
| 70 | 59 | $self->{_lines_of_perl}++; | |||||||||||||||||||||||||||||
| 71 | } elsif ( $in_data ) { | ||||||||||||||||||||||||||||||
| 72 | 89 | $self->{_lines_of_data}++; | |||||||||||||||||||||||||||||
| 73 | } elsif ( m/ \A \s* \# /smx ) { | ||||||||||||||||||||||||||||||
| 74 | 91 | $self->{_lines_of_comment}++; | |||||||||||||||||||||||||||||
| 75 | } elsif ( m/ \A \s* \z /smx ) { | ||||||||||||||||||||||||||||||
| 76 | 228 | $self->{_lines_of_blank}++; | |||||||||||||||||||||||||||||
| 77 | } else { | ||||||||||||||||||||||||||||||
| 78 | 555 | $self->{_lines_of_perl}++; | |||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||
| 83 | 85 | foreach my $violation ( @{ $violations } ) { | |||||||||||||||||||||||||||||
| 84 | 159 | $self->{_violations_by_severity}->{ $violation->severity() }++; | |||||||||||||||||||||||||||||
| 85 | 159 | $self->{_violations_by_policy}->{ $violation->policy() }++; | |||||||||||||||||||||||||||||
| 86 | 159 | $self->{_total_violations}++; | |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||
| 89 | 85 | return; | |||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||
| 92 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||
| 94 | sub modules { | ||||||||||||||||||||||||||||||
| 95 | 3 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
modules: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||
| 97 | 3 | return $self->{_modules}; | |||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||
| 100 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||
| 102 | sub subs { | ||||||||||||||||||||||||||||||
| 103 | 5 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
subs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||
| 105 | 5 | return $self->{_subs}; | |||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||
| 108 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||
| 110 | sub statements { | ||||||||||||||||||||||||||||||
| 111 | 3 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
statements: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||
| 113 | 3 | return $self->{_statements}; | |||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||
| 116 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||
| 118 | sub lines { | ||||||||||||||||||||||||||||||
| 119 | 3 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
lines: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||
| 121 | 3 | return $self->{_lines}; | |||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||
| 124 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||
| 126 | sub lines_of_blank { | ||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
lines_of_blank: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||
| 129 | 0 | return $self->{_lines_of_blank}; | |||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||
| 132 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||
| 134 | sub lines_of_comment { | ||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
lines_of_comment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||
| 137 | 0 | return $self->{_lines_of_comment}; | |||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||
| 140 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||
| 142 | sub lines_of_data { | ||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
lines_of_data: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||
| 145 | 0 | return $self->{_lines_of_data}; | |||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||
| 148 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||
| 150 | sub lines_of_perl { | ||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
lines_of_perl: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||
| 153 | 0 | return $self->{_lines_of_perl}; | |||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||
| 156 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||
| 158 | sub lines_of_pod { | ||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
lines_of_pod: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||
| 161 | 0 | return $self->{_lines_of_pod}; | |||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||
| 164 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||
| 166 | sub _subs_total_mccabe { | ||||||||||||||||||||||||||||||
| 167 | 1 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
_subs_total_mccabe: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||
| 169 | 1 | return $self->{_subs_total_mccabe}; | |||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||
| 172 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||
| 174 | sub violations_by_severity { | ||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
violations_by_severity: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||
| 177 | 0 | return $self->{_violations_by_severity}; | |||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||
| 180 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||
| 182 | sub violations_by_policy { | ||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
violations_by_policy: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||
| 185 | 0 | return $self->{_violations_by_policy}; | |||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||
| 188 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||
| 190 | sub total_violations { | ||||||||||||||||||||||||||||||
| 191 | 4 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
total_violations: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||
| 193 | 4 | return $self->{_total_violations}; | |||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||
| 196 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||
| 198 | sub statements_other_than_subs { | ||||||||||||||||||||||||||||||
| 199 | 2 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
statements_other_than_subs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||
| 201 | 2 | return $self->statements() - $self->subs(); | |||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||
| 204 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||
| 206 | sub average_sub_mccabe { | ||||||||||||||||||||||||||||||
| 207 | 1 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
average_sub_mccabe: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||
| 209 | 1 | ▶ | return if $self->subs() == 0; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||
| 211 | 1 | return $self->_subs_total_mccabe() / $self->subs(); | |||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||
| 214 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||
| 216 | sub violations_per_file { | ||||||||||||||||||||||||||||||
| 217 | 1 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
violations_per_file: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | return if $self->modules() == 0; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||
| 221 | 1 | return $self->total_violations() / $self->modules(); | |||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||
| 224 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||
| 226 | sub violations_per_statement { | ||||||||||||||||||||||||||||||
| 227 | 1 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
violations_per_statement: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||
| 229 | 1 | my $statements = $self->statements_other_than_subs(); | |||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||
| 231 | 1 | ▶ | return if $statements == 0; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||
| 233 | 1 | return $self->total_violations() / $statements; | |||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||
| 236 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||
| 238 | sub violations_per_line_of_code { | ||||||||||||||||||||||||||||||
| 239 | 1 | ▶ | my ( $self ) = @_; | ||||||||||||||||||||||||||||
|
Subroutine
violations_per_line_of_code: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||
| 241 | 1 | ▶ | return if $self->lines() == 0; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||
| 243 | 1 | return $self->total_violations() / $self->lines(); | |||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||
| 246 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||
| 248 | 40 | 1; | |||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||
| 250 | __END__ | ||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||
| 252 | #----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||
| 254 | =pod | ||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||
| 256 | =for stopwords McCabe | ||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||
| 258 | =head1 NAME | ||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||
| 260 | Perl::Critic::Statistics - Compile stats on Perl::Critic violations. | ||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||
| 263 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||
| 265 | This class accumulates statistics on Perl::Critic violations across one or | ||||||||||||||||||||||||||||||
| 266 | more files. NOTE: This class is experimental and subject to change. | ||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||
| 269 | =head1 INTERFACE SUPPORT | ||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||
| 271 | This is considered to be a non-public class. Its interface is subject | ||||||||||||||||||||||||||||||
| 272 | to change without notice. | ||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||
| 275 | =head1 METHODS | ||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||
| 277 | =over | ||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||
| 279 | =item C<new()> | ||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||
| 281 | Create a new instance of Perl::Critic::Statistics. No arguments are supported | ||||||||||||||||||||||||||||||
| 282 | at this time. | ||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||
| 285 | =item C< accumulate( $doc, \@violations ) > | ||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||
| 287 | Accumulates statistics about the C<$doc> and the C<@violations> that were | ||||||||||||||||||||||||||||||
| 288 | found. | ||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||
| 291 | =item C<modules()> | ||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||
| 293 | The number of chunks of code (usually files) that have been analyzed. | ||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||
| 296 | =item C<subs()> | ||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||
| 298 | The total number of subroutines analyzed by this Critic. | ||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||
| 301 | =item C<statements()> | ||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||
| 303 | The total number of statements analyzed by this Critic. | ||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||
| 306 | =item C<lines()> | ||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||
| 308 | The total number of lines of code analyzed by this Critic. | ||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||
| 311 | =item C<lines_of_blank()> | ||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||
| 313 | The total number of blank lines analyzed by this Critic. This includes only | ||||||||||||||||||||||||||||||
| 314 | blank lines in code, not POD or data. | ||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||
| 317 | =item C<lines_of_comment()> | ||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||
| 319 | The total number of comment lines analyzed by this Critic. This includes only | ||||||||||||||||||||||||||||||
| 320 | lines whose first non-whitespace character is C<#>. | ||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||
| 323 | =item C<lines_of_data()> | ||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||
| 325 | The total number of lines of data section analyzed by this Critic, not | ||||||||||||||||||||||||||||||
| 326 | counting the C<__END__> or C<__DATA__> line. POD in a data section is counted | ||||||||||||||||||||||||||||||
| 327 | as POD, not data. | ||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||
| 330 | =item C<lines_of_perl()> | ||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||
| 332 | The total number of lines of Perl code analyzed by this Critic. Perl appearing | ||||||||||||||||||||||||||||||
| 333 | in the data section is not counted. | ||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||
| 336 | =item C<lines_of_pod()> | ||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||
| 338 | The total number of lines of POD analyzed by this Critic. Pod occurring in a | ||||||||||||||||||||||||||||||
| 339 | data section is counted as POD, not as data. | ||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||
| 342 | =item C<violations_by_severity()> | ||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||
| 344 | The number of violations of each severity found by this Critic as a | ||||||||||||||||||||||||||||||
| 345 | reference to a hash keyed by severity. | ||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||
| 348 | =item C<violations_by_policy()> | ||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||
| 350 | The number of violations of each policy found by this Critic as a | ||||||||||||||||||||||||||||||
| 351 | reference to a hash keyed by full policy name. | ||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||
| 354 | =item C<total_violations()> | ||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||
| 356 | The total number of violations found by this Critic. | ||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||
| 359 | =item C<statements_other_than_subs()> | ||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||
| 361 | The total number of statements minus the number of subroutines. | ||||||||||||||||||||||||||||||
| 362 | Useful because a subroutine is considered a statement by PPI. | ||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||
| 365 | =item C<average_sub_mccabe()> | ||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||
| 367 | The average McCabe score of all scanned subroutines. | ||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||
| 370 | =item C<violations_per_file()> | ||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||
| 372 | The total violations divided by the number of modules. | ||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||
| 375 | =item C<violations_per_statement()> | ||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||
| 377 | The total violations divided by the number statements minus | ||||||||||||||||||||||||||||||
| 378 | subroutines. | ||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||
| 381 | =item C<violations_per_line_of_code()> | ||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||
| 383 | The total violations divided by the lines of code. | ||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||
| 386 | =back | ||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||
| 389 | =head1 AUTHOR | ||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||
| 391 | Elliot Shank C<< <perl@galumph.com> >> | ||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||
| 394 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||
| 396 | Copyright (c) 2007-2011 Elliot Shank. | ||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||
| 398 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||
| 399 | it under the same terms as Perl itself. The full text of this license | ||||||||||||||||||||||||||||||
| 400 | can be found in the LICENSE file included with this module. | ||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||
| 402 | =cut | ||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||
| 404 | ############################################################################## | ||||||||||||||||||||||||||||||
| 405 | # Local Variables: | ||||||||||||||||||||||||||||||
| 406 | # mode: cperl | ||||||||||||||||||||||||||||||
| 407 | # cperl-indent-level: 4 | ||||||||||||||||||||||||||||||
| 408 | # fill-column: 78 | ||||||||||||||||||||||||||||||
| 409 | # indent-tabs-mode: nil | ||||||||||||||||||||||||||||||
| 410 | # c-indentation-style: bsd | ||||||||||||||||||||||||||||||
| 411 | # End: | ||||||||||||||||||||||||||||||
| 412 | # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : | ||||||||||||||||||||||||||||||