blaenk / wp-recaptcha

I gave ownership of this project to Google many years ago
Other
38 stars 16 forks source link

Automated source code inspection and subsequent manual optimisation #21

Open PanderMusubi opened 14 years ago

PanderMusubi commented 14 years ago

Please include the following automated inspection on the source code of this plugin.

PHP code style checking

phpcs wp-recaptcha>phpcs.txt

PHP dependancies and complexity checking

PHP_Depend/pdepend.php -d memory_limit=128M --bad-documentation --summary-xml=pdepend-summary.xml --phpunit-xml=pdepend-phpunit.xml --jdepend-chart=pdepend-jdepend.svg --overview-pyramid=pdepend-pyramid.svg wp-recaptcha

resulting images can be converted in this way

inkscape -z --file=pdepend-jdepend.svg --export-png=pdepend-jdepend.png inkscape -z --file=pdepend-pyramid.svg --export-png=pdepend-pyramid.png convert pdepend-jdepend.png pdepend-jdepend.jpg convert /pdepend-pyramid.png pdepend-pyramid.jpg

PHP mess detection for possible bugs, suboptimal code, overcomplicated expressions and unused parameters, methods, properties

php -d memory_limit=128M tools/phpmd/phpmd.php wp-recaptcha html codesize --reportfile phpmd.html

Subsequently, improve PHP code in order to minimise the errors and warnings reported by these three tools. Please implement this step in your standard release procedure.

Adhering to the industry standards or common practises as promoted by these tools will improve code quality and decrease the risk of bugs.

PanderMusubi commented 14 years ago

Fro wp-recaptcha version 2.9.6, this results in:

blaenk commented 14 years ago

Hey Pander, thanks for this analysis. Would you be kind enough to run it on the new version, branch oo-refactor? I would appreiate it.

PanderMusubi commented 14 years ago

Hi Bleank,

What is the exact command to download that version. I'll run it and send you the results if you are going to incorporate it in your release procedure from then one ;)

Regards,

Pander

blaenk commented 14 years ago

Sorry for the late response. If you used git to get the source, you can do git checkout remotes/origin/oo-refactor oo-refactor. That should work. However, it's perhaps easiest to just download the source tree in an archive here.

PanderMusubi commented 14 years ago

Here it is, first the current prod version, then the new refactored version:

$ grep FILE -A 2 wp-recaptcha/phpcs.txt

FILE: wp-recaptcha/recaptchalib.php

FOUND 225 ERROR(S) AND 29 WARNING(S) AFFECTING 129 LINE(S)

FILE: wp-recaptcha/wp-recaptcha.php

FOUND 790 ERROR(S) AND 186 WARNING(S) AFFECTING 572 LINE(S)

$ grep FILE -A 2 blaenk-wp-recaptcha-5be1b86/phpcs.txt

FILE: blaenk-wp-recaptcha-5be1b86/mailhide_settings.php

FOUND 1 ERROR(S) AND 17 WARNING(S) AFFECTING 18 LINE(S)

FILE: blaenk-wp-recaptcha-5be1b86/recaptchalib.php

FOUND 225 ERROR(S) AND 29 WARNING(S) AFFECTING 129 LINE(S)

FILE: blaenk-wp-recaptcha-5be1b86/recaptcha.php

FOUND 138 ERROR(S) AND 185 WARNING(S) AFFECTING 211 LINE(S)

FILE: blaenk-wp-recaptcha-5be1b86/settings.php

FOUND 1 ERROR(S) AND 22 WARNING(S) AFFECTING 23 LINE(S)

FILE: blaenk-wp-recaptcha-5be1b86/wp-recaptcha.php

FOUND 3 ERROR(S) AND 2 WARNING(S) AFFECTING 5 LINE(S)

FILE: blaenk-wp-recaptcha-5be1b86/uninstall.php

FOUND 13 ERROR(S) AND 4 WARNING(S) AFFECTING 9 LINE(S)

FILE: blaenk-wp-recaptcha-5be1b86/mailhide.php

FOUND 148 ERROR(S) AND 111 WARNING(S) AFFECTING 154 LINE(S)

So, please install phpcs and you can see the details for yourself and fix them. Good luck.

PanderMusubi commented 14 years ago

Ah, the layout was not intended like this, it is just the dashes that get intrerpretated by submitting via this form.