apple / swift-driver
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
Unit Size Overall
  • There are 427 units with 5,539 lines of code in units (24.7% of code).
    • 4 very long units (615 lines of code)
    • 8 long units (574 lines of code)
    • 56 medium size units (1,701 lines of code)
    • 86 small units (1,265 lines of code)
    • 273 very small units (1,384 lines of code)
11% | 10% | 30% | 22% | 24%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
swift9% | 10% | 31% | 23% | 26%
cpp72% | 0% | 0% | 13% | 14%
py0% | 16% | 41% | 25% | 17%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
Sources/SwiftDriver9% | 11% | 32% | 22% | 24%
Sources/makeOptions72% | 0% | 0% | 13% | 14%
Utilities0% | 16% | 41% | 25% | 17%
Sources/swift-help0% | 0% | 81% | 18% | 0%
Sources/SwiftOptions0% | 0% | 18% | 45% | 36%
Sources/SwiftDriverExecution0% | 0% | 0% | 24% | 75%
Sources/swift-driver0% | 0% | 0% | 100% | 0%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
mutating func addCommonFrontendOptions()
in Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
196 34 4
int makeOptions_main()
in Sources/makeOptions/makeOptions.cpp
168 30 0
mutating func compileJob()
in Sources/SwiftDriver/Jobs/CompileJob.swift
128 20 3
init()
in Sources/SwiftDriver/SwiftScan/SwiftScan.swift
123 1 1
mutating func addFrontendSupplementaryOutputArguments()
in Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
98 16 6
mutating func addCompileInputs()
in Sources/SwiftDriver/Jobs/CompileJob.swift
91 20 6
mutating func visit()
in Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraph.swift
80 9 1
init?()
in Sources/SwiftDriver/IncrementalCompilation/BuildRecord.swift
71 7 2
def main()
in Utilities/build-script-helper.py
69 15 0
mutating func mergeModuleJob()
in Sources/SwiftDriver/Jobs/MergeModuleJob.swift
59 6 2
mutating func visit()
in Sources/SwiftDriver/IncrementalCompilation/SourceFileDependencyGraph.swift
54 9 1
func batchScanDependencies()
in Sources/SwiftDriver/SwiftScan/SwiftScan.swift
52 4 4
func visit()
in Sources/SwiftDriver/ExplicitModuleBuilds/ClangVersionedDependencyResolution.swift
50 11 3
def handle_invocation()
in Utilities/build-script-helper.py
50 18 1
mutating func formBatchedJobs()
in Sources/SwiftDriver/Jobs/Planning.swift
49 3 2
mutating func generatePCHJob()
in Sources/SwiftDriver/Jobs/GeneratePCHJob.swift
48 5 2
mutating func backendJob()
in Sources/SwiftDriver/Jobs/BackendJob.swift
46 3 3
func printTargetInfoJob()
in Sources/SwiftDriver/Jobs/PrintTargetInfoJob.swift
45 7 8
func addArgsToLinkStdlib()
in Sources/SwiftDriver/Jobs/Toolchain+LinkerSupport.swift
40 7 5
func addAllOutputsFor()
in Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
39 2 1