Post-Apocalyptic RPG forums

Development => Programming => Topic started by: oct on October 25, 2009, 04:37:14 PM



Title: Code Check Utility
Post by: oct on October 25, 2009, 04:37:14 PM
I made a little script that walks through the parpg code directory and checks for possible code errors using pylint. 

Usage:

   To check for possible code errors:
        parpg_check.py </path/to/parpg>

   To check for possible PEP-8 code conventions only:
        parpg_check.py --check pep8 </path/to/parpg>

   To check for code warnings:
        parpg_check.py --check warnings </path/to/parpg>

    To check for refactors,  aka possible bad code smell:
        parpg_check.py --check refactors </path/to/parpg>

    And the whole shebang:
        parpg_check.py --check all </path/to/parpg>

You need pylint (http://www.logilab.org/857/ (http://www.logilab.org/857/)) to use the script. Pylint isn't perfect so you might get a couple of false positives, but it is useful for finding simple errors and PEP-8 code violations.  Also, the script spits out the messages to stdout, so you might want to redirect it to a file ( parpg_check.py /path/to/parpg > check.txt).

I have not tested in on Windows as I don't have a Windows box, so your mileage may vary there.



octavio


Title: Re: Code Check Utility
Post by: shevegen on October 25, 2009, 04:55:01 PM
Cool stuff. Now we need someone on windows testing it.


Title: Re: Code Check Utility
Post by: amo-ej1 on October 25, 2009, 05:41:05 PM
I added the script in utilities/parpg_check.py, I did some small modifications (mainly the default path (which is now ../) the helpstring, and adding the fife license thing at the top).

Could somebody please try running it on win32 ?


Edit: see also http://parpg-trac.cvsdude.com/parpg/ticket/131


Title: Re: Code Check Utility
Post by: saritor on October 26, 2009, 07:46:05 PM
I tested this out in windows today. The big issue is that when it runs into the revision check it passes a command line argument that (afaik) will not work if you are using TortoiseSVN. I am not super familiar with TortSVN but if there was a way to pass it some command line argument to get the same out put (since its really only a front-end for SVN) it would probably work alright. I don't know if that's even a possibility though. Or if there might be some other way to directly grep it out of the .svn files. Anywho that is all I have learned for now, maybe some other windows dev's can drop some comments here?


Title: Re: Code Check Utility
Post by: zenbitz on October 26, 2009, 11:26:48 PM
pylint  executable seems non-obvious to install on Mac OSX.   port py-lint doesn't seem to provide it, nothing in fink either.  I will try a little harder and report...

EDIT: Got it.
>sudo easy_install pylint

I run the parpg checker (no args) and get a few hundred errors.  Am I doing it right?


Title: Re: Code Check Utility
Post by: amo-ej1 on October 28, 2009, 08:54:10 AM
maybe some other windows dev's can drop some comments here?

Do you also hear the silence ? :D


Title: Re: Code Check Utility
Post by: mvBarracuda on October 28, 2009, 09:34:21 AM
Is the SVN functionality essential to the script? If not, couldn't we simply ignore the check via an IF statement in the script if ran on win32?


Title: Re: Code Check Utility
Post by: amo-ej1 on October 28, 2009, 12:42:15 PM
It's pure cosmetics, I opened a ticket http://parpg-trac.cvsdude.com/parpg/ticket/133 for this. We could either throw it out|throw it out on win32|attempt to replace it by pysvn

but then we'll need to check how nice pysvn plays with tortoise


Title: Re: Code Check Utility
Post by: oct on October 28, 2009, 10:26:48 PM
Ah yes, the svn revision number.  I pipe the output of the script to a file that gets checked nightly by a cron job to see if a new revision has been uploaded.   If it has I rerun the script and make a new one.  That's what the revision number was for, but I should have cleaned it out before posting it.

I'll try to make things more portable next time.


Title: Re: Code Check Utility
Post by: superfluid on October 28, 2009, 11:43:07 PM
I'd just like to throw out that not everyone *cough cough* uses stock SVN for interacting with the repo  :) So if such svn functionality could be optional that would be cool.


Title: Re: Code Check Utility
Post by: amo-ej1 on October 29, 2009, 12:36:45 PM
it's already thrown out ;) it echos the directory now instead of the revision number