def __transform(self, section): methods = adapter.methods(section) if methods: complexities = [] for ms in methods: complexities.extend( map(lambda m: cyclomatic_complexity(m['codeBlock']), ms)) return complexities else: return [0]
def __transform(self, section): methods = adapter.methods(section) # can look like this: [[m1,m2], [m3,m4]] if methods: ret_val = [] # workaround for 66.txt which has a main method that is not in a class, see line 2969 for clazz in methods: if clazz: for method in clazz: ret_val.append(len(method['name'])) if not ret_val: ret_val = [0] # workaround for files that contain empty classes, for instance 51.txt lines 15435-15440 return ret_val else: return [0]
def __transform(self, sections): methods = [] for section in sections: methods_in_section = adapter.methods(section) if methods_in_section is not None: for ms in methods_in_section: for m in ms: methods.append(m['codeBlock']) for i in range(0, len(methods)): for j in range(i + 1, len(methods)): sim = cosine(vector(str(methods[i]).lower()), vector(str(methods[j]).lower())) if sim > 0.9: return [1.0] return [0.0]
def __transform(self, section): methods = adapter.methods(section) if methods: ret_val = [] for clazz in methods: if clazz: for method in clazz: for variable_name in method['variables']: ret_val.append(len(variable_name)) if not ret_val: ret_val = [0] return ret_val else: return [0]
def __transform(self, section): methods = adapter.methods( section) # can look like this: [[m1,m2], [m3,m4]] if methods: ret_val = [] for clazz in methods: if clazz: for method in clazz: ret_val.append(len(method['variables'])) if not ret_val: ret_val = [0] return ret_val else: return [0]
def __transform(self, section): methods = adapter.methods(section) if methods: return map(lambda x: len(x), methods) else: return [0]