Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[CAGE] perl coding standards...

12 views
Skip to first unread message

Will Coleda

unread,
Sep 26, 2006, 11:21:37 PM9/26/06
to parrot-...@perl.org
I took a first pass at a perlcritic test: t/codingstd/perlcritic.t ;
this test isn't run by default.

It reports on only the following perlcritic rules at the moment:

TestingAndDebugging::RequireUseStrict
TestingAndDebugging::RequireUseWarnings
Variables::ProhibitConditionalDeclarations
InputOutput::ProhibitTwoArgOpen
InputOutput::ProhibitBarewordFileHandles
NamingConventions::ProhibitAmbiguousNames
Subroutines::ProhibitBuiltinHomonyms
Subroutines::ProhibitExplicitReturnUndef
Subroutines::ProhibitSubroutinePrototypes
Subroutines::RequireFinalReturn
CodeLayout::ProhibitHardTabs

Which seem like a fairly sane, reasonable starting point. (At least
to this crazy.) While Chip should probably bless this, it's probably
a fairly safe CAGE item to run this test (you can run it with no args
and get a LOT of output, or pass filenames to check as args.), and
then patch up the files. Note that turning on warnings might mean you
need to further clean some code.

Since a lot of this perl code this test checks doesn't have explicit
tests, make sure no new failures are generated by your cleanup. As
always, try to keep whitespace only fixes (removing hard tabs) as
separate patches.

Finally, don't feel you have to make a file error-free. Pick one
error that bugs you, grep through the test output for that, and fix
those errors.

Here's an example:

$ perl t/codingstd/perlcritic.t languages/tcl/lib/Parrot/Test/Tcl.pm
1..1
not ok 1 - languages/tcl/lib/Parrot/Test/Tcl.pm
# Failed test (t/codingstd/perlcritic.t at line 83)
# got: 'Code before strictures are enabled at line 16,
column 1.
#
# Code before warnings are enabled at line 16, column 1.
#
# Hard tabs used at line 80, column 1.
# '
# expected: ''
# Looks like you failed 1 test of 1.

So, in this case, you could pretty easily fix the hard tab issue, but
turning on strict and warnings causes a bunch of other issues at
runtime, so you'd then have to track those down.

Regards.

--
Will "Coke" Coleda
wi...@coleda.com


Chris Dolan

unread,
Oct 2, 2006, 4:48:04 PM10/2/06
to Will Coleda, parrot-...@perl.org
On Sep 26, 2006, at 10:21 PM, Will Coleda wrote:

> I took a first pass at a perlcritic test: t/codingstd/
> perlcritic.t ; this test isn't run by default.

[snip]

Cool! Attached is a patch to simplify this test code a little bit by
leveraging Test::Perl::Critic. I also reworked
CodeLayout::UseParrotCoda to use current P::C conventions.

lib/Perl/Critic/Policy/CodeLayout/UseParrotCoda.pm | 41 +++------
t/codingstd/perlcritic.t | 88 +++++++
+-------------
2 files changed, 51 insertions(+), 78 deletions(-)

Chris

--
Chris Dolan, Software Developer, http://www.chrisdolan.net/
Public key: http://www.chrisdolan.net/public.key
vCard: http://www.chrisdolan.net/ChrisDolan.vcf


perlcritic.patch
0 new messages