facebookresearch / InvariantRiskMinimization
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 30 units with 389 lines of code in units (70.5% of code).
    • 0 very long units (0 lines of code)
    • 2 long units (116 lines of code)
    • 4 medium size units (115 lines of code)
    • 5 small units (75 lines of code)
    • 19 very small units (83 lines of code)
0% | 29% | 29% | 19% | 21%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py0% | 29% | 29% | 19% | 21%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
experiment_synthetic0% | 36% | 36% | 15% | 12%
colored_mnist0% | 0% | 0% | 51% | 48%
figure_10% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def plot_bars()
in code/experiment_synthetic/plot.py
58 15 4
def run_experiment()
in code/experiment_synthetic/main.py
58 12 1
def __init__()
in code/experiment_synthetic/models.py
44 10 3
def train()
in code/experiment_synthetic/models.py
25 5 4
def plot_experiment()
in code/experiment_synthetic/plot.py
24 5 3
def __init__()
in code/experiment_synthetic/sem.py
22 4 6
def parse_title()
in code/experiment_synthetic/plot.py
16 4 1
def __init__()
in code/experiment_synthetic/models.py
16 4 3
def errors()
in code/experiment_synthetic/main.py
16 3 2
def make_environment()
in code/colored_mnist/main.py
15 3 3
def __init__()
in code/colored_mnist/main.py
12 3 1
def __call__()
in code/experiment_synthetic/sem.py
10 2 3
def pretty_print()
in code/colored_mnist/main.py
8 3 1
def mean_var_test()
in code/experiment_synthetic/models.py
7 1 3
def forward()
in code/colored_mnist/main.py
7 2 2
def penalty_ls()
in code/figure_1/penalties.py
6 1 6
def penalty_g()
in code/figure_1/penalties.py
6 1 5
def sample()
in code/figure_1/penalties.py
5 1 2
def __init__()
in code/experiment_synthetic/models.py
5 3 3
def penalty()
in code/colored_mnist/main.py
5 1 2