有人知道是否有用于java的在线代码分析器。我希望能够检查一些小部分的代码。在线Java代码分析器
例如:该方法具有这样的警告:(空解引用)
private XMLGregorianCalendar asXMLGregorianCalendar(Date data) {
DatatypeFactory dateformat = null;
try {
dateformat = DatatypeFactory.newInstance();
} catch (MyException e) {
///
}
if (data == null) {
return null;
} else {
GregorianCalendar gregorianCal = new GregorianCalendar();
gregorianCal.setTimeInMillis(data.getTime());
return dateformat.newXMLGregorianCalendar(gregorianCal);
}
}
我的新版本是:
private XMLGregorianCalendar asXMLGregorianCalendar(Date data) throws ComponentBlockingException {
if (data == null) {
return null;
}
DatatypeFactory dateformat = null;
try {
dateformat = DatatypeFactory.newInstance();
} catch (MyException e) {
////
}
GregorianCalendar gregorianCal = new GregorianCalendar();
gregorianCal.setTimeInMillis(data.getTime());
return dateformat.newXMLGregorianCalendar(gregorianCal);
}
}
我认为第二种方式应该没问题。
我不知道在线工具,但最新的IDE应该涵盖这种类型的用例。 – assylias
也许ide一个[ideone.com](http://ideone.com/)? – mleczey
[FindBugs](http://findbugs.sourceforge.net/)不在线,但可以对这些事情有帮助,并且有一个体面的Eclipse插件。它还集成了Maven,Idea和NetBeans。 –