Today’s simple tip will show you how to check for lingering “TODO” comments before you push your code up to your shared repository.
[more]
Have you ever dropped a TODO in your code to remind you to come back and refactor or clean something up later? I’ll do that quite often when I’m hashing out changes for a new feature or bugfix:
File 2 content! This is File 2, Line 2! //TODO: Come back and add more lines!
I’ll usually clean those up pretty quickly, but sometimes I forget to go back and get them all. Fortunately, git makes it very easy for me to find any lingering TODOs. Just run this command from your posh-git console:
git show HEAD | sls -SimpleMatch "TODO" -Context 5
If your last commit included any new TODOs, you’ll see the relevant block of the commit, and you can investigate further. You can scan an older commit by substituting the commit’s hash in place of “HEAD” in the command above.