Sunday, October 26, 2014

Show longest continuous block of code not covered by tests

Usage: nocov.py
import fileinput
count = 0
lengths = {}
first = 0
for line in fileinput.input():
    if first and ('stm mis' in line or 'pln' in line):
        lengths[first] += 1
    else:
        t = line.split("id='t")
        if len(t) < 2:
            continue
        first = t[-1].split("'")[0]
        lengths[first] = 1

for x in sorted(lengths.items(), key=lambda (x, y): y):
    print x

No comments:

Post a Comment