0
我想通過它的Web界面,檢查是否存在下列情況定義XPath規則,以檢查catch子句中的Java
try{
doStuff();
} catch (SomeException e) {
handleException(e);
}
應強調引進新的自定義XPath規則到SonarQube。鑑於
try{
doStuff();
} catch (SomeException e) {
LOG.info(e.getMessage() + " other stuff");
handleException(e);
}
應該是所需的形式。任何想法如何通過XPath表達它?
非常感謝!我只是試過設計器,但XPath表達式返回這個代碼的「No matching nodes xxxx」:import java.util.logging.Logger; public class Test { \t private Logger LOG = Logger.getLogger(「」); \t public void main(String [] args){ 嘗試doStuff(); (SomeException e){LOG.info(e.getMessage()+「other stuff」); handleException(e); } \t} } – Alex 2014-09-04 15:37:24
這不正確嗎? '沒有匹配節點'意味着沒有符合XPath規則的代碼。在你的catch語句中是'LOG.info'調用,所以它不違反規則。例如,請參閱編輯答案。 – damgad 2014-09-04 15:52:50
我想我有一些其他無關的問題阻止了這個例子的工作。謝謝! – Alex 2014-09-04 16:00:39