Red Flag In PR's For A Software Dev
S-01 | Reject a pull request with White Spaces immediately!
As a Senior Software Engineer we all come across the path where we need to review other people's code and in doing so, we may experience some unusual things such as,
- Extra white spaces.
- Unconventional naming sense
- Illogical functional Name
- Awkward functional Calling
- Spaghetti Code
and you just sit there thinking like! W.T.H is going on?
Starting off!
Don’t. Reformat. Code. In. Feature. Pull. Requests.
Look, I don’t really care about formatting. As long as it isn’t a gratuitously stupid format, I’m willing to work with it. And if your editor automatically re-formats the files you are actively working in, I’m even willing to accept white-space changes to relevant files.
But,
DO NOT set up your IDE to auto-format THE ENTIRE PROJECT, and then push a PR with a 3 line feature change and 500 lines of filler.
Imagine 50+ Pages of this Hell
- It’s annoying.
- It makes it incredibly difficult to figure out what changed.
- You are going to cause merge conflicts for everyone else who is working in the project
- You will clutter the git history, so ‘git-annotate’ will show your white-space commit, not a meaningful message.
Most importantly, it is Time wasting && annoying!.
Let’s think of some real world analogs:
You invite a guest over to your house. Guest uses the bathroom. Guest notices some hair on the sink. Guest uses a paper towel to wipe it up. Cool ! Polite !
You invite a guest over to your house. Guest uses the bathroom. Guest walks upstairs to master bedroom, and begins re-folding clothes. Bad! Bad guest!
The Right Way
If you must reformat a large code-base, announce it to your team like this:
- HEY GUYS. I’M ABOUT TO BE REALLY ANNOYING AND FIDDLY.
- INSTEAD OF LEARNING GOOD COPING TECHNIQUES FOR MY ANXIETY AND OBSESSION, I AM GOING TO REFORMAT THE ENTIRE CODE BASE
- PLEASE PLEASE LET ME KNOW IF YOU HAVE OUTSTANDING PR'S OR BRANCHES SO I CAN NOT CLOBBER THEM WITH STUPID WHITE-SPACE CHANGES
- I WILL NEVER, EVER SUBJECT YOU TO THIS POINTLESS ACTIVITY EVER AGAIN!
Then, submit the reformat as a PR WITH NO OTHER CHANGES, merge it IMMEDIATELY, and go back to doing useful work.
And ask yourself whether that was really worth it.