How to use the radon.complexity function in radon

To help you get started, we’ve selected a few radon 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 caleb531 / automata / tests / test_compliance.py View on Github external
def test_complexity():
    """All source file functions should have a low cyclomatic complexity."""
    file_paths = itertools.chain(
        glob.iglob('automata/*/*.py'),
        glob.iglob('tests/*.py'))
    for file_path in file_paths:
        with open(file_path, 'r') as file_obj:
            blocks = radon.cc_visit(file_obj.read())
        for block in blocks:
            fail_msg = '{} ({}) has a cyclomatic complexity of {}'.format(
                block.name, file_path, block.complexity)
            yield nose.assert_less_equal, block.complexity, 10, fail_msg
github caleb531 / youversion-suggest-alfred / tests / test_compliance.py View on Github external
def test_complexity():
    """All source and test files should have a low cyclomatic complexity"""
    file_paths = glob.iglob('*/*.py')
    for file_path in file_paths:
        with open(file_path, 'r') as file_obj:
            blocks = radon.cc_visit(file_obj.read())
        for block in blocks:
            fail_msg = '{} ({}) has a cyclomatic complexity of {}'.format(
                block.name, file_path, block.complexity)
            yield nose.assert_less_equal, block.complexity, 10, fail_msg
github caleb531 / cache-simulator / tests / test_compliance.py View on Github external
def test_complexity():
    file_paths = glob.iglob('*/*.py')
    for file_path in file_paths:
        with open(file_path, 'r') as file_obj:
            blocks = radon.cc_visit(file_obj.read())
        for block in blocks:
            test_doc = '{} ({}) should have a low cyclomatic complexity score'
            test_complexity.__doc__ = test_doc.format(
                block.name, file_path)
            fail_msg = '{} ({}) has a cyclomatic complexity of {}'.format(
                block.name, file_path, block.complexity)
            yield nose.assert_less_equal, block.complexity, 10, fail_msg