Intellij 中的 FindBugs - 可以重用 .fbpref 文件吗?

FindBugs in Intellij - Possible to reuse .fbpref file?

最初 Eclipse 占主导地位,因此在 Eclipse IDE 中进行的设置现在正在转移到 IntelliJ。

我正在为 IntelliJ 安装 Findbugs 插件。我遇到了 FindBugs-IDEA 和 QAPlug-Findbugs.

我检查了两者,它们需要一个 .xml 文件作为可能的“规则集”。不过,我只有来自 eclipse 的 .fbpref 文件,它看起来像这样:

...
detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
detectorAtomicityProblem=AtomicityProblem|true
detectorBadAppletConstructor=BadAppletConstructor|false
detectorBadResultSetAccess=BadResultSetAccess|true
detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true
...

是否可以将其转换为我提到的其中一个插件接受的 .xml 文件? 是否有关于这些插件的 .xml 文件应该是什么样子的文档?我试过谷歌搜索,但没有成功。

使用配置文件来配置 FindBugs-plugin 的行为似乎有些不寻常的做法?

如果您安装了 FindBugs 插件,XML 文件已经存在:

project/.idea/findbugs-idea.xml

但是 .fbprefs 没有转换器。您可以打开两个设置 windows:

  • 日食:Project > Properties > FindBugs
  • IntelliJ:File > Settings > Other Settings > FindBugs-IDEA

并手动复制这些设置。您还可以打开这两个文件(xml.fbprefs)并通过复制和粘贴(尤其是检测器)更快地移动一些设置。

有一项很棒的服务叫做 Transformy,它可以轻松改造这些检测器。在左侧面板中插入检测器线:

detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|false
detectorAtomicityProblem=AtomicityProblem|true
detectorBCPMethodReturnCheck=BCPMethodReturnCheck|false
....

并以此为格式进行转换:

<entry key="AppendingToAnObjectOutputStream" value="false" />

不幸的是,它弄乱了包含数字的规则,例如 FindSelfComparison2,因此请手动复制这些规则。