how to integrate TODO handling into the maven test phase?

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.

Answer

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).

Leave a Reply

Your email address will not be published. Required fields are marked *