How to use the mccabe.McCabeChecker._code function in mccabe

To help you get started, we’ve selected a few mccabe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pylava / pylava / pylava / lint / pylava_mccabe.py View on Github external
def run(path, code=None, params=None, **meta):
        """MCCabe code checking.

        :return list: List of errors.
        """
        tree = compile(code, path, "exec", ast.PyCF_ONLY_AST)

        McCabeChecker.max_complexity = int(params.get('complexity', 10))
        return [
            {'lnum': lineno, 'offset': offset, 'text': text, 'type': McCabeChecker._code}
            for lineno, offset, text, _ in McCabeChecker(tree, path).run()
        ]