【问题标题】:FindBugs custom detector to check variable namingFindBugs 自定义检测器检查变量命名
【发布时间】:2015-03-15 10:07:20
【问题描述】:

我正在开发一个自定义 findbugs 插件,它可以在 java 类中查找变量命名错误。

例如 Button 变量必须以 btn* 开头,如果不是,请报告。

Button btnSave; // It's ok
Button close; //Report it, not starts with btn

我已经为这个项目工作了好几天。我可以检测方法命名错误、方法返回值错误等。但我无法检测到 -this simple- 变量命名错误。我尝试了很多代码片段,findbugs 文档对这种情况没有帮助。

此外,我无法调试我的自定义插件项目,每次更改都会占用我的时间。

谢谢。

【问题讨论】:

    标签: java variables findbugs static-code-analysis


    【解决方案1】:

    FindBugs 是一个对 字节码 进行操作的代码分析器。变量名是源代码的属性。

    使用其他静态分析器(例如 PMD)对源代码进行操作可能会更好。

    另见What are the differences between PMD and FindBugs?

    【讨论】:

    • Ooov :(。谢谢你。我要去检查一下。
    猜你喜欢
    • 2015-08-15
    • 1970-01-01
    • 2015-10-02
    • 2018-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多