how to integrate TODO handling into the maven test phase?
Asked Answered
H

2

6

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.

Horthy answered 27/7, 2010 at 7:11 Comment(1)
You're better off generating a report than failing a test or a build. The latter will get your developers to remove all TODOs to make a build succeed. Imagine the fun when the missing TODOs have to be accounted for; yeah, emails will be sent, alarms would go off, heads will roll etc. but a bit too late.Enscroll
C
3

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

Carburet answered 27/7, 2010 at 7:24 Comment(2)
fail the build is a bit too radical for my taste, but if i dont find anything else, ill definitely check out that pluginHorthy
@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 or not. You could also choose to generate a report instead. It's up to you.Carburet
E
3

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.

Enscroll answered 27/7, 2010 at 7:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.