Sonar掃描的NPE問題解決方案

Sonar掃描的NPE問題

report this on Sonar Community: Commons-lang StringUtils isNotBlank method still raise NPE

有人遇到了相同的問題,官方猜測是沒有正確的配置sonar.java.libraries

SonarQube上的確提示——

Bytecode of dependencies was not provided for analysis of source files, you might end up with less precise results. Bytecode can be provided using sonar.java.libraries property.

手動驗證,將commons-lang3-3.7.jar添加到sonar.java.libraries參數(shù)里,問題解決。


下一步需要處理的方式——

added the target “dependency:copy-dependencies” as part of the maven execution. This copied all the dependencies to the right location, then I set the property “-Dsonar.java.libraries=target/dependency” in our case.

將項目的依賴都復(fù)制到固定的目錄,然后將這個目錄傳遞給sonar.java.libraries參數(shù)。

dependency:copy-dependencies的官方用法。

理論上這樣就可以解決這個問題,需要驗證的是多模塊的項目的依賴是否可以全部正確復(fù)制到正確的目錄下。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容