facebookresearch / DisCo
Conditional Complexity

The distribution of complexity of units (measured with McCabe index).

Intro
  • Conditional complexity (also called cyclomatic complexity) is a term used to measure the complexity of software. The term refers to the number of possible paths through a program function. A higher value ofter means higher maintenance and testing costs (infosecinstitute.com).
  • Conditional complexity is calculated by counting all conditions in the program that can affect the execution path (e.g. if statement, loops, switches, and/or operators, try and catch blocks...).
  • Conditional complexity is measured at the unit level (methods, functions...).
  • Units are classified in four categories based on the measured McCabe index: 1-5 (simple units), 6-10 (medium complex units), 11-25 (complex units), 26+ (very complex units).
Learn more...
Conditional Complexity Overall
  • There are 1,034 units with 11,348 lines of code in units (79.7% of code).
    • 0 very complex units (0 lines of code)
    • 13 complex units (1,702 lines of code)
    • 35 medium complex units (1,648 lines of code)
    • 76 simple units (1,866 lines of code)
    • 910 very simple units (6,132 lines of code)
0% | 14% | 14% | 16% | 54%
Legend:
51+
26-50
11-25
6-10
1-5
Alternative Visuals
Conditional Complexity per Extension
51+
26-50
11-25
6-10
1-5
py0% | 15% | 14% | 16% | 53%
cpp0% | 0% | 0% | 25% | 75%
lua0% | 0% | 0% | 0% | 100%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
ROOT0% | 60% | 11% | 6% | 21%
fairseq_cli0% | 62% | 12% | 8% | 17%
fairseq0% | 11% | 20% | 20% | 47%
fairseq/modules0% | 17% | 7% | 19% | 56%
fairseq/models0% | 0% | 14% | 20% | 65%
fairseq/optim0% | 0% | 15% | 9% | 74%
fairseq/data0% | 0% | 9% | 13% | 76%
scripts0% | 0% | 20% | 34% | 44%
fairseq/tasks0% | 0% | 22% | 7% | 69%
fairseq/strategies0% | 0% | 35% | 0% | 64%
fairseq/criterions0% | 0% | 0% | 22% | 77%
fairseq/clib0% | 0% | 0% | 25% | 75%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
def main()
in generate.py
132 44 1
def main()
in fairseq_cli/generate.py
132 44 1
def train_step()
in fairseq/trainer.py
120 40 4
179 38 24
def main()
in fairseq_cli/eval_lm.py
133 38 1
def main()
in eval_lm.py
133 38 1
def forward()
in fairseq/modules/multihead_attention.py
134 37 9
def forward()
in fairseq/modules/masked_multihead_attention.py
141 37 10
def main()
in preprocess.py
148 35 1
def main()
in fairseq_cli/preprocess.py
148 35 1
def main()
in generate_disco.py
108 33 1
def main()
in fairseq_cli/interactive.py
97 31 1
def main()
in interactive.py
97 31 1
def save_checkpoint()
in fairseq/checkpoint_utils.py
56 24 4
def main()
in fairseq_cli/train.py
48 24 2
def main()
in train.py
48 24 2
def filter_by_size()
in fairseq/data/data_utils.py
36 23 4
def _register_grad_hook()
in fairseq/legacy_distributed_data_parallel.py
70 21 1
def finalize_hypos()
in fairseq/sequence_generator.py
56 20 4
def load_dataset()
in fairseq/tasks/translation_self.py
70 19 4