lokku / Perl-Critic-Lokku

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

TryTiny::ProhibitExitingSubroutine: false positive within while loop #4

Open eserte opened 5 years ago

eserte commented 5 years ago

A while loop should probably be handled like a for loop, that is, next/last/redo should be allowed here. Currently this is causing a violation. Sample script:

#!/usr/bin/perl

use strict;
use warnings;
use Try::Tiny;

try {
    my $i = 0;
    while($i++ < 3) {
    next if $i == 2;
    warn "do something for $i...\n";
    }
} catch {
    warn "something failed";
};

__END__
$ perlcritic --single-policy TryTiny::ProhibitExitingSubroutine try-tiny-perlcritic.pl             
Using next/last/redo/return in a Try::Tiny block is ambiguous at line 10, column 2.  Using next/last/redo without a label or using return in a Try::Tiny block is ambiguous, did you intend to exit out of the try/catch/finally block or the surrounding block?.  (Severity: 4)

Same problem probably exists for do { ... } while.

freyfogle commented 5 years ago

Hi,

Are you actually using this module?

I don't believe this code is being used by anyone anywhere, nor is the module being maintained. Certainly the original creator - a company called Lokku that I founded - no longer exists.

eserte commented 5 years ago

Yes, I am an actual user.

freyfogle commented 5 years ago

Wow, that is fantastic! Would you like to be owner? Though I write that as someone who no longer has commit access ;-)

Flimm commented 5 years ago

I don't have commit access either.

eserte commented 5 years ago

Actually FLIMM has PAUSE permissions: https://metacpan.org/permission/distribution/Perl-Critic-Lokku Changing this (i.e. adding SREZIC as co-maint) should be enough. It looks like I should not use the Perl::Critic::Lokku bundle anymore, but distribute the two policy modules under another name?

Flimm commented 5 years ago

@eserte Honestly, considering Lokku is no more, I think it would be best if this was forked under a different name. Alternatively, I wonder if the maintainers of Try::Tiny would consider including these Perl::Critic policies in that distribution, since all the Perl::Critic policies here only concern Try::Tiny.

eserte commented 5 years ago

@Flimm Putting Perl::Critic policies into the module distribution would be a quite unique thing --- currently all Perl::Critic::Policy::* modules are also in a Perl-Critic-* distribution:

$ zcat ~/.cpan/sources/modules/02packages.details.txt.gz | grep '^Perl::Critic::Policy' | grep -v /Perl-Critic
(empty)

For example there are policies for Moose and Moo which are in separate Perl-Critic-* distributions, not in Moose resp. Moo itself.

While looking around I found two more Try::Tiny policies from @bluefeet --- https://github.com/bluefeet/Perl-Critic-Policy-TryTiny-RequireUse and https://github.com/bluefeet/Perl-Critic-Policy-TryTiny-RequireBlockTermination . So the both Lokku policies could also be split into separate distributions, or all four could be collected into one Perl-Critic-Policy-TryTiny distribution.

In any case, I would need the PAUSE co-maint permissions for the modules to be allowed to do a CPAN release.

Flimm commented 5 years ago

That sounds good to me. I don't think any of that requires handing over the PAUSE rights to Perl::Critic::Lokku, so I don't think it's waiting on me.

mtmail commented 5 years ago

I'm an admin of the lokku github organisation.

Lokku was a heavy user of Perl and active in the community (conference sponsor and such). The company who acquired Lokku isn't and afaik none of the Perl infrastructure is still used. They do own the copyright though.

Let me know if you need this repository transferred. I'm not quite comfortable adding new team members to the organisation. Transfer/forking/renaming is fine though as long as somewhere the attribution "originally developed at Lokku Ltd" remains for copyright sake.

eserte commented 5 years ago

@Flimm: I don't need the permissions for Perl::Critic::Lokku, but for the two *::Try::Tiny::* modules. @mtmail: I don't think it's necessary to transfer this repository --- I would rather do some kind of fork under different names (probably there will be two repositories for the two Try::Tiny policies).

mtmail commented 5 years ago

Sound good. Post a link when ready and I'll update the documention here to reflect it's unmaintained and point to the fork.

Flimm commented 3 years ago

Perl::Critic::Lokku has been deleted from CPAN.