Sorting out tabs vs spaces in the codebase

Right now the source code of the C core is an unholy mixture of tabs vs spaces. I believe that initial versions of the source code used a fairly esoteric configuration where the general indentation size (“sift width” in vim lingo) was 2 spaces, but every 8 consecutive spaces were replaced with a single tab, which probably mixes the worst of both worlds.

I think it would be great if we could settle on a common style and follow it consistently, probably by setting up an .editorconfig file in the root and/or adding a pre-commit hook that enforces the chosen style. I’m a spaces guy (2 or 4), but I can adapt if the community chooses otherwise.

Obligatory reference to the tabs vs spaces video:

Yes, agree completely (I’m pro 2 spaces, but can live with 4 spaces)! We already discussed this before, and I think we are all on the same page here. I think we waited with reformatting until all PRs were merged. Perhaps it is an idea to reformat the entire code base then shortly after January 19?

Sounds good to me! I’ll do it after the 19th.

1 Like

I would leave code borrowed / included from other projects alone, to make it easier to upgrade them to newer versions, and not to interfere with diff too much. Most such borrowed code had to be slightly changed when including it in igraph. When upgrading, one has to figure out which changes were made for igraph and which changes are from the new version of the package.

I am thinking of packages like Bliss is Cliquer. I upgraded Bliss in the past and I am currently in the process of upgrading it again (for post 0.8).

Since most (though not all) such borrowed code uses 4 levels to indent (either with space or size-4 tabs), I would vote for standardizing igraph on 4 spaces to make it as uniform as possible. (Otherwise I don’t have strong feelings about the style—whatever works for me for as long as it’s consistent.)

Yes, excellent point!

Well, it turns out that we can make a poll in Discourse, so here we go: :slight_smile:

  • 2 spaces
  • 4 spaces

0 voters

1 Like