facebookresearch / XLM
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 414 units with 7,413 lines of code in units (88.0% of code).
    • 1 very long units (152 lines of code)
    • 20 long units (1,374 lines of code)
    • 110 medium size units (3,508 lines of code)
    • 89 small units (1,313 lines of code)
    • 194 very small units (1,066 lines of code)
2% | 18% | 47% | 17% | 14%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py2% | 18% | 47% | 17% | 14%
perl0% | 0% | 0% | 77% | 22%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
ROOT59% | 0% | 36% | 4% | 0%
xlm/model0% | 32% | 34% | 15% | 17%
src/model0% | 32% | 34% | 15% | 17%
xlm0% | 13% | 50% | 23% | 12%
src0% | 13% | 50% | 23% | 12%
xlm/evaluation0% | 10% | 72% | 9% | 7%
src/evaluation0% | 10% | 72% | 9% | 7%
xlm/data0% | 11% | 43% | 25% | 19%
src/data0% | 11% | 43% | 25% | 19%
tools0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def get_parser()
in train.py
152 4 0
def generate_beam()
in xlm/model/transformer.py
86 35 8
def generate_beam()
in src/model/transformer.py
86 35 8
def __init__()
in xlm/model/memory/memory.py
83 32 4
def __init__()
in src/model/memory/memory.py
83 32 4
71 15 1
def register_args()
in xlm/model/memory/memory.py
71 1 1
def __init__()
in xlm/trainer.py
71 33 3
71 15 1
def register_args()
in src/model/memory/memory.py
71 1 1
def __init__()
in src/trainer.py
71 33 3
def evaluate_mt()
in xlm/evaluation/evaluator.py
68 18 6
def check_data_params()
in xlm/data/loader.py
68 73 1
def evaluate_mt()
in src/evaluation/evaluator.py
68 18 6
def check_data_params()
in src/data/loader.py
68 73 1
def __init__()
in xlm/model/transformer.py
58 13 5
def fwd()
in xlm/model/transformer.py
58 16 9
def __init__()
in src/model/transformer.py
58 13 5
def fwd()
in src/model/transformer.py
58 16 9
def forward()
in xlm/model/memory/memory.py
53 19 2