2017-01-03 58 views
0

聲納在null!= textEditor中顯示錯誤。Sonarqube(版本4.5):條件不應無條件評估爲TRUE或FALSE

TextEditor textEditor = null; 

try{ 
    /* Initialize text editor for the current operation */ 
    textEditor = textEditorFactory.getCurrentEditingContext(); 
    if(null == textEditor){ 
    return; 
    } 
    /* doSomeOperation */ 
} catch (final Exception e) { 
    if (null != textEditor) { 
    textEditor.cancelEdit(); 
    } 
} 

錯誤消息:以便它並不總是 評估爲「假」改變這種情況。

+0

你能確定你正在使用哪種語言嗎? (我在猜測Java?),你還可以精確地知道SonarJava Analyzer的版本是什麼? – benzonico

回答

0

唯一值textEditor可以在catch塊中有null。這是因爲如果在try塊中引發異常,它只能來自getCurrentEditingContext()調用,其中textEditor仍然爲null