facebookresearch / UnsupervisedMT
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 209 units with 4,284 lines of code in units (92.7% of code).
    • 6 very long units (905 lines of code)
    • 13 long units (861 lines of code)
    • 41 medium size units (1,286 lines of code)
    • 45 small units (665 lines of code)
    • 104 very small units (567 lines of code)
21% | 20% | 30% | 15% | 13%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py21% | 20% | 30% | 15% | 13%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
NMT/src21% | 5% | 38% | 17% | 16%
NMT/src/model15% | 42% | 26% | 8% | 6%
NMT74% | 25% | 0% | 0% | 0%
NMT/src/data21% | 0% | 44% | 15% | 17%
NMT/src/modules0% | 32% | 9% | 39% | 19%
PBSMT/src0% | 0% | 0% | 60% | 39%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def generate()
in NMT/src/sequence_generator.py
238 47 7
def get_parser()
in NMT/main.py
201 3 0
def check_all_data_params()
in NMT/src/data/loader.py
132 97 1
def generate_beam()
in NMT/src/model/attention.py
125 38 7
def __init__()
in NMT/src/model/attention.py
106 38 3
def test_sharing()
in NMT/src/test.py
103 68 4
def __init__()
in NMT/src/trainer.py
88 28 7
def __init__()
in NMT/src/model/seq2seq.py
86 30 3
def forward()
in NMT/src/modules/multihead_attention.py
78 18 9
def build_attention_model()
in NMT/src/model/attention.py
75 12 3
def main()
in NMT/main.py
70 29 1
def generate()
in NMT/src/model/attention.py
69 22 6
def __init__()
in NMT/src/model/transformer.py
66 20 3
def forward()
in NMT/src/model/attention.py
57 7 5
def generate()
in NMT/src/model/seq2seq.py
57 20 6
def build_seq2seq_model()
in NMT/src/model/seq2seq.py
57 6 3
def check_mt_model_params()
in NMT/src/model/__init__.py
56 45 1
def initialize_embeddings()
in NMT/src/model/pretrain_embeddings.py
51 29 4
def __init__()
in NMT/src/model/seq2seq.py
51 15 2
def __init__()
in NMT/src/model/attention.py
49 13 2