PerlNitpick/Rule/RemoveUnusedVariables.pm

filter: Statementstmt 100% 27 / 27 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 94.5% 35 / 37 CC 3 SCAR 5.1
CC
3
Cov
97%
rewrite
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
« PerlNitpick.pm ↑ Summary PerlNitpick/Rule/AddTrailingCommas.pm »
1 package App::PerlNitpick::Rule::RemoveUnusedVariables;
2 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use PPI::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Perl::Critic::Document;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Perl::Critic::Policy::Variables::ProhibitUnusedVariables;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use App::PerlNitpick::PCPWrap;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶sub rewrite {
Subroutine rewrite: called CC=3 SCAR=11.0
Pod undocumented
12 1 my ($self, $doc) = @_;
13  
14 1 my $o = App::PerlNitpick::PCPWrap->new('Perl::Critic::Policy::Variables::ProhibitUnusedVariables');
15  
16 1 my @vio = $o->violates(
17 undef,
18 Perl::Critic::Document->new(-source => $doc)
19 );
20  
21 1 for (@vio) {
22 1 my ($msg, $explain, $el) = @$_;
23 1 ▶ if ($el->variables == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($el->variables == 1) { } 1 0 1
24 1 $el->remove;
25 } else {
26 # TODO: figure out which variables in this multi-variable statement are unused.
27 }
28 }
29  
30 1 return $doc;
31 }
32  
33 1 1;
34  
35 __END__
« PerlNitpick.pm ↑ Summary PerlNitpick/Rule/AddTrailingCommas.pm »