facebookresearch / d2go
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 1,001 units with 10,119 lines of code in units (58.9% of code).
    • 3 very long units (458 lines of code)
    • 17 long units (1,159 lines of code)
    • 96 medium size units (2,885 lines of code)
    • 155 small units (2,252 lines of code)
    • 730 very small units (3,365 lines of code)
4% | 11% | 28% | 22% | 33%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py4% | 11% | 28% | 22% | 33%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
projects_oss/detr11% | 8% | 34% | 21% | 23%
d2go/data0% | 21% | 16% | 23% | 38%
d2go/runner0% | 23% | 17% | 12% | 47%
d2go/modeling0% | 10% | 30% | 28% | 30%
d2go/utils0% | 4% | 32% | 18% | 44%
d2go/export0% | 24% | 18% | 12% | 44%
d2go/evaluation0% | 0% | 61% | 12% | 26%
d2go0% | 0% | 28% | 29% | 42%
tools0% | 0% | 15% | 46% | 38%
d2go/optimizer0% | 0% | 20% | 39% | 40%
d2go/config0% | 0% | 17% | 45% | 36%
ROOT0% | 0% | 0% | 100% | 0%
d2go/model_zoo0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main()
in projects_oss/detr/main.py
168 41 1
def get_args_parser()
in projects_oss/detr/main.py
153 1 0
def __init__()
in projects_oss/detr/detr/d2/detr.py
137 14 2
def forward()
in projects_oss/detr/detr/models/segmentation.py
100 20 4
def forward()
in projects_oss/detr/detr/models/deformable_transformer.py
84 9 5
def inject_gan_datasets()
in d2go/data/gans.py
84 7 1
def _original_call()
in d2go/data/dataset_mappers/d2go_dataset_mapper_impl.py
81 23 2
def _do_test()
in d2go/runner/default_runner.py
76 18 5
def log_every()
in projects_oss/detr/detr/util/misc.py
72 7 4
def forward()
in projects_oss/detr/detr/models/deformable_detr.py
70 13 2
def do_train()
in d2go/runner/default_runner.py
70 11 4
def extended_lvis_load()
in d2go/data/extended_lvis.py
70 19 3
def before_step()
in d2go/modeling/quantization.py
60 15 1
def _original_call()
in d2go/data/dataset_mappers/rotated_dataset_mapper.py
59 19 2
def get_transform()
in d2go/data/transforms/affine.py
59 3 2
def fetch_checkpoints_till_final()
in d2go/utils/validation_monitor.py
58 14 1
def tracing_adapter_wrap_export()
in d2go/export/torchscript.py
57 5 1
def _apply_eager_mode_quant()
in d2go/modeling/meta_arch/rcnn.py
55 15 2
def _reset_dataset_evaluators()
in d2go/runner/lightning_task.py
53 7 1
def forward()
in d2go/modeling/subclass.py
51 14 5