facebookresearch / image-to-set
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 173 units with 2,666 lines of code in units (89.1% of code).
    • 2 very long units (444 lines of code)
    • 6 long units (498 lines of code)
    • 24 medium size units (766 lines of code)
    • 31 small units (445 lines of code)
    • 110 very small units (513 lines of code)
16% | 18% | 28% | 16% | 19%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py16% | 18% | 28% | 16% | 19%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
src25% | 32% | 26% | 7% | 8%
src/utils27% | 0% | 26% | 15% | 30%
src/modules0% | 8% | 32% | 29% | 29%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main()
in src/train.py
322 73 1
def build_vocab_recipe1m()
in src/utils/recipe1m_utils.py
122 55 1
def get_model()
in src/model.py
93 13 2
def main()
in src/eval.py
92 14 1
def get_loader()
in src/data_loader.py
85 15 12
def forward()
in src/model.py
79 34 7
def forward()
in src/modules/multihead_attention.py
77 20 9
def get_parser()
in src/args.py
72 2 0
def sample()
in src/modules/rnn_decoder.py
44 7 7
def _upgrade_state_dict()
in src/modules/utils.py
43 4 1
def __init__()
in src/data_loader.py
41 7 10
def __getitem__()
in src/data_loader.py
40 8 2
def sample()
in src/modules/transformer_decoder.py
39 7 7
def __init__()
in src/data_loader.py
37 5 10
36 13 8
def __init__()
in src/model.py
36 1 18
def forward()
in src/modules/transformer_decoder.py
36 1 5
def __init__()
in src/utils/voc_utils.py
34 7 7
def DC()
in src/utils/metrics.py
33 5 2
def __init__()
in src/data_loader.py
32 4 7