<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def detect_complex_func(func):
 """Detect the cyclomatic complexity of the contract functions shouldn't be greater than 7 """

        result = []
        code_complexity = compute_cyclomatic_complexity(func)

        if code_complexity > ComplexFunction.MAX_CYCLOMATIC_COMPLEXITY:
            result.append({
                "func": func,
                "cause": ComplexFunction.CAUSE_CYCLOMATIC
            })

        """Detect the number of external calls in the func
           shouldn't be greater than 5
        """
        count = 0
        for node in func.nodes:
            for ir in node.irs:
                if isinstance(ir, (HighLevelCall, LowLevelCall, LibraryCall)):
                    count += 1

        if count > ComplexFunction.MAX_EXTERNAL_CALLS:
            result.append({
                "func": func,
                "cause": ComplexFunction.CAUSE_EXTERNAL_CALL
            })

        """Checks the number of the state variables written
           shouldn't be greater than 10
        """
        if len(func.state_variables_written) > ComplexFunction.MAX_STATE_VARIABLES:
            result.append({
                "func": func,
                "cause": ComplexFunction.CAUSE_STATE_VARS
            })

        return result