facebookresearch / SpanBERT
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 889 units with 9,795 lines of code in units (84.9% of code).
    • 4 very complex units (898 lines of code)
    • 7 complex units (825 lines of code)
    • 30 medium complex units (1,370 lines of code)
    • 78 simple units (1,530 lines of code)
    • 770 very simple units (5,172 lines of code)
9% | 8% | 13% | 15% | 52%
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
py9% | 8% | 13% | 15% | 52%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
code32% | 18% | 17% | 8% | 24%
pretraining0% | 26% | 17% | 29% | 27%
pretraining/fairseq/modules0% | 13% | 0% | 12% | 73%
code/pytorch_pretrained_bert0% | 8% | 17% | 20% | 53%
pretraining/fairseq0% | 0% | 15% | 21% | 63%
pretraining/fairseq/models0% | 0% | 16% | 5% | 78%
pretraining/fairseq/data0% | 0% | 12% | 24% | 62%
pretraining/fairseq/tasks0% | 0% | 30% | 0% | 69%
pretraining/fairseq/optim0% | 0% | 5% | 14% | 79%
pretraining/fairseq/criterions0% | 0% | 0% | 36% | 63%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
def main()
in code/run_glue.py
235 82 1
def main()
in code/run_squad.py
238 71 1
def main()
in code/run_mrqa.py
225 68 1
def main()
in code/run_tacred.py
200 67 1
134 36 6
def main()
in pretraining/preprocess.py
148 35 1
96 33 6
128 32 6
def make_predictions()
in code/run_squad.py
139 30 8
def from_pretrained()
in code/pytorch_pretrained_bert/modeling.py
89 29 7
def forward()
in pretraining/fairseq/modules/multihead_attention.py
91 26 9
def train_step()
in pretraining/fairseq/trainer.py
90 25 3
def make_predictions()
in code/run_mrqa.py
103 23 7
def load_tf_weights_in_bert()
in code/pytorch_pretrained_bert/modeling.py
59 22 2
58 20 5
def _is_chinese_char()
in code/pytorch_pretrained_bert/tokenization.py
11 20 2
def from_pretrained()
in pretraining/fairseq/models/hf_bert.py
75 20 6
def from_pretrained()
in pretraining/fairseq/models/pair_bert.py
75 20 6
def get_from_cache()
in code/pytorch_pretrained_bert/file_utils.py
49 19 2
def evaluate()
in code/run_squad.py
56 19 9