views:

43

answers:

2

suppose i have a project with lots of todos, some unintentionally left there, some no longer relevant, some represent future possible features etc.

i know that most IDEs can show/filter/sort them, but im looking for a way to enforce a more strict policy.

what im looking for is some maven plugin that i can bind to the test phase that looks for TODOs of a specific format (for example //TODO-Ver ...) and, if any are found, generates a test failure (which would then be visible via hudson, emails will be sent, alarms would go off, heads will roll etc).

this extra execution would be bound to the test phase under some profile that will only be activated close to the dev cycle end or something.

my question is has anyone done anything like this before ? what code inspection tools can be tailored to look for TODOs by regexp, and what maven plugin can be used to run said inspection tools ? is it possible to do from a unit test ? any comments/ideas/suggestions would be welcome.

+3  A: 

Checkstyle can do that (see the TodoComment check) and you could use the maven checkstyle plugin and its checkstyle:check goal to check the code and fail the build in case of violation (usually during the verify phase).

Pascal Thivent
fail the build is a bit too radical for my taste, but if i dont find anything else, ill definitely check out that plugin
hatchetman82
@hatchetman82: Well, you spoke about rolling heads, not me :) And if you want Hudson to send emails, you should fail the build. Anyway, you can configure the plugin to [`failOnViolation`](http://maven.apache.org/plugins/maven-checkstyle-plugin/check-mojo.html#failOnViolation) or not. You could also choose to generate a report instead. It's up to you.
Pascal Thivent
+1  A: 

The checkstyle plugin has already been pointed out, so I'll introduce the Taglist Maven plugin that looks for TODO, FIXME tags in the source code and can produce a report of the usages of all such tags. Of course, it is customizable, so you can put in your own tags to search for; regexes also seem to be supported.

Vineet Reynolds