2
我为一个学习项目使用免费的Coverity Scan服务,我想对几种方法建模,要么总是抛出异常,要么内部调用System.exit()
,因此不返回,以便从Coverity的流分析中获得更好的结果。如何使用Coverity建模将方法标记为不返回?
例如:
class Foo {
// given these
Blarg fieldFromTheClass
void fail(String s, int a, int b) {
throw new DomainSpecificBlahBlahException(s, someFunction(a), someOtherFunction(a, b), fieldFromTheClass, collaborator.getBaz());
}
void fatal(Strin s) {
System.out.println("Fatal error: " + s);
System.exit(1);
}
// we should get 2 flags here
void test(int i) {
if (i%2==0) {
try {
fatal("foobar");
} catch (SecurityException se) {
// recovering from security manager - should be flagged as unreachable in normal circumstances
}
} else {
fail("baz", 1, 3);
}
doSomethingElse(); // unreachable
}
}
什么会做一个模型文件的方式?
此外,是否在任何公共存储库(即Bintray或中央)提供Coverity注释?
哦拍这个答案吧C++特定。我假设Java是相似的,但我不使用它。 – sbcondor
它仍是一些东西(比没有好:-) – ddimitrov