Write a Perl::Critic Policy for various List::* packages
There's an unfortunate thing that can happen with some List::* packages and thats some of the list-operating functions ( ie: all, any , first ) have a nice little bug where to can not actually pass it a list and be blissfully unaware of this.
ie:
return any { foobar( $_ ) }
A cursory glance suggests "Sure, that works", when in fact, any will iterate over an empty list seeing if foobar($_) returns true for any of them.... guess thats not very good.
Its a bit hard to solve this problem without LOTS of dark XS magic and even then, you have to patch it into the right list tools.
A Perl Critic policy suite that checks for missing parameters for the various things exported by the various *(ie: List::AllUtils ) package could come in handy.
-
Kent Fredric commented
Nope, tested prototypes, don't do the trick. You also have to get around odd use cases like
first { } method() # which is apparently broken by the &@ prototype.
Like I said, you really *do* have to reach for dark magic to solve this issue normally, and lazyness and "Cant I just do it in perl" and "I can't touch the original code to fix this" and "original code doesn't want XS nasties" ==> Well, the best I can do is create a new package, so I can either re-implement all of List::* myself somehow, or wrap it all myself somehow (ie: create a clone of ::AllUtils with XS nasties )
Or, it could just be a critic policy. Which works.
-
Liking this one. However, shouldn't protyping them as (&@) do the trick? If not, since List::Util is core, i think it should be put into one of the base Perl::Critic packages as a patch.
-
@techpractical commented
@kent: Hook::LexWrap?
-
Kent Fredric commented
I threw this idea your way just in case I don't find the tuits myself to do it =).