from collections import defaultdict
from lib.stats.helpers import get_naming_convention

def complexity(items):

    issues = []

    for item in items:
        if not item['type'] == 'function':
            continue
        cc = item['cyclomatic_complexity']

        if cc > 8:
            issue = {
                'type' :'complexity',
                'level' : 'warning',
                'description' : 'Highly complex function',
                'start_line' : item['start_line'],
                'end_line' : item['end_line'],
                'function_name' : item['name'],
                'score' : cc,
            }
            issues.append(issue)
        
    return issues
