facebookresearch / detr
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
Unit Size Overall
  • There are 207 units with 2,548 lines of code in units (86.0% of code).
    • 1 very long units (112 lines of code)
    • 5 long units (335 lines of code)
    • 26 medium size units (777 lines of code)
    • 48 small units (667 lines of code)
    • 127 very small units (657 lines of code)
4% | 13% | 30% | 26% | 25%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py4% | 13% | 30% | 26% | 25%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
ROOT27% | 32% | 14% | 5% | 19%
models0% | 9% | 23% | 39% | 27%
d2/detr0% | 28% | 22% | 45% | 4%
util0% | 12% | 28% | 24% | 34%
datasets0% | 0% | 49% | 18% | 32%
d20% | 0% | 69% | 10% | 20%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main()
in main.py
112 39 1
def forward()
in models/segmentation.py
76 20 4
def __init__()
in d2/detr/detr.py
70 9 2
def evaluate()
in engine.py
69 27 7
67 1 0
def log_every()
in util/misc.py
53 7 4
def plot_logs()
in util/plot_utils.py
47 16 4
def __call__()
in datasets/coco.py
45 20 3
def resize()
in datasets/transforms.py
43 15 4
def build_optimizer()
in d2/train_net.py
41 12 3
def build()
in models/detr.py
40 8 1
39 13 7
def main()
in d2/converter.py
38 9 0
def evaluate()
in datasets/coco_eval.py
35 14 1
def forward()
in models/segmentation.py
31 4 4
def __call__()
in d2/detr/dataset_mapper.py
31 14 2
def prepare_for_coco_segmentation()
in datasets/coco_eval.py
29 6 2
def plot_precision_recall()
in util/plot_utils.py
28 8 2
def crop()
in datasets/transforms.py
28 10 3
def __getitem__()
in datasets/coco_panoptic.py
27 11 2