facebookresearch / rlstructures
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 747 units with 8,299 lines of code in units (76.2% of code).
    • 14 very long units (1,940 lines of code)
    • 14 long units (958 lines of code)
    • 54 medium size units (1,776 lines of code)
    • 78 small units (1,102 lines of code)
    • 587 very small units (2,523 lines of code)
23% | 11% | 21% | 13% | 30%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py23% | 11% | 21% | 13% | 30%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
tutorial/deprecated30% | 21% | 16% | 11% | 19%
rlalgos/dqn40% | 0% | 17% | 17% | 24%
rlalgos/reinforce_diayn56% | 0% | 12% | 9% | 21%
rlalgos/reinforce_device70% | 0% | 16% | 0% | 13%
rlalgos/reinforce59% | 0% | 13% | 5% | 20%
rlalgos/sac30% | 0% | 34% | 8% | 27%
rlalgos/simple_ddqn41% | 0% | 23% | 4% | 30%
rlalgos/a2c_gae27% | 0% | 15% | 25% | 31%
rlalgos/ppo56% | 0% | 15% | 12% | 15%
rlalgos/deprecated0% | 17% | 40% | 9% | 33%
rlstructures/env_wrappers0% | 26% | 52% | 0% | 21%
rlstructures/deprecated0% | 16% | 22% | 10% | 51%
rlalgos0% | 17% | 0% | 28% | 54%
rlstructures/rl_batchers0% | 0% | 0% | 41% | 58%
rlstructures0% | 0% | 0% | 30% | 69%
tutorial0% | 0% | 0% | 15% | 84%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def run()
in rlalgos/dqn/duelling_dqn.py
219 25 1
def run()
in rlalgos/reinforce_diayn/reinforce_diayn.py
178 9 1
def run()
in rlalgos/reinforce_device/reinforce.py
162 6 1
def run()
in rlalgos/reinforce/reinforce.py
158 8 1
def run()
in rlalgos/sac/sac.py
156 10 1
def run()
in rlalgos/simple_ddqn/ddqn.py
142 17 1
def run()
in tutorial/deprecated/tutorial_reinforce_with_evaluation_s/reinforce.py
132 6 1
def run()
in tutorial/deprecated/tutorial_from_reinforce_to_a2c_s/a2c.py
118 10 1
def run()
in rlalgos/a2c_gae/a2c.py
118 12 1
def run()
in rlalgos/ppo/discrete_ppo.py
118 9 1
def run()
in tutorial/deprecated/tutorial_recurrent_a2c_s/a2c.py
113 11 1
def run()
in tutorial/deprecated/tutorial_recurrent_a2c_gae_s/a2c.py
113 11 1
def run()
in tutorial/deprecated/tutorial_from_reinforce_to_a2c/a2c.py
107 10 1
def run()
in tutorial/deprecated/tutorial_reinforce_with_evaluation/reinforce.py
106 7 1
def run()
in tutorial/deprecated/tutorial_a2c_with_infinite_env/a2c.py
97 9 1
def run()
in tutorial/deprecated/tutorial_recurrent_policy/a2c.py
97 9 1
def run()
in rlalgos/deprecated/sac/sac.py
79 6 1
def step()
in rlstructures/env_wrappers/gymenv.py
71 10 2
def get_loss()
in rlalgos/deprecated/ppo/discrete_ppo.py
69 3 2
def get_loss()
in tutorial/deprecated/tutorial_recurrent_policy/a2c.py
67 11 2