有人知道是否有用於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。 –