获取错误:无法加载交叉规则(无效的规则类型或文件不存在)



我正试图在另一个自定义规则中加载一个定制规则,这两个规则都是由Parasoft规则向导创建的。

以下代码是作为方法放置在调用规则中的python片段:

def somePythonMethod(node, context): 
   parent = context.getParentContext() 
   result = parent.executeRule("my_rule.rule", node) 

我在运行分析时检索到的错误:

unable to load cross rule (invalid rule type or file does not exist)

后面是一个指向规则路径的链接,该路径确实存在。因此,我认为问题与规则类型有关。

这个错误的来源是什么?

parasoft docos建议使用以下内容:

   enf = node.getEnforcer()
   filename = node.getProperty("filename")
   line = node.getLine()
   col = node.getColumn()
   enf.executeRuleEx('./my.rule', node, filename, int(line), int(col))

不同之处在于,您在执行器而不是父节点上调用executeRuleEx()。显然对OP来说太晚了,但它可能会帮助其他人在未来提出同样的问题。

最新更新