|Perl Monk, Perl Meditation|
Automate perltidy for PM code?by Moron (Curate)
|on Jul 09, 2007 at 14:14 UTC||Need Help??|
(Update: scratch the idea of changing the behaviour of code tags - see jdporter's reply and yes Perl::Tidy would make more sense than from scratch, see Derby's reply).
Re-reading the various nodes relating to editing and moderation, I couldn't find a clear statement as to whether editing should go as far as cleaning up untidy code, except that it is standard enough to request the addition of code tags via the moderation tool.
Every now and again someone complains that a post has untidy code in it, especially, inconsistent indentation that makes it hard for the reader to match block and other boundaries.
It appears reasonable to nudge the author into cleaning up his own code. On the other hand, it occurred to me that not everyione is aware of perltidy which does it automatically in a flash. And the whole point of requesting editing via moderation is to allow inexperienced, potentially novice, posters to make themselves heard without having to run a technical/site-"in"-group gauntlet first.
I did a quick straw poll through the SOPW and nearly half of the posts look up to perltidy standards. The other half and a bit apparently weren't, although with widely varying degrees of deviancy from the very trivial to the profoundly perverted (...UK readers can calm down now; I am only talking about coding standards ;) ).
Now, I have no idea what precise facilities janitors have at their disposal, nor any insight into how PM is devved, but it occurred to me that it might not be that hard to automate perltidy for select and press-button use by janitors or even to have specific perltidy tags available or another option might be to enhance the code tag to automatically feed the code through perltidy and replace the code with the results, (e.g. something like the code below).
The actual question I am raising is - should perltidy be automated here for these purposes, and if so, should it be automatically for every code-tagged block (update: to clarify: I meant to imply the alternative option to that as being a separate tidying tag for optional use only) or something requested by moderators and performed by janitors? Or the status quo is "advise but not enforce perltidy". I'll say this much about the status quo option: if the more fastidious monk wanted to goad OPers into tidying code themselves, they would have to engage in it on a more than full-time basis, given the steady flow of "unperltidy" postings!
^M Free your mind!