Errant Whitespace Matters

July 09, 2014

Ugh! Why worry about something trivial like extra whitespace at the end of a line!!? Do you have mental problems or something or do you just hate me?

— Software Engineers Just Tryin’ to Get Stuff DoneTM

Confession time. I think asking developers to remove extra whitespace is important. This is a touchy subject but I think I can make a case so here goes.

Reason #1: Quality

Is software engineering science or art? At this point in my life I’m leaning in the art direction(I should definitely flesh out that idea more someday). Like other forms of art, craftsmanship matters. Think about a woodworker building a chair. Yes, the chair needs to not fall over when you sit in it. But it also matters how beautiful the finish is. The point is that details matter. If your shiny new code that implements that sweet new feature includes extra whitespace then you probably didn’t even bother to double check your commit, did you? If you didn’t bother to double check your commit, there’s a good chance that there are other issues besides the whitespace. Face it… you’re one of those artsy fartsy types now. It’s just that you’re medium is bits instead of wood. Take pride in your work.

Reason #2: Slippery Slope

I’ve seen this a bunch:

commit b41c6310ede83493c2202bc2e3757882b1351a28
Author: Damnthe Torpedoes <>
Date:   Wed Jul 2 15:36:19 2014 -0500

    [ticket #42] Switch to using  ball bearings

    It's all ball bearings nowadays

…with a diff that contains the ball bearing switch over…. along with a bunch of formatting changes automatically introduced by Damnthe’s helpful text editor. Those unnecessary changes makes it almost impossible to see the actual code change amongst the hundreds of lines of code that the editor modified. How am I supposed to review code like that?! How much of this extra junk should be allowed in a commit before somebody yells? I say rather than debate the degree, just say “none”.


Listen whiners… errant whitespace is one of those things that’s super easy to check using a script:

git diff-index --check --cached $against --

So just do it. It’ll make you a better developer. Also it’ll make us OCD types twitch just a little bit less.

P.S. I found errant whitespace in this post and fixed it before committing.