pytorch / fairseq
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 3,834 units with 41,101 lines of code in units (62.7% of code).
    • 1 very complex units (281 lines of code)
    • 10 complex units (1,246 lines of code)
    • 114 medium complex units (6,213 lines of code)
    • 268 simple units (7,408 lines of code)
    • 3,441 very simple units (25,953 lines of code)
<1% | 3% | 15% | 18% | 63%
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
py<1% | 3% | 15% | 18% | 62%
cpp0% | 0% | 0% | 12% | 87%
lua0% | 0% | 0% | 0% | 100%
pyx0% | 0% | 0% | 0% | 100%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
fairseq_cli22% | 23% | 22% | 15% | 16%
fairseq0% | 12% | 26% | 11% | 49%
fairseq/tasks0% | 4% | 16% | 23% | 55%
fairseq/criterions0% | 4% | 26% | 22% | 45%
scripts0% | 14% | 22% | 37% | 25%
fairseq/data0% | 1% | 13% | 15% | 70%
fairseq/models0% | 0% | 10% | 16% | 72%
fairseq/optim0% | 0% | 23% | 12% | 64%
fairseq/modules0% | 0% | 5% | 22% | 72%
fairseq/model_parallel0% | 0% | 14% | 31% | 53%
fairseq/distributed0% | 0% | 24% | 34% | 41%
fairseq/dataclass0% | 0% | 40% | 22% | 36%
scripts/constraints0% | 0% | 87% | 0% | 12%
fairseq/logging0% | 0% | 0% | 18% | 81%
fairseq/clib0% | 0% | 0% | 14% | 85%
fairseq/benchmark0% | 0% | 0% | 0% | 100%
fairseq/scoring0% | 0% | 0% | 0% | 100%
ROOT0% | 0% | 0% | 0% | 100%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
def _main()
in fairseq_cli/generate.py
281 62 2
def save_checkpoint()
in fairseq/checkpoint_utils.py
126 44 4
def main()
in fairseq_cli/interactive.py
161 43 1
def generate()
in fairseq/iterative_refinement_generator.py
172 39 5
def forward()
in fairseq/criterions/wav2vec_criterion.py
93 38 4
def _upgrade_state_dict()
in fairseq/checkpoint_utils.py
107 32 1
def main()
in scripts/rm_pt.py
91 31 0
def main()
in fairseq_cli/train.py
131 30 1
def load_dataset()
in fairseq/tasks/multilingual_language_modeling.py
183 28 5
def collater()
in fairseq/data/multilingual/sampled_multi_dataset.py
74 27 3
def __init__()
in fairseq/trainer.py
108 26 6
def step()
in fairseq/optim/fused_adam.py
93 25 5
def build_model()
in fairseq/models/multilingual_transformer.py
103 25 3
def upgrade_state_dict_named()
in fairseq/models/roberta/model.py
67 24 3
def load_dataset()
in fairseq/tasks/semisupervised_translation.py
196 23 4
def load_checkpoint()
in fairseq/checkpoint_utils.py
73 23 3
def _build_optimizer()
in fairseq/trainer.py
67 23 1
def _generate_sentence_pair()
in fairseq/data/legacy/block_pair_dataset.py
44 23 5
def forward()
in fairseq/criterions/model_criterion.py
49 23 4
def generate()
in fairseq/sequence_scorer.py
107 22 4