facebookresearch / UnsupervisedDecomposition
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 790 units with 11,911 lines of code in units (80.0% of code).
    • 9 very long units (1,091 lines of code)
    • 37 long units (2,443 lines of code)
    • 126 medium size units (3,897 lines of code)
    • 157 small units (2,291 lines of code)
    • 461 very small units (2,189 lines of code)
9% | 20% | 32% | 19% | 18%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py9% | 20% | 32% | 19% | 18%
perl0% | 0% | 0% | 77% | 22%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
pytorch-transformers/pytorch_transformers8% | 17% | 28% | 22% | 23%
XLM/src/evaluation20% | 0% | 63% | 7% | 8%
XLM50% | 27% | 22% | 0% | 0%
pytorch-transformers/pseudoalignment17% | 47% | 17% | 10% | 7%
pytorch-transformers19% | 31% | 25% | 12% | 10%
XLM/src/model0% | 41% | 29% | 12% | 17%
XLM/src/model/memory0% | 32% | 30% | 18% | 18%
XLM/src0% | 13% | 51% | 23% | 12%
XLM/src/data0% | 11% | 43% | 25% | 19%
XLM/tools0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def evaluate_mt()
in XLM/src/evaluation/evaluator.py
170 21 6
def get_parser()
in XLM/train.py
156 4 0
def main_bert_nsp()
in pytorch-transformers/pseudoalignment/pseudo_decomp_bert_nsp.py
128 28 0
def main()
in pytorch-transformers/pytorch_transformers/__main__.py
112 29 0
def _forward()
in pytorch-transformers/pytorch_transformers/modeling_transfo_xl.py
108 41 4
def evaluate_ensemble()
in pytorch-transformers/ensemble_answers_by_confidence_script.py
106 26 3
def from_pretrained()
in pytorch-transformers/pytorch_transformers/modeling_utils.py
106 34 4
def _from_pretrained()
in pytorch-transformers/pytorch_transformers/tokenization_utils.py
104 41 4
def forward()
in pytorch-transformers/pytorch_transformers/modeling_xlnet.py
101 50 9
def generate_beam()
in XLM/src/model/transformer.py
94 41 9
def main()
in pytorch-transformers/pseudoalignment/pseudo_decomp_variable.py
90 13 0
def convert_roberta_checkpoint_to_pytorch()
in pytorch-transformers/pytorch_transformers/convert_roberta_checkpoint_to_pytorch.py
89 7 3
def forward()
in pytorch-transformers/pytorch_transformers/modeling_transfo_xl_utilities.py
89 4 4
def main()
in XLM/translate.py
86 33 1
def __init__()
in XLM/src/model/memory/memory.py
83 32 4
def __init__()
in pytorch-transformers/pytorch_transformers/modeling_xlm.py
75 6 33
def _tokenize()
in pytorch-transformers/pytorch_transformers/tokenization_xlm.py
74 6 4
def init_distributed_mode()
in XLM/src/slurm.py
72 15 1
def __init__()
in XLM/src/trainer.py
72 34 3
def __init__()
in pytorch-transformers/pytorch_transformers/modeling_transfo_xl.py
71 7 31