如何将 TODO 处理集成到 Maven 测试阶段?
假设我有一个有很多待办事项的项目,有些无意中留在那里,有些不再相关,有些代表未来可能的功能等。
我知道大多数 IDE 可以显示/过滤/排序它们,但我正在寻找一种方法来强制执行更多严格的政策。
我正在寻找的是一些 Maven 插件,我可以将其绑定到测试阶段,该测试阶段会查找特定格式的 TODO(例如 //TODO-Ver ...),并且如果找到任何 TODO,则会生成测试失败(这将导致然后通过哈德森可见,将发送电子邮件,警报将响起,头将滚动等)。
这个额外的执行将被绑定到某个配置文件下的测试阶段,该配置文件只会在接近开发周期结束或其他情况时被激活。
我的问题是以前有人做过类似的事情吗? 可以定制哪些代码检查工具来通过正则表达式查找 TODO,以及可以使用哪些 Maven 插件来运行所述检查工具?可以通过单元测试来做吗? 欢迎任何意见/想法/建议。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Checkstyle 可以做到这一点(请参阅 TodoComment 检查),您可以使用 maven checkstyle 插件 及其
checkstyle:check
目标是检查代码并在违规情况下使构建失败(通常在验证
阶段)。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 theverify
phase).checkstyle插件已经指出了,所以我介绍一下Taglist Maven插件 在源代码中查找 TODO、FIXME 标签,并可以生成 以下内容的报告所有此类标签的用法。当然,它是可定制的,所以你可以放入自己的要搜索的标签; 正则表达式似乎也受支持。
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.