facebookresearch / RTFM
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 471 units with 2,828 lines of code in units (66.7% of code).
    • 1 very long units (137 lines of code)
    • 4 long units (254 lines of code)
    • 15 medium size units (425 lines of code)
    • 51 small units (748 lines of code)
    • 400 very small units (1,264 lines of code)
4% | 8% | 15% | 26% | 44%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py4% | 8% | 15% | 26% | 44%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
ROOT30% | 42% | 14% | 4% | 7%
core0% | 24% | 41% | 17% | 17%
rtfm/tasks0% | 0% | 20% | 38% | 40%
rtfm0% | 0% | 33% | 27% | 38%
model0% | 0% | 13% | 45% | 41%
rtfm/dynamics0% | 0% | 5% | 38% | 56%
rtfm/dynamics/monster0% | 0% | 13% | 13% | 73%
rtfm/dynamics/item/weapon0% | 0% | 0% | 18% | 81%
rtfm/dynamics/item/armour0% | 0% | 0% | 30% | 69%
rtfm/dynamics/item/modifier0% | 0% | 0% | 0% | 100%
rtfm/dynamics/item0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def train()
in run_exp.py
137 23 1
def get_parser()
in exp_utils.py
68 1 0
def __init__()
in core/file_writer.py
65 10 5
def learn()
in run_exp.py
63 8 7
def test()
in run_exp.py
58 12 2
def act()
in run_exp.py
41 11 6
def generate_all()
in rtfm/tasks/groups.py
41 13 3
34 5 7
def featurize()
in rtfm/featurizer.py
34 5 2
def featurize()
in rtfm/featurizer.py
33 7 4
def run_turn()
in rtfm/dynamics/engine.py
27 13 2
def log()
in core/file_writer.py
26 8 4
def from_logits()
in core/vtrace.py
26 1 9
def _reset()
in rtfm/tasks/groups.py
26 7 1
def act()
in rtfm/dynamics/monster/hostile.py
25 15 3
def get_batch()
in run_exp.py
24 6 6
def step()
in core/environment.py
23 4 2
def __init__()
in rtfm/tasks/task.py
22 1 2
def fuse()
in model/paper_txt2pi.py
22 1 6
def forward()
in model/reader.py
21 2 2