Perl::...cateSub(3pm)

πŸ“¦
version 0.19 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Perl::...cateSub(3pm) πŸ’–

okay so bestie, welcome to another page from the User Contributed Perl Documentation collection β€” this one lives in Perl::...cateSub(3pm) and it's genuinely so useful, no cap. πŸŽ€


✨ NAME ✨

TooMuchCode::ProhibitDuplicateSub β€” when 2 subroutines are defined with the same name, report the first one. πŸ’…


🌸 DESCRIPTION 🌸

okay so here's the tea: this policy checks if there are subroutine definitions with identical names under the same namespace. and if they exist? all but the last one are marked as violation. the way it just does the thing πŸ˜­πŸ‘‘

so like, the perl runtime allows a named subroutine to be redefined in the same source file, and the latest definition wins. iconic behavior fr fr. and in the event that this is done by developers β€” preferably unintentionally β€” the perl runtime warns about a subroutine being redefined, with the position being for the one that wins. it's giving "here's a heads up bestie" ✨

but this policy? this policy does the opposite. πŸ™ˆ

now, although the last one is not marked as a violation, its position is reported together anyway β€” making it easier for the developer to locate the subroutine. obsessed with the thoughtfulness honestly 🫢

and should the developer decide to programmatically remove the duplicates? literally just go through all the violations and remove those statements. that's it. that's the whole move. slay. πŸ¦‹


lowkey the whole vibe here is: duplicate subs get caught, the winner gets a shoutout, and you get handed a lil roadmap to clean it all up. iykyk πŸ’œ

perl v5.36.0 Β· 2023-10-05 Β· Perl::...cateSub(3pm) β€” mwah, thanks for reading bestie, go forth and dedupe those subs πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from