Login
RT #61311: Subroutines::ProhibitUnusedPrivateSubroutines dies on
authorTom Wyant <harryfmudd@comcast.net>
Tue, 14 Sep 2010 05:25:14 +0000 (05:25 +0000)
committerTom Wyant <harryfmudd@comcast.net>
Tue, 14 Sep 2010 05:25:14 +0000 (05:25 +0000)
commit2e31b80408fbec89a78c5ebb1d034bc0e1f0d84d
treea880d816c826687e0909cf6475e57af11689247d
parent4bb887541aa8147bbd43b9236b96680ad77b1154
RT #61311: Subroutines::ProhibitUnusedPrivateSubroutines dies on
"&_name" call

The problem was that the return value of sprevious_sibling() was being
incorrectly tested.

About 12 lines into sub _find_sub_reference_in_document(), and again
about 18 lines in, the code 'defined $prior' occurs. The 'defined'
should be removed; that is, the code should just be '$prior'.

The erroneous code assumed that the PPI method sprevious_sibling()
returned undef if there was no previous sibling in the parse tree. In
fact, it is documented as returning a false value.
Changes
lib/Perl/Critic/Policy/Subroutines/ProhibitUnusedPrivateSubroutines.pm
t/Subroutines/ProhibitUnusedPrivateSubroutines.run