facebookresearch / DPR
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 345 units with 3,177 lines of code in units (55.5% of code).
    • 1 very long units (120 lines of code)
    • 2 long units (155 lines of code)
    • 32 medium size units (996 lines of code)
    • 42 small units (636 lines of code)
    • 268 very small units (1,270 lines of code)
3% | 4% | 31% | 20% | 39%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py3% | 4% | 31% | 20% | 39%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
ROOT14% | 18% | 39% | 14% | 12%
dpr/data0% | 0% | 31% | 23% | 45%
dpr/utils0% | 0% | 25% | 28% | 45%
dpr/models0% | 0% | 23% | 17% | 59%
dpr/indexer0% | 0% | 19% | 16% | 64%
dpr0% | 0% | 42% | 0% | 57%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main()
in dense_retriever.py
120 22 1
def validate_average_rank()
in train_dense_encoder.py
94 23 1
def validate_nll()
in train_dense_encoder.py
61 6 1
def main()
in generate_dense_embeddings.py
50 5 1
def validate()
in train_extractive_reader.py
46 8 1
def iterate_ds_data()
in dpr/utils/data_utils.py
45 10 2
def all_gather_list()
in dpr/utils/dist_utils.py
43 7 3
def _linearize_table()
in dpr/data/biencoder_data.py
42 16 3
def read_nq_tables_jsonl()
in dpr/data/tables.py
39 14 2
def run_train()
in train_dense_encoder.py
39 5 1
def download()
in dpr/data/download_data.py
38 9 2
def read_nq_tables_jsonl()
in dpr/data/biencoder_data.py
36 12 1
def run_train()
in train_extractive_reader.py
36 4 1
def calc_questions_overlap()
in dpr/data/tables.py
34 9 3
def __init__()
in train_dense_encoder.py
32 7 2
def compute_loss()
in dpr/models/reader.py
31 5 8
def _calc_loss()
in train_extractive_reader.py
31 4 2
def get_bert_biencoder_components()
in dpr/models/hf_models.py
30 4 3
def __init__()
in train_extractive_reader.py
30 5 2
def split_table()
in dpr/data/biencoder_data.py
29 7 3