Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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