klocwork を使用してバグ分析を行っているときに、警告が表示されNull pointer dereference of 'nextLineDn' where null is returned from a method
ます。
どうやら他の静的分析ツールfindbug
も同じ警告を出します。
しかし、明らかに、使用する前に null/empty をチェックしています。
int noOfLines = device.getLines().size();
if( lineNo != 0 && noOfLines > lineNo ) // if next line exists
{
nextLineDn = device.getDn(lineNo+1);
if(!Util.isNullOrEmpty(nextLineDn))
{
return (nextLineDn.contains("@")) ? nextLineDn.split("@")[0] : nextLineDn;
}
}
class Util
:
public static boolean isNullOrEmpty(String str) {
return (str == null || str.isEmpty());
}
誰かが私にこれについて何か考えを与えることができますか? 同じ条件で非常に多くの警告が表示されます。警告を削除するために他に何ができるかわかりません。