facebookresearch / pytext
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,109 units with 24,000 lines of code in units (54.0% of code).
    • 0 very complex units (0 lines of code)
    • 2 complex units (119 lines of code)
    • 54 medium complex units (2,143 lines of code)
    • 184 simple units (4,166 lines of code)
    • 2,869 very simple units (17,572 lines of code)
0% | <1% | 8% | 17% | 73%
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% | <1% | 8% | 17% | 73%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
pytext/data0% | 1% | 9% | 18% | 71%
pytext/models0% | <1% | 4% | 14% | 80%
pytext/config0% | 0% | 21% | 17% | 61%
pytext/legacy0% | 0% | 18% | 23% | 58%
pytext/optimizer0% | 0% | 11% | 18% | 70%
pytext0% | 0% | 24% | 23% | 51%
pytext/metrics0% | 0% | 20% | 4% | 74%
pytext/utils0% | 0% | 10% | 24% | 65%
pytext/trainers0% | 0% | 26% | 17% | 55%
pytext/metric_reporters0% | 0% | 2% | 20% | 76%
pytext/task0% | 0% | 10% | 13% | 75%
pytext/fields0% | 0% | 11% | 28% | 60%
pytext/loss0% | 0% | 0% | 30% | 69%
pytext/torchscript0% | 0% | 0% | 6% | 93%
pytext/exporters0% | 0% | 0% | 0% | 100%
pytext/common0% | 0% | 0% | 0% | 100%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
def valid_actions()
in pytext/models/semantic_parsers/rnng/rnng_parser.py
41 27 2
def build_tree()
in pytext/data/data_structures/annotation.py
78 27 2
def v0_to_v1()
in pytext/config/config_adapter.py
35 22 1
def __init__()
in pytext/trainers/trainer.py
83 21 3
def v1_to_v2()
in pytext/config/config_adapter.py
60 20 1
def pretty_print_config_class()
in pytext/utils/documentation.py
46 20 1
def numericalize()
in pytext/legacy/data/field.py
40 19 3
def torchscriptify()
in pytext/models/doc_model.py
95 19 3
def torchscript_export()
in pytext/main.py
44 19 6
def step()
in pytext/optimizer/adabelief.py
83 18 3
def _value_to_json()
in pytext/config/serialize.py
30 18 2
def print_metrics()
in pytext/metrics/mask_metrics.py
36 16 1
def config_from_json()
in pytext/config/serialize.py
49 16 3
def merge_token_labels_by_label()
in pytext/utils/data.py
31 16 2
def _make_simple_list()
in pytext/metric_reporters/metric_reporter.py
21 16 2
def build_vocab()
in pytext/fields/text_field_with_special_unk.py
43 16 4
def get_no_fail_decoupled()
in pytext/data/decoupled_data.py
26 16 2
def print_metrics()
in pytext/metrics/__init__.py
97 15 2
def _value_from_json()
in pytext/config/serialize.py
27 15 2
def get_decoupled()
in pytext/data/decoupled_data.py
28 15 2