You are currently looking at an older section of the wincent.dev website.
Please check the new version of the site at https://wincent.dev/ for updated content.

wincent knowledge base

« Locking, double-checked locking and speed | Main | Unit testing guidelines »

January 27, 2006

Lightweight issue tracking

I use Bugzilla to power my public feature requests and bug tracking database. But sometimes when I am writing code I want to quickly insert a reminder into the source code itself rather than opening an issue in the database. Rather than keeping a separate "TODO" list I just write a comment in the code like this:

// TODO: add user preference for opacity

If I later want to find all of the TODO items I can use Xcode's "Find In Project..." functionality or I can grep from the command-line. For this purpose I have the following function defined in my ~/.bash_profile:

# grep for "TODO" string
todo()
{
  if [ $# -lt 1 ]; then
    grep -R -n "TODO: " . | grep -v ".svn"
  else
    # loop through the args
    while [ -n "$1" ]
    do
      grep -R -n "TODO: " "$1" | grep -v ".svn"
      shift
    done
  fi
}

I can then use the function to grep for TODO items in the current directory, in a specific file (or files), or in a specific directory (or directories):

$ todo
$ todo .
$ todo WOSynergyAdvanceController.m
$ todo SynergyAdvanceFramework synergyd

I'll then see a list of matching file names, line numbers, and the TODO items themselves. Items in .svn directories are filtered from the output. If no arguments are supplied then the function starts the grep in the current directory. The output will look like this:

./WOITunesController.m:1683:    // TODO: add caching for this value

So that's lightweight issue tracking. You can do the same with bugs using a function like this:

# grep for "BUG" string
bugs()
{
  if [ $# -lt 1 ]; then
    grep -R -n "BUG: " . | grep -v ".svn"
  else  
    # loop through the args
    while [ -n "$1" ]
    do
      grep -R -n "BUG: " "$1" | grep -v ".svn"
      shift
    done
  fi
}

Posted by wincent at January 27, 2006 02:23 PM