facebookresearch / reconsider
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 541 units with 7,167 lines of code in units (82.2% of code).
    • 5 very long units (719 lines of code)
    • 21 long units (1,343 lines of code)
    • 64 medium size units (1,967 lines of code)
    • 111 small units (1,608 lines of code)
    • 340 very small units (1,530 lines of code)
10% | 18% | 27% | 22% | 21%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py10% | 18% | 27% | 22% | 21%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
pytorch_transformers6% | 19% | 27% | 23% | 23%
ROOT35% | 16% | 29% | 12% | 5%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main()
in main.py
284 62 0
def from_pretrained()
in pytorch_transformers/modeling_utils.py
114 37 6
def main()
in pytorch_transformers/__main__.py
112 29 0
def _forward()
in pytorch_transformers/modeling_transfo_xl.py
108 41 4
def forward()
in pytorch_transformers/modeling_xlnet.py
101 50 9
def convert_roberta_checkpoint_to_pytorch()
in pytorch_transformers/convert_roberta_checkpoint_to_pytorch.py
90 7 3
def forward()
in pytorch_transformers/modeling_transfo_xl_utilities.py
89 4 4
def _from_pretrained()
in pytorch_transformers/tokenization_utils.py
88 33 4
def __init__()
in pytorch_transformers/modeling_xlm.py
73 6 32
def __init__()
in pytorch_transformers/modeling_transfo_xl.py
71 7 31
def __init__()
in pytorch_transformers/modeling_transfo_xl.py
69 18 2
68 34 8
def forward()
in pytorch_transformers/modeling_xlm.py
66 28 9
def __init__()
in pytorch_transformers/modeling_xlnet.py
63 6 26
62 15 4
def load_tf_weights_in_openai_gpt()
in pytorch_transformers/modeling_openai.py
60 19 3
def load_tf_weights_in_bert()
in pytorch_transformers/modeling_bert.py
59 22 3
def build_tf_to_pytorch_map()
in pytorch_transformers/modeling_transfo_xl.py
58 4 2
def forward()
in pytorch_transformers/modeling_transfo_xl.py
56 15 8
def forward()
in pytorch_transformers/modeling_distilbert.py
56 17 8