views:

315

answers:

2

Regarding the php code smell detector at http://c2.com/cgi/wiki?DetectingCodeSmellsInPhp

When I open it in my web browser, I get an error, but when I open it in my IDE, I don't.

How to correct it?

+3  A: 

Detecting a definitive code smell with code will possible the same day the halting problem will be fixed. *takes off joke hat*

What he is just doing is setting some parameters on what he thinks is bad code. And it's wrong (imo)

Having equal or more than 4 parameters is a code smell? He himself has that in the code smell detector!

More than 20 lines for a function is a code smell? The main function in this code smell detector is 49 lines of code!!

Code smell is not a thing you can program, in some cases the best way to do some function is the non standard way (whatever that way is) and in other cases it is not. You just have to trust your instinct and do as Frank Farmer said in the comments above. Just take a good wiff.

Ólafur Waage
It also uses string parsing, instead of token parsing...
gms8994
+1  A: 

if you want a code sniffer, use Pears PHP_CodeSniffer. it lets you define your own rules, your own set of rules, etc.

PHP_CodeSniffer is a PHP5 script that tokenises and "sniffs" PHP, JavaScript and CSS files to detect violations of a defined coding standard. It is an essential development tool that ensures your code remains clean and consistent. It can also help prevent some common semantic errors made by developers.

A coding standard in PHP_CodeSniffer is a collection of sniff files. Each sniff file checks one part of the coding standard only.

it's fun to use (try writing a single function that adheres to the PEAR standards) and forces at least some consistency in the codebase.

it doesn't guarantee code quality, but it may help

Schnalle