facebookresearch / SpanBERT
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 889 units with 9,795 lines of code in units (84.9% of code).
    • 9 very long units (1,550 lines of code)
    • 12 long units (862 lines of code)
    • 75 medium size units (2,328 lines of code)
    • 159 small units (2,284 lines of code)
    • 634 very small units (2,771 lines of code)
15% | 8% | 23% | 23% | 28%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py15% | 8% | 23% | 23% | 28%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
code50% | 9% | 12% | 16% | 9%
pretraining26% | 19% | 30% | 11% | 12%
pretraining/fairseq/models0% | 12% | 11% | 31% | 44%
code/pytorch_pretrained_bert0% | 14% | 20% | 28% | 36%
pretraining/fairseq/modules0% | 13% | 32% | 21% | 32%
pretraining/fairseq0% | 6% | 37% | 21% | 33%
pretraining/fairseq/data0% | 0% | 28% | 32% | 38%
pretraining/fairseq/criterions0% | 0% | 54% | 29% | 15%
pretraining/fairseq/optim0% | 0% | 22% | 29% | 48%
pretraining/fairseq/tasks0% | 0% | 47% | 7% | 44%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main()
in code/run_squad.py
238 71 1
def main()
in code/run_glue.py
235 82 1
def main()
in code/run_mrqa.py
225 68 1
def main()
in code/run_tacred.py
200 67 1
def main()
in pretraining/preprocess.py
148 35 1
def make_predictions()
in code/run_squad.py
139 30 8
134 36 6
128 32 6
def make_predictions()
in code/run_mrqa.py
103 23 7
96 33 6
def forward()
in pretraining/fairseq/modules/multihead_attention.py
91 26 9
def train_step()
in pretraining/fairseq/trainer.py
90 25 3
def from_pretrained()
in code/pytorch_pretrained_bert/modeling.py
89 29 7
def from_pretrained()
in pretraining/fairseq/models/hf_bert.py
75 20 6
def from_pretrained()
in pretraining/fairseq/models/pair_bert.py
75 20 6
def read_squad_examples()
in code/run_squad.py
65 18 3
def load_tf_weights_in_bert()
in code/pytorch_pretrained_bert/modeling.py
59 22 2
58 20 5
def evaluate()
in code/run_squad.py
56 19 9
def main()
in pretraining/train.py
56 7 1