Hi guys,
Looks like we have different ways of indent our files.
I 've seen these occurrences for a single indentation on drools trunk:
- java files:
-- 4 spaces
-- 1 tab
- xml files:
-- 4 spaces
-- 3 spaces
-- 2 spaces
-- 1 tab
- drl files:
-- 4 spaces
-- 2 spaces
-- 1 tab
I've seen different types mixed in the same line regularly. One
developer created the line, another developer wrapped it in an if statement.
The problem
===========
What's the problem with mixing these different types?
- It stimulates merge conflicts.
- It obfuscates diffs.
- It hampers with readability.
Some editors show \t as 2 spaces, others as 4, others as 8. Most
notably, in plain HTML, firefox etc show it as 8 spaces IIRC.
So line A with 2 indentations of 4 spaces each
and line B with 2 indentations of 1 tab each
are not rendered starting from the same column.
The solution proposals
======================
We should agree on what to use.
Then simply configure it in eclipse/intellij:
- In eclipse you need to set it several times:
-- once in the java style (or import the eclipse-formatter.xml)
-- once in the xml style (even if you import the eclipse-formatter.xml file)
-- once in the text style (even if you import the eclipse-formatter.xml
file)
- In intellij, do it in code style/general.
Proposal 1) Use 4 spaces in java, xml and drl to indent.
Pro:
- The current drools eclipse formatter, trunk/eclipse-formatter.xml
states this for java files. Note that it says nothing about xml or drl
files because those need to be configured separately in eclipse, which
is probably the reason why some of use spaces for java files and tabs
for xml files.
- Most of our java files currently use 4 spaces
- The "Sun java coding conventions" state we should use 4 spaces.
http://www.oracle.com/technetwork/java/codeconventions-136091.html#262
"Four spaces should be used as the unit of indentation."
Proposal 2) Use 4 spaces in java and 2 spaces in xml and drl
Pro:
- xml files can have deep indentations and 2 spaces might be clear enough
Proposal 3) Use 1 tab in java, xml and drl to indent.
Pro:
- Eclipse uses 1 tab by default for xml files (and maybe also for java
files?)
My opinion (vote?)
==================
Proposal 1) Use 4 spaces in java, xml and drl to indent.
PS
==
Please keep this topic isolated to the spaces VS tabs problem.
If you'd like to open the topic of the coding style which differs
between developers, please do so in a separate topic, as that one can be
long and unfulfilling discussion and I 'd like to settle the spaces
quickly...
--
With kind regards,
Geoffrey De Smet