On 05/04/2018 05:41 AM, Rene Hopf wrote:
> There is a mix of tabs and spaces in the code, sometimes even mixed in the 
> same line,
> and loads of bad indentation. Im not blaming anyone here,
> that just happens with such an old codebase with so many contributors.

Agreed, it's a suboptimal situation that sometimes happens in old code
bases.


> However, I could not even find coding style guidelines.

We have two that i discovered with "git grep 'coding.*style'":

docs/src/code/style-guide.txt
src/CodingStyle


> Imho the only way of fixing that is with some automatic formatter.
> I think clang-format is the best: https://clang.llvm.org/docs/ClangFormat.html

I agree that using a automated formatter is the best way to achieve and
enforce uniform coding style.

I've worked in the FreeBSD kernel project, which has a strict
indentation policy and the resulting project-wide uniform code style,
and i must say i liked it.

However, I don't think it's a good idea to implement this in LinuxCNC
today.  Project-wide reformatting of the code solves the "inconsistent
indentation" problem, but introduces new, worse problems:

* It makes it harder to understand how the meaningful (ie,
non-whitespace) contents of the file have changed over time.

* It makes it harder to apply patches across the indentation-change
boundary.  For example, if we reindented master, it would be harder to
merge bugfixes from 2.7 into master.

I ran clang-format on all *.{c,cc,cpp,h,hh,hpp} files in src/, using the
LLVM style but with IndentWidth set to 4, and the resulting diffstat is:

 554 files changed, 129919 insertions(+), 128645 deletions(-)

That's just totally unmanageable, IMO.


That said, if a developer comes across incorrect or misleading
indentation while working in our code, it would clearly help the project
out if they fixed it locally, in that spot.


-- 
Sebastian Kuzminsky

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to