Managing TODOs

While working on big projects I occasionally find myself taking shortcuts when a subsystem needs more work. For example, when working on rendering weapons and attacks the focus might just be on the rendering part, but there is also work to be done on how to manage which weapon to render. Instead of getting sidetracked from my original goal, I’ll add an inline TODO comment and use a placeholder weapon to render.

In this post I’ll focus on how I manage and track these useful inline comment notes through my workflow:

Android Studio / IntelliJ IDEA

IntelliJ IDEA already has really good support for TODOs I mainly extended it to my preferences.

Live Templates

Android Studio comes with some existing Live Templates to quickly write TODOs with a specified template.

TODO Live Template in Android Studio

You can configure the template text as you see fit (Go to Preferences > Editor > Live Templates). Utilize live template variables if you wish to append information like the current date or name files.

In my case I append the current date followed by whatever comment that gives me some good context.

TODO Tracking

Android Studio / IntelliJ already has built in TODO tracking for 2 patterns. You can add and customize them by going to Preferences > Editor > TODO. In total I use 4 patterns to cover all my cases (context wise).

Patterns and custom filters based on those patterns

You can customize the pattern, icon and text style of the TODO comments to make them stand out. Then you can track your projects TODOs via the tool window:

Visual Studio Code

I utilize VSCode to mostly work on my server code, which is written in Go.

Code Snippets

Similar to IntelliJ’s Live Templates, VSCode provides support for Code Snippets and you can to add these yourself.

Go to Preferences > User Snippets and select either New Global Snippets file... or New Snippets file for 'your-project'. This will create a new JSON file under your-project/.vscode. Call it TODO.code-snippets and place the following code:

You can customize the variables to fit your own template. Check all valid syntax options at official VSCode Documentation.

Finally going to a file and writing the prefix will quickly place the template.

TODO Highlighting and Tracking

Unlike IntelliJ, VSCode does not have built in TODO tracking. With that said, the market place contains plugins that kindly provide this feature.

Todo Tree Extension

I downloaded an extension called Todo Tree and configured it to give me the highlighting I want for each tag. Install the extension and go to your global or project’s settings.json file and add the following between the file’s brackets:

This configures the 4 tags with a different icons and color to make them stand out:

Open Todo Tree’s window and you can see a list of all the projects TODOs with all your new tags.

Git Hooks

Git is a great source control tool and one feature I really like is it’s customizable hooks. I use hooks to run scripts that analyze code changes and run tests. A great tool for this is Overcommit. It allows you to easily configure the hooks and share them with everyone in project.

git commit hook checks

As you can see one of the post-commit hooks I run is really dumb bash script that prints a colored list of the current number of TODO tags I have in the whole codebase.

To set this up you should first install Overcommit and got through any initial hook setup. Afterwards, in your projects source directory create a file called find-TODOs.sh and add the following:

Note: You may need to modify the colored echo function depending on your system. I use mac with ZSH shell and added the #!/bin/zsh at the top to support \e in my functions.

Afterwards in your terminal, navigate to the file’s folder and run:

  1. chmod +x find-TODOs.sh to give permissions
  2. ./find-TODOs.sh to execute the script
Output should look something similar (with no output for 0 tags)

If the script finds any tags it will exit with failure exit 1.

To configure Overcommit to execute the hook add the following to your .overcommit.yml file.

This runs a PostCommit hook that will only “warn” you of the number of TODOs in your codebase.

Run the following to update your git hooks:

  • overcommit --sign
  • overcommit --sign post-commit

That’s it. Next time you commit something you should see Overcommit run the hook.


Subscribe to my newsletter

Remember to subscribe to receive monthly updates about Clash Legacy!