apple / swift
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 44,045 units with 520,848 lines of code in units (45.4% of code).
    • 141 very complex units (40,978 lines of code)
    • 408 complex units (43,764 lines of code)
    • 1,920 medium complex units (101,265 lines of code)
    • 3,358 simple units (90,691 lines of code)
    • 38,218 very simple units (244,150 lines of code)
7% | 8% | 19% | 17% | 46%
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
cpp9% | 9% | 23% | 19% | 37%
h1% | 2% | 5% | 9% | 81%
swift<1% | 3% | 3% | 5% | 87%
py1% | 11% | 13% | 20% | 52%
c0% | 19% | 19% | 10% | 50%
inc0% | 0% | 30% | 22% | 47%
mm0% | 0% | 9% | 16% | 73%
m0% | 0% | 0% | 79% | 20%
Conditional Complexity per Logical Component
primary logical decomposition
51+
26-50
11-25
6-10
1-5
lib9% | 9% | 23% | 19% | 37%
tools12% | 8% | 15% | 16% | 46%
include1% | 1% | 5% | 9% | 81%
benchmark3% | 0% | 3% | 7% | 86%
utils<1% | 10% | 14% | 19% | 53%
stdlib0% | 5% | 8% | 13% | 71%
validation-test0% | <1% | <1% | 6% | 92%
SwiftCompilerSources0% | 0% | 17% | 12% | 69%
unittests0% | 0% | 3% | 9% | 87%
Most Complex Units
Top 20 most complex units
Unit# linesMcCabe index# params
bool SILParser::parseSpecificSILInstruction()
in lib/SIL/Parser/ParseSIL.cpp
2765 955 5
NodePointer NodePrinter::print()
in lib/Demangling/NodePrinter.cpp
1741 493 3
bool isSimpleType()
in lib/Demangling/NodePrinter.cpp
309 298 1
bool ConstraintSystem::repairFailures()
in lib/Sema/CSSimplify.cpp
869 292 5
void SILSerializer::writeSILInstruction()
in lib/Serialization/SerializeSIL.cpp
1460 274 1
RuntimeEffect swift::getRuntimeEffect()
in lib/SIL/Utils/InstructionUtils.cpp
441 259 2
bool SILDeserializer::readSILInstruction()
in lib/Serialization/DeserializeSIL.cpp
1653 259 4
static void diagSyntacticUseRestrictions()
in lib/Sema/MiscDiagnostics.cpp
928 246 3
TypeLookupErrorOr decodeMangledType()
in include/swift/Demangling/TypeDecoder.h
658 203 3
Type Type::transformRec()
in lib/AST/Type.cpp
620 188 1
static bool hasOpaqueArchetype()
in lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp
217 188 2
InlineCost swift::instructionInlineCost()
in lib/SILOptimizer/Utils/SILInliner.cpp
231 187 1
func getIndex()
in benchmark/single-source/StringSwitch.swift
190 186 1
bool Parser::parseNewDeclAttribute()
in lib/Parse/ParseDecl.cpp
813 186 4
ImportedName NameImporter::importNameImpl()
in lib/ClangImporter/ImportName.cpp
563 184 3
CheckedCastKind TypeChecker::typeCheckCheckedCast()
in lib/Sema/TypeCheckConstraints.cpp
403 180 7
256 171 2
void irgen::emitBuiltinCall()
in lib/IRGen/GenBuiltin.cpp
930 165 6
275 141 6
static int handleTestInvocation()
in tools/SourceKit/tools/sourcekitd-test/sourcekitd-test.cpp
615 134 2