Well volunteered!

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.

1 vote
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Kent Fredric shared this idea  ·   ·  Admin →

    4 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • 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.

      • AdminChristian Walde (Developer, Cat Eats Mouse) commented  · 

        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.

      • Kent Fredric commented  · 

        I threw this idea your way just in case I don't find the tuits myself to do it =).

      Feedback and Knowledge Base