Java FindBugs 未显示找到的错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6395546/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
FindBugs not showing the bugs found
提问by stivlo
I've used FindBugs before and I didn't have problems, however this time on Eclipse Helios on Ubuntu Natty Narval bugs are found but not shown.
我以前使用过 FindBugs 并且我没有遇到问题,但是这次在 Ubuntu Natty Narval 上的 Eclipse Helios 上发现了错误但没有显示。
Here's what I tried:
这是我尝试过的:
- Right Click on the project > Find Bugs > Find Bugs
- Looking at the progress I saw 3 bugs were found
- In the Problems view they are not listed
- 右键单击项目> Find Bugs > Find Bugs
- 查看进度发现3个bug
- 在问题视图中,它们未列出
I tried to go to its own perspective with: Open Perspective > Other > FindBugs but Bug Explorer is empty.
我试图通过以下方式进入自己的视角:打开视角 > 其他 > FindBugs 但错误资源管理器是空的。
Any ideas to view those bugs?
有什么想法可以查看这些错误吗?
UPDATE:In Eclipse error log I see:
更新:在 Eclipse 错误日志中,我看到:
!ENTRY edu.umd.cs.findbugs.plugin.eclipse 2 2 2011-06-18 21:13:24.968
!MESSAGE The following classes needed for FindBugs analysis on project **
were missing:
!SUBENTRY 1 edu.umd.cs.findbugs.plugin.eclipse 2 0 2011-06-18 21:13:24.969
!MESSAGE org.apache.commons.exec.CommandLine
!SUBENTRY 1 edu.umd.cs.findbugs.plugin.eclipse 2 0 2011-06-18 21:13:24.969
!MESSAGE org.apache.commons.exec.DefaultExecutor
!SUBENTRY 1 edu.umd.cs.findbugs.plugin.eclipse 2 0 2011-06-18 21:13:24.969
!MESSAGE org.apache.commons.exec.ExecuteException
UPDATE 2:I don't know how to fix Eclipse, but I found a workaround. I added the findbugs report to maven's pom.xml
更新 2:我不知道如何修复 Eclipse,但我找到了一个解决方法。我在 maven 的 pom.xml 中添加了 findbugs 报告
<reporting>
<plugins>
[...]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.3-SNAPSHOT</version>
<configuration>
<xmlOutput>true</xmlOutput>
<!-- Optional derectory to put findbugs xdoc xml report -->
<xmlOutputDirectory>target/site</xmlOutputDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
The following configuration generates an HTML report in target/site/findbugs.html
以下配置在 target/site/findbugs.html 中生成 HTML 报告
回答by mliebelt
This may be a problem of the configuration of your problems view. Do the following steps to ensure that the findbugs findings are shown in the problems view:
这可能是你的问题视图的配置问题。执行以下步骤以确保 findbugs 结果显示在问题视图中:
- Select the problems view (no findbugs warnings or errors shown)
- Select from the drop-down menu of the problems view (Caret down button) the menu entry "Configure Contents..."
- Select in the left side view e.g. "Errors/Warnings on Project"
- Ensure that on the right side, in the Types list, all the Findbugs Types are selected.
- Finish the configuration of the view.
- 选择问题视图(未显示 findbugs 警告或错误)
- 从问题视图的下拉菜单(Caret down 按钮)中选择菜单项“配置内容...”
- 在左侧视图中选择例如“项目错误/警告”
- 确保在右侧的“类型”列表中,选择了所有 Findbugs 类型。
- 完成视图的配置。
Now the problems view should show you the 3 findings of before.
现在问题视图应该显示之前的 3 个发现。
Alternatively, you could use the Findbugs perspective to get a deeper insight of the problems found.
或者,您可以使用 Findbugs 透视图来更深入地了解所发现的问题。
I have found an additional entry at the Findbugs Eclipse Plugin Page: Eclipse Plugin loads, but does not work correctly. Check that as well.
我在 Findbugs Eclipse 插件页面找到了一个额外的条目:Eclipse 插件加载,但无法正常工作。也检查一下。
When Findbugs tries to analyze your classes (not: the source code), the classes used by your code have to be available. I do not know for which bug patterns this is necessary, but for some (flow analysis), the used classes have to be reachable. So ensure that the used classes (directly or indirectly) are visible in the loadpath of eclipse.
当 Findbugs 尝试分析您的类(而不是:源代码)时,您的代码使用的类必须可用。我不知道这对于哪些错误模式是必要的,但对于某些(流分析),使用的类必须是可访问的。所以确保使用的类(直接或间接)在 eclipse 的加载路径中是可见的。
回答by Ray Toal
If you have bugs showing up in some projects but not others, the problem may be that the bugs in one project are just not severe enough to show up.
如果您在某些项目中出现了错误,而在其他项目中没有出现,则问题可能是某个项目中的错误不够严重而无法显示。
I had the same issue (30 bugs showing up in Open Analysis Results in Editor) but none in Problems view or Find Bugs Explorer. The following worked for me:
我遇到了同样的问题(在编辑器的打开分析结果中显示了 30 个错误),但在问题视图或查找错误资源管理器中没有。以下对我有用:
1. Project -> Properties -> Find Bugs
2. Enable Project Specific Settings
3. Check everything under Report Visible Bug Categories
4. Slide minium rank to report to 20
5. Set minimum confidence to Low
6. Rerun FindBugs
回答by i84c0re
I just stumpled upon a similar problem when using maven, eclipse and m2e-code-quality plugin (https://github.com/m2e-code-quality/m2e-code-quality). Solution was to list all visitors which should be run in a visitors tag in the configuration of the findbugs-maven-plugin. Also you may want to set maxRank to 20. When you omit the visitors to run the m2e-code-quality plugin will generate a findbugs plugin config which runs NO visitor at all. Worst part is that the findbug settings in the project properties will show some enabled visitors but these don't come from the project config.
我只是在使用 maven、eclipse 和 m2e-code-quality 插件(https://github.com/m2e-code-quality/m2e-code-quality)时遇到了类似的问题。解决方案是在 findbugs-maven-plugin 的配置中列出应该在访问者标签中运行的所有访问者。此外,您可能希望将 maxRank 设置为 20。当您省略访问者以运行 m2e-code-quality 插件时,将生成一个 findbugs 插件配置,该配置根本不运行任何访问者。最糟糕的是,项目属性中的 findbug 设置将显示一些已启用的访问者,但这些并非来自项目配置。