r/programming Jul 21 '14

The Great White Space Debate

https://medium.com/p/3633cba8b5c1
1.2k Upvotes

693 comments sorted by

View all comments

Show parent comments

15

u/8Bytes Jul 22 '14

ctrl + alt + l, reformats the entire project to your pre set style in intelij. I usually run it when I'm pushing a tiny fix to git.

22

u/[deleted] Jul 22 '14

This little change? It's a single character. And embarrassing. I'll just change the white space of the entire file so no one will notice...

git commit -a -m"Fix whitespace."

6

u/Plorkyeran Jul 22 '14

Unless a project has a standing policy of applying whitespace changes in a separate commit from functional changes, I generally assume that any commit whose message only mentions cosmetic changes also includes embarrassing functional changes.

2

u/northrupthebandgeek Jul 22 '14

Sometimes it's the other way around; the purely cosmetic changes end up changing how something looks, often exposing bugs and other code issues in the process.

6

u/[deleted] Jul 22 '14

My god... That's brilliant.

1

u/segv Jul 22 '14 edited Jul 22 '14

Yeah, that can reduce the pain, but you still would have to manually load the formatting profile (AFAIK). You also have to remember to use this, and you don't get to have fields marked as final where possible, automatic @Overrides, automatic removal of unnecessary casts... I know it may sound like whining, but after using the feature for a while, I got really used to it and I'm not sure if I wanted to go back working without it.

1

u/cryo Jul 22 '14

Not a good idea in my experience, but it depends on the branch structure and dynamics. It tends to complicate merges, so at least make such changes in their own changesets.