Inherited code: To format or not to format?

I disagree with you. For me, the formatting, even if it is only a way to "present" the source code, is also an important code quality indicator.

Using the auto-formatting has several advantages. It homogenizes the format among all the developers of the team. This will avoid you some troubles with the SCM manipulation: for example, merging two files that have few real changes, but a lot of formatting differences is a nightmare!

It can also show you some errors. For example:

if (aCondition)
    foo();
    bar();

will be reformatted:

if (condition)
    foo();
bar();

showing that the second line is not in the if statement.

Last, but not least, a well formatted code (not only for Java) is easier to read!


Auto-format the inherited code just once, and then proceed without auto-formatting.


In my opinion consistent code formatting improves legibility. It is clearly no substitute for good code, but on the other hand the most brilliant construct which is sloppily formatted can also not be called good code.

The problem with auto-format for me is mostly that it disturbs the versioning system. A one-time conversion of formatting - without any other changes - may however well improve the workflow.