lokku / Perl-Critic-Lokku

A collection of Perl::Critic policies
https://metacpan.org/pod/Perl::Critic::Lokku
0 stars 4 forks source link

Test suite breaks with perl 5.33.7 and newer #7

Open eserte opened 3 years ago

eserte commented 3 years ago

FLIMM/Perl-Critic-Lokku-0.003.tar.gz does not have pass reports since perl 5.33.7. See http://matrix.cpantesters.org/?dist=Perl-Critic-Lokku%200.003

On my systems t/run.t fails like this:

#   Failed test 'TryTiny::ProhibitExitingSubroutine - line 20 - A "try" invocation with "next" inside it'
#   at t/run.t line 9.
# Expected 1 violations, got 0. 

#   Failed test 'TryTiny::ProhibitExitingSubroutine - line 40 - A "try" invocation with "$i == 0 && next" inside it'
#   at t/run.t line 9.
# Expected 1 violations, got 0. 

#   Failed test 'TryTiny::ProhibitExitingSubroutine - line 60 - A "try" invocation with "next if $i == 0"'
#   at t/run.t line 9.
# Expected 1 violations, got 0. 

#   Failed test 'TryTiny::ProhibitExitingSubroutine - line 143 - A "try" invorcation with an if-block inside it'
#   at t/run.t line 9.
# Expected 1 violations, got 0. 

#   Failed test 'TryTiny::ProhibitExitingSubroutine - line 175 - A "try" invocation with a for-loop, and a "next" outside'
#   at t/run.t line 9.
# Expected 1 violations, got 0. 

#   Failed test 'TryTiny::ProhibitExitingSubroutine - line 206 - A "try" invocation with subref inside it, with "try" inside it, with "return"'
#   at t/run.t line 9.
# Expected 1 violations, got 0. 

#   Failed test 'TryTiny::RequireCatch - line 1 - "try" on its own'
#   at t/run.t line 9.
# Expected 1 violations, got 0. 

#   Failed test 'TryTiny::RequireCatch - line 12 - "try" with "finally" block'
#   at t/run.t line 9.
# Expected 1 violations, got 0. 

#   Failed test 'TryTiny::RequireCatch - line 67 - "try" in an if block'
#   at t/run.t line 9.
# Expected 1 violations, got 0. 
# Looks like you failed 9 tests of 23.
t/run.t ............... 
Dubious, test returned 9 (wstat 2304, 0x900)
Failed 9/23 subtests 
eserte commented 3 years ago

It seems that the problem is that "try" is now a perl bareword, even if the new experimental "try" feature is not enabled. This means that the check in https://metacpan.org/source/FLIMM/Perl-Critic-Lokku-0.003/lib/Perl/Critic/Policy/TryTiny/ProhibitExitingSubroutine.pm#L52 does not work anymore --- is_function_call() returns falls if is_perl_bareword() returns true.

See also https://metacpan.org/source/RURBAN/B-Keywords-1.22/lib/B/Keywords.pm#L455-459

Flimm commented 3 years ago

Please note that Perl::Critic::Lokku has been deleted from CPAN.