2016-07-27 44 views
7

我認爲我們在Sonar的安裝(5.6和java插件4.0)中有誤報。 未使用的「私有」的方法應該被刪除的問題是提高了下面的代碼:錯誤應刪除未使用的「私人」方法

public boolean orderLineHasDetails(OrderLine orderLine) { 

     boolean result = orderLine.getContractDevices() != null && orderLine.getContractDevices().size() > 0; 

     if (result) { 

      result = asLeastOneUniqueId(orderLine.getContractDevices()); 

     } 

     return result; 

    } 


    private boolean asLeastOneUniqueId(List<ContractDevice> contractDeviceList) { 


     Iterator<ContractDevice> contractDeviceIterator = contractDeviceList.iterator(); 

     boolean result = false; 

     while (!result && contractDeviceIterator.hasNext()) { 

      result = StringUtils.isNotBlank(contractDeviceIterator.next().getDeviceUniqueId()); 

     } 

     return result; 

    } 

這是一個已知的bug?

感謝您的幫助。

編輯:
一個新的假陽性內的方法: enter image description here

問候,

斯特凡

+0

這是用於Java的嗎? –

+0

是的,它是用最新的java插件的一個java源代碼(4.0) – Wilda

+0

'orderLine.getContractDevices()'的確切返回類型是什麼? –

回答

1

這是在以前的聲納裝置的錯誤。但最近它是固定的,工作正常。嘗試使用eclipse市場上的sonar Lint(我希望你使用的是eclipse),它是eclipse中最新版本的聲納。

我在我的代碼庫中試過這段代碼,並且沒有顯示消息。因此請嘗試更新sonarsonarqubesonar Lint

+2

我不使用eclipse,我的目標是在jenkins工作中工作;) – Wilda

+1

這是2017年5月,我仍然收到很多這種虛假警報:-( –