I am not the tidy soft of person. In fact, I hate doing housework. But something about untidy codes really irks me. Recently, we adopted the use of crucible as a code review tool. It revealed a whole lot of badly formatted codes in our projects.
The codes look innocently neat and tidy in the Eclipse IDE, i.e.
However, the minute they are committed to the server, the formatting runs in fisheye.
So what’s the reason? The main culprit is the use of tabs. Tabs render inconsistently between the IDE and the web interface. As a matter of fact, this is a common problem, and most open source projects have a rule to forbid the use of tabs in their source codes.
However, such stringent coding policy will require a powerful code formatting tool which will ensure that our developers can easily adhere to the standards.
Ah.. that is solved by our PHPEclipse, with its nice tab to space conversion tool…
All we need to do is to go to Preferences >> PHP >> Code Style >> Formatter and set the tab policy to convert all tabs to a 4 space indent. Once that is done, all we need to do is to do a
Ctrl + Shift + F
To perform source code formating in eclipse… and hey presto! Nicely formatted codes in both Eclipse and Fisheye.





