facebookresearch / pytext
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 3,109 units with 24,000 lines of code in units (54.0% of code).
    • 0 very long units (0 lines of code)
    • 21 long units (1,458 lines of code)
    • 203 medium size units (5,943 lines of code)
    • 386 small units (5,532 lines of code)
    • 2,499 very small units (11,067 lines of code)
0% | 6% | 24% | 23% | 46%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py0% | 6% | 24% | 23% | 46%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
pytext/models0% | 6% | 25% | 20% | 46%
pytext/optimizer0% | 12% | 11% | 28% | 47%
pytext/data0% | 3% | 28% | 22% | 45%
pytext/metric_reporters0% | 6% | 30% | 27% | 35%
pytext/config0% | 7% | 30% | 23% | 38%
pytext/metrics0% | 14% | 15% | 23% | 46%
pytext/trainers0% | 26% | 15% | 16% | 41%
pytext/legacy0% | 4% | 23% | 30% | 41%
pytext/utils0% | 4% | 23% | 22% | 48%
pytext/task0% | 10% | 15% | 19% | 54%
pytext0% | 0% | 51% | 23% | 25%
pytext/loss0% | 0% | 30% | 21% | 48%
pytext/torchscript0% | 0% | 9% | 8% | 82%
pytext/fields0% | 0% | 18% | 49% | 32%
pytext/exporters0% | 0% | 0% | 29% | 70%
pytext/common0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def calculate_metric()
in pytext/metric_reporters/squad_metric_reporter.py
98 8 1
def print_metrics()
in pytext/metrics/__init__.py
97 15 2
def torchscriptify()
in pytext/models/doc_model.py
95 19 3
def torchscriptify()
in pytext/models/doc_model.py
89 6 3
def step()
in pytext/optimizer/adabelief.py
83 18 3
def __init__()
in pytext/trainers/trainer.py
83 21 3
def build_tree()
in pytext/data/data_structures/annotation.py
78 27 2
def from_config()
in pytext/models/tri_tower_classification_model.py
77 8 4
def process_squad_tsv()
in pytext/data/sources/squad.py
67 11 2
def step()
in pytext/optimizer/madgrad.py
66 12 3
def __init__()
in pytext/models/representations/lightconv.py
62 10 4
def step()
in pytext/optimizer/radam.py
60 9 3
def v1_to_v2()
in pytext/config/config_adapter.py
60 20 1
def pad()
in pytext/legacy/data/field.py
60 12 2
def report_realtime_metric()
in pytext/metric_reporters/language_model_metric_reporter.py
60 5 2
def migrate_to_new_data_handler()
in pytext/config/config_adapter.py
58 2 2
def from_config()
in pytext/models/two_tower_classification_model.py
57 6 4
def report()
in pytext/utils/timing.py
52 7 2
def __init__()
in pytext/models/seq_models/conv_encoder.py
52 9 5
def torchscript_export()
in pytext/task/tasks.py
52 13 4