| 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
| |||||||||||
| 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__ | ||||||||||