Latest Posts

Topic: Tabs or Spaces

stonerl
Avatar
Topic Opener
Joined: 2018-07-30, 00:03
Posts: 327
Ranking
Tribe Member
Posted at: 2018-08-19, 21:44

Looking through the files I noticed that the lua files use 3 spaces for indentation, while the c++ part uses a 3 spaced tab. But some files use a mix of tabs and spaces; launch_mpg.cc for example.

The Contribute Site references the Google Style Code, but there it says no tabs only 2 spaces...


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2018-08-20, 09:52

SirVer and I didn't really agree on this - I prefer tabs, he prefers spaces. SO, there was never any consensus.

Lua should definitely use spaces now, because we have a script for fixing the indentation that depends on it.

I'm surprised that clang-format doesn't unify matters for C++ though - we run it on every merge to trunk.


Busy indexing nil values

Top Quote
stonerl
Avatar
Topic Opener
Joined: 2018-07-30, 00:03
Posts: 327
Ranking
Tribe Member
Posted at: 2019-05-09, 15:15

Could we agree on tabs for all c++ and spaces for lua files? Lua files are all spaced, while c++ files are predominantly tabbed and especially hard to work with since some of them have spaces and tabs mixed all over the place.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2645
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2019-05-09, 16:11

I recently saw that spaces in C++ were often used if codelines had to be continued in the next line due to longer than our max line length. I sometimes had the impression that these were formatted this way by a script but I don't know for sure.


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2019-05-10, 08:37

Bunnybot uses clang-format when merging to master, and also runs a script that SirVer wrote to fix the indentation in Lua. clang-format is set to use tabs, Lua is formatted with spaces. So, this is already being done as you suggest.

clang-format is controlled by a .clang-format file in our repository. The tricky bit is that it will still produce different results on different machines, so we let only bunnybot run it.

I'm against doing a whole-sale reformatting right now, because we have a lot of branches open.


Busy indexing nil values

Top Quote