FindBugs 新公式

发布于 2025-01-05 08:48:20 字数 633 浏览 4 评论 0原文

我经常犯这种错误,而不是:

Toast.makeText(this, getString(R.string.string_id), Toast.LENGTH_SHORT).show();

我这样做:

Toast.makeText(this, getString(R.string.string_id), Toast.LENGTH_SHORT);

我认为,这应该可以用 FindBugs(或任何其他静态分析实用程序)检测到,我目前在 Eclipse 中使用它。

条件:

  • 静态调用
  • 我们不保存返回值

消息类似:

您显然忘记保存调用的返回值,或者您缺少对返回的 Toast 变量的 .show() 调用

此消息严格局限于此类错误,但它可能包含更多条件或此可能是一些常见的错误。

但我确实怀念的是一些教程,我们如何向 FindBugs 数据库添加新食谱。您能否指出我在搜索中未找到的地方,或者为我提供另一种解决方案来查找此类问题?

I often do this kind of mistake, instead of:

Toast.makeText(this, getString(R.string.string_id), Toast.LENGTH_SHORT).show();

i do this:

Toast.makeText(this, getString(R.string.string_id), Toast.LENGTH_SHORT);

I think, this should be detectable with FindBugs (or any other static analysis utility), which I currently use with Eclipse.

Conditions:

  • static call
  • we don't save the returned value

Message similar to:

You apparently forgot to save returned value of call, or you're missing .show() call on returned Toast variable

This message is strictly localized to this type of mistake, but it could contain more conditions or this can be some common mistake.

But what I do miss, is some tutorial, how can we add new recipes to FindBugs database. Can you please point me to place I haven't found in my search or offer me another solution for finding this kind of problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落叶缤纷 2025-01-12 08:48:20

到目前为止,我可以看到两个可以帮助您的链接:

前者符合条件我想,作为一个教程。

So far I can see two links that can help you:

The former qualifies as a tutorial, I guess.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文