facebookresearch / nbref
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 234 units with 4,250 lines of code in units (88.6% of code).
    • 11 very long units (1,329 lines of code)
    • 8 long units (615 lines of code)
    • 28 medium size units (790 lines of code)
    • 51 small units (765 lines of code)
    • 136 very small units (751 lines of code)
31% | 14% | 18% | 18% | 17%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py31% | 14% | 18% | 18% | 17%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
baseline_model/data_utils29% | 9% | 17% | 21% | 21%
preprocess32% | 10% | 26% | 13% | 15%
baseline_model56% | 32% | 0% | 0% | 10%
preprocess/cram_vul_dataset0% | 100% | 0% | 0% | 0%
baseline_model/modules0% | 0% | 30% | 47% | 21%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def test_tree()
in baseline_model/data_utils/train_tree_encoder.py
140 33 8
def __get_nodes__()
in preprocess/asm_mips.py
137 26 3
def train_eval_tree()
in baseline_model/data_utils/train_tree_encoder.py
134 33 8
def main()
in baseline_model/run_tree_transformer.py
133 17 0
def get_arg_parser()
in baseline_model/config.py
122 5 1
def evaluation()
in baseline_model/data_utils/train_tree_encoder_v2.py
122 39 10
def eval_training()
in baseline_model/data_utils/train_tree_encoder_v2.py
117 35 12
def main()
in baseline_model/run_vulnerability_detection.py
117 13 0
def extract_from_solution()
in preprocess/extract_obj.py
103 26 1
def __get_nodes__()
in preprocess/asm_obj.py
103 17 3
def main()
in preprocess/asm_mips.py
101 25 0
def processing_data()
in baseline_model/data_utils/train_tree_encoder.py
95 25 2
def __ins_node__()
in preprocess/asm_mips.py
92 37 1
def process()
in preprocess/cram_vul_dataset/src2asm.py
89 18 2
def run_spawn()
in baseline_model/run_tree_transformer_multi_gpu.py
82 11 9
def _gc_dataloader()
in baseline_model/data_utils/ggnn_utils.py
73 13 8
def main()
in baseline_model/run_tree_transformer_multi_gpu.py
72 14 0
def main()
in baseline_model/run_similarity_check.py
61 6 0
def main()
in preprocess/dump_trace.py
51 4 0
def __init__()
in preprocess/asm_obj.py
41 16 3