So I am trying to write a script to calculate the Cyclomatic complexity of each function, and keep running into the error that monitor is not defined. So far I haven't been able to find a good solution on how to get around this.
`
import pyhidra
with pyhidra.open_program("test") as flat_api:
from ghidra.program.model.listing import Function, FunctionIterator
from ghidra.program.util import CyclomaticComplexity
program = flat_api.getCurrentProgram()
functions = currentProgram.getFunctionManager().getFunctions(
True
)
func_to_complexity = list()
cc = CyclomaticComplexity()
for function in functions: # type: Function
complexity = cc.calculateCyclomaticComplexity(function, monitor)
func_to_complexity.append(
{
"function": str(function),
"address": function.getEntryPoint(),
"complexity": complexity,
}
)`
Can anyone help in identifying where monitor comes from? Or how to pass the monitor object to the Cyclomatic Complexity function.
So I am trying to write a script to calculate the Cyclomatic complexity of each function, and keep running into the error that monitor is not defined. So far I haven't been able to find a good solution on how to get around this. ` import pyhidra with pyhidra.open_program("test") as flat_api: from ghidra.program.model.listing import Function, FunctionIterator from ghidra.program.util import CyclomaticComplexity
Can anyone help in identifying where monitor comes from? Or how to pass the monitor object to the Cyclomatic Complexity function.