line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::PerlNitpick::Rule::RemoveUnusedVariables; |
2
|
|
|
|
|
|
|
# ABSTRACT: Remove unused variables |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=encoding UTF-8 |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
This nitpicking rules removes variabse that is declared but not used. |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=cut |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
288849
|
use Moose; |
|
1
|
|
|
|
|
394655
|
|
|
1
|
|
|
|
|
5
|
|
11
|
1
|
|
|
1
|
|
6165
|
use PPI::Document; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
21
|
|
12
|
1
|
|
|
1
|
|
753
|
use Perl::Critic::Document; |
|
1
|
|
|
|
|
808588
|
|
|
1
|
|
|
|
|
36
|
|
13
|
1
|
|
|
1
|
|
11
|
use Perl::Critic::Policy::Variables::ProhibitUnusedVariables; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
442
|
use App::PerlNitpick::PCPWrap; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
6
|
no Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub rewrite { |
20
|
1
|
|
|
1
|
0
|
2532
|
my ($self, $doc) = @_; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
7
|
my $o = App::PerlNitpick::PCPWrap->new('Perl::Critic::Policy::Variables::ProhibitUnusedVariables'); |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
9
|
my @vio = $o->violates( |
25
|
|
|
|
|
|
|
undef, |
26
|
|
|
|
|
|
|
Perl::Critic::Document->new(-source => $doc) |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
12
|
for (@vio) { |
30
|
1
|
|
|
|
|
16
|
my ($msg, $explain, $el) = @$_; |
31
|
1
|
50
|
|
|
|
4
|
if ($el->variables == 1) { |
32
|
1
|
|
|
|
|
43
|
$el->remove; |
33
|
|
|
|
|
|
|
} else { |
34
|
|
|
|
|
|
|
# TODO |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
48
|
return $doc; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |