OHDSI Home | Forums | Wiki | Github

Indent rules (at least for js, at least for ATLAS)

Frank just made a pull request for adding jshint to our development environment:

I haven’t tried it yet, but it seems like a great thing. It also reminds me to bring up something that’s been bugging me: indent standards. Apparently – http://jshint.com/docs/options/#indent – jshint isn’t going to help enforce indent rules, but it would be nice if we at least agreed on a standard. I had noticed that the majority of the code used tabs for indent, so that’s what I’ve been doing, and when I come across code that uses spaces, I convert to tabs. I would much prefer that we standardize on 2 spaces for indent. Tabs are a drag when looking at code in github (though there is an option to override the default of displaying them as 8 spaces) or in diffs.

There are still places in the code that are inconsistent (using something other than tabs) or just messed up (not having correct indenting levels). My having cleaned some of these up should make it easier to convert if we do decide on a standard.

What do other people think of two spaces? Any other preferences?

No preference but +1 on standardizing around one set of standards.

So the debate on this is long and both “sides” make valid points.

I happen to prefer tabs because I like small code indenting and any IDE I have used allows me to specify the Tab Size (which for me is set to 2). I like the flexibility this gives developers in terms of having the IDE display the tabs at whatever width they prefer.

We aren’t going to get everyone to agree on this but why don’t we take a day and let people reply via this poll and see where we come out.

  • We should use tabs with flexible IDE controlled tab sizes
  • We should obviously use two spaces!
  • Don’t be silly, we need to use four spaces!!

0 voters

Let me just make the case for spaces a little more clearly than I did above:

In diffs on github, the default is to expand tabs to 8 spaces. So a diff like this:
https://github.com/OHDSI/Atlas/commit/7edca0b2ab689444530cca841fc93c8a36d2da79#diff-4a2749a951896efbff8222ffd9dbd8aeR597 ends up pretty ugly and a little hard to read.

You can use ?ts=2 at the end of github urls to see code files with different tabwidth, but that doesn’t seem to work for diffs.

I agree that the diff looks awful on github. There appears to be a solution however where we could add a .editorconfig file to the repository that will set an override for how the code is displayed. That being said, I’m not using github for diff.

Oh, what diff do you use? I mostly see the diff on github when I’m reviewing commits.

When I’m reviewing what is in commits I’ll use Github Desktop which gives you a view like this:

For diffs I’ll use meld or winmerge or kdiff3.

Have been unable to make the Arch. calls recently owing to conflicting meetings, but wanted to throw my hat in the ring (Poll vote added).

Note - for “auto IDE” adherence - we have found the editorconfig standard (.editorconfig in repo root) to be great for enforcing these rules across the various IDEs our engineers prefer. Have not found a mainstream IDE yet that does not support it.

http://editorconfig.org/

t