Php code odor detector

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

When I open it in my web browser, I get an error message, but when I open it in my IDE, I do not.

How to fix it?

+4
source share
2 answers

Detection of the final smell of the code with the code will be possible on the same day as the problem with stopping. *takes off joke hat*

What he just does is set some parameters to what he considers bad code. And this is wrong (imo)

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

More than 20 lines for a function - is it the smell of code? The main function in this code smell detector is 49 lines of code.

The smell of code is not something you can program, in some cases the best way to make a function is to use a non-standard way (regardless of what it 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 wave.

+8
source

if you need code sniffer use Pears PHP_CodeSniffer . it allows you to define your own rules, your own set of rules, etc.

PHP_CodeSniffer is a PHP5 script that tokens and sniffs PHP, JavaScript and CSS files to detect violations of a particular coding standard. This is an important development tool that ensures that your code stays clean and consistent. It can also help prevent some common semantic mistakes made by developers.

The coding standard in PHP_CodeSniffer is a collection of sniff files. Each sniff file validates only one part of the encoding standard.

It's fun to use (try writing one function that adheres to the PEAR standards) and force at least some consistency in the code base.

it does not guarantee the quality of the code, but can help

+2
source

All Articles