maven findbugs“高水位线”
[findbugs 是这里的例子,问题适用于任何这样的 Maven 插件]
我不久前参加了一个构建讲座,其中谈到的一个我非常喜欢的模式是:当向链中添加一个新工具时,你从 n 开始违规,您应该保持 n 减少(高水位线),并且仅当当前检查超过 n 的最后一个值时构建才会失败。
findbugs 刚刚被引入到我们的构建中,我们正在寻找一种方法来实现此模式。我们看不到任何通过插件配置来做到这一点的方法,所以很好奇是否有人可以提及他们是如何实现这一目标的。我想显而易见的方法是自定义插件,但在我们继续前进之前,想听听其他人的想法。
[findbugs is the example here, question is applicable to any such maven plugin]
I attended a build lecture not long ago and a pattern that was talked about that I quite liked was: when adding a new tool to the chain and you start with n violations, you should keep n decreasing (a high water mark) and fail the build only when current check exceeds the last value of n.
findbugs has just been introduced to our build and we were looking for a way to implement this pattern. We couldn't see any way to do it via the plugin configuration, so was curious if anyone out there could mention how they have achieved this. I guess the obvious way is to customize the plugin, but before we go charging ahead, would like to hear thoughts from others.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Findbugs(以及我所知道的所有其他代码指标插件)生成 一个 XML 文件。我要做的是编写一个专门读取这些 xml 文件的 Maven 插件。它将在某处保留一个私有查找表,用于存储每个构建、每个指标的最后值。
它将使用一个通用的解析器接口,您必须为每个指标插件实现该接口。配置将是这样的:
Findbugs (and all other code metrics plugins I know of) generates an XML file. What I would do is write a maven plugin that specializes in reading these xml files. It would keep a private lookup table somewhere, where it stores per build, per metrics last values.
It would use a common parser interface which you would have to implement for each metric plugin. The config would be something like this:
我认为 FindBugs 的情况有点特殊:违规不仅仅是表面上的,它们可能是真正的错误,因此应该修复,至少是高优先级错误(即使用
高
阈值时)。以防万一,我们遵循类似的模式(我们对完成的定义包括不增加技术债务),但我们没有在 Maven 中实现它(并且我们不会使构建失败)。我们使用 Sonar 及其 时间机器 跟踪指标演变(我们跟踪每日演变)。它对我们来说效果很好,即使它不如构建失败那么强大。
The case of FindBugs is in my opinion a bit particular: violations are not just cosmetic, they may be real bugs and should thus be fixed, at least high priority bugs (i.e. when using the
High
threshold).Just in case, we follow a similar pattern (our definition of done includes a no technical debt increase) but we didn't implement it in Maven (and we don't fail the build). We use Sonar and its time machine to track metrics evolution (we track the daily evolution). It works well for us, even if it's not as strong as failing the build.
我在 Maven findbugs 跟踪器中提出了这个问题(请参阅 http://jira.codehaus.org/浏览/MFINDBUGS-115)。
此外,作为提出这个问题的一部分,我编写了一个提交的补丁。我们在大型多模块项目中成功运行了此补丁。
您可以按照 findbugs-maven-plugin 站点上的说明同步代码并应用补丁,或者希望该补丁或其派生版本可能会被插件的未来版本所接受。
I have raised this issue in the maven findbugs tracker (see http://jira.codehaus.org/browse/MFINDBUGS-115).
Further as part of raising this I have coded a submitted a patch. We are running this patch with success in our large multi-module project.
You could either sync the code and apply the patch by following the instructions on the findbugs-maven-plugin site or hopefully the patch or a derivation of it might be accepted into some future version of the plugin.
有趣的是你提到了这一点,因为我现在正在为我的雇主做这件事。我们剥离了一个开源项目来开展这项工作,名为 dybdob;因为它非常是一项正在进行中的工作,所以现在存储库中的代码相当糟糕并且非常硬编码/hacky。然而,计划或多或少地按照 Seanizer 的建议进行:解析 XML,保留计数,如果增加则失败。
我实现的第一件事(同样:硬编码、hacky 和未记录)是一个插件,用于实际计算构建中发出的 javac 编译器警告,并在数量增加时中断构建。现在可以了,我目前正在并行处理 findbugs、checkstyle 和 pmd 警告。
希望您能检查一下,如果您有兴趣提供帮助(或者只是想看看它是如何演变的),请给我写信。
Funny that you mention this, because I'm working on exactly this for my employer at the moment. We've spun off an open-source project to hold the work, called dybdob; as it is very much a work in progress, the code that's in the repo right now is rather horrible and very hardcoded/hacky. However, the plan is to do more-or-less exactly what seanizer suggests: parse the XML, keep the counts, and fail if increased.
The first thing I implemented (again: hardcoded, hacky, and undocumented) is a plugin to actually count javac compiler warnings coming out of the build, and break the build if that amount increases. That's now working, and I'm currently working on findbugs, checkstyle, and pmd warnings in parallel.
Would love for you to check it out, and drop me a line if you're interested in helping out (or even just want to see how it evolves).