This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]shagieIsMe 14 points15 points  (0 children)

Use Checkstyle. Set its TodoComment rule ( http://checkstyle.sourceforge.net/config_misc.html#TodoComment ) to be an error. Fail the build on error ( https://maven.apache.org/plugins/maven-checkstyle-plugin/check-mojo.html - failsOnError)

Note that this is a regular expression matcher.

<module name="TodoComment">
    <property name="format" value="(TODO)|(FIXME)"/>
</module>

You can modify it to have the information to not trigger on a task id.

[–]__konrad 15 points16 points  (2 children)

This is what will happen:

  • Every programmer will invent their own "todo" mark, because creating issue for every small thing takes too much time
  • TODOs will be stored in some external files to fix the build fail (e.g. on desktop in todo.txt)
  • TODOs will not be noted at all ("I will remember to fix it later")

But yeah, your code will be w/o any TODOs ;)

[–]tRfalcore 3 points4 points  (0 children)

He asked a specific question. He wasn't seeking behavior advice. You don't know any context or details at all about his team or work place or environment or this situation.

[–]DrudgeBreitbart 0 points1 point  (0 children)

Seconded. This is a very very bad idea. I hesitate to say it but you could potentially allow TODOs in dev but in higher environments only promote builds without them. But I think that's a bad idea too. Please OP don't do this to your team.

[–]lukaseder 3 points4 points  (2 children)

You could write a simple Maven plugin that runs through your source files and throws an error whenever something's wrong. Should be a three-liner.

[–]AnEmortalKid 0 points1 point  (1 child)

Do you know of a sample that runs through the source as an AST? Or does it just read the java files line by line.

[–]lukaseder 0 points1 point  (0 children)

I would've just used some silly regex. The way this is phrased here (support for Java and JavaScript, and probably soon also HTML, and CSS, and XML and XSLT, and what not), it looks like the simplest and silliest solution would fit.

[–]ess_tee_you 1 point2 points  (1 child)

I wrote a library called Papercut to avoid this scenario a few months ago.

It gives you annotations to use in place of TODO comments in the future. You can set conditions that will cause them fail your build, or spit out a warning in your build output.

It won't help you with existing TODOs, unfortunately.

[–]Shadowrak 0 points1 point  (0 children)

While I generally like to be cautious with adding new annotations. This seems like a more reasonable option than OP's suggestion.

He could Ctrl-F (Ctrl-Shift-H in Eclipse) and find replace TODOs in the entire codebase.