我正在使用PMD插件(版本4.0.2)用于Eclipse(Eclipse Kepler Java EE).我已经配置了一个命名规则:ShortVariable.
除了像"id"和之类的参数外,这种方法很好"e".我希望PMD忽略这些.所以我搜索了一种忽略某些参数的方法.我找到了这个链接(尽管它是用于phpmd)并尝试过,但我似乎无法让它工作.我的配置文件看起来像这样(XML):
<?xml version="1.0"?>
<ruleset name="My PMD ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>
My PMD
</description>
<rule ref="rulesets/java/naming.xml/ShortVariable">
<property name="exceptions" value="id" />
</rule>
</ruleset>
Run Code Online (Sandbox Code Playgroud)
当我尝试使用eclipse插件导入此规则集时,它显示没有可能导入的规则.有任何想法吗?
我有一个代码来检查变量的条件.
有时这个变量在内存中0xfdfdfdfd,当然它不能从那里读取.
如果变量为null,我会
if(!variable)
{
//report error or skip...
}
else
{
//do stuff with the variable...
}
Run Code Online (Sandbox Code Playgroud)
但显然0xfdfdfdfd意味着有一个变量,我只是无法访问它.
有没有我可以使用的检查(比如null),所以当我无法访问它时,我不会尝试弄乱变量?