Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Cyclomatic Complexity
Search
Anna Filina
October 08, 2016
Programming
290
0
Share
Cyclomatic Complexity
Don’t write unnecessary tests anymore. Use a simple, scientific approach.
Anna Filina
October 08, 2016
More Decks by Anna Filina
See All by Anna Filina
Surviving a Symfony Upgrade
afilina
1
170
Upgrading Legacy to the Latest PHP Version
afilina
1
180
Better Code Design in PHP
afilina
0
300
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
190
Better Code Design in PHP
afilina
1
450
Better Code Design in PHP
afilina
0
620
Adding Tests to Untestable Legacy Code
afilina
0
390
Upgrading Legacy to the Latest PHP Version
afilina
0
420
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
320
Other Decks in Programming
See All in Programming
Road to RubyKaigi: Play Hard(ware)
makicamel
1
480
Running Swift without an OS
kishikawakatsumi
0
850
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
320
Explore CoroutineScope
tomoeng11
0
110
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
実践CRDT
tamadeveloper
0
600
Kingdom of the Machine
yui_knk
2
1.1k
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
2
460
How Swift's Type System Guides AI Agents
koher
0
310
実用!Hono RPC2026
yodaka
2
280
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
1k
第3木曜LT会 #28
tinykitten
PRO
0
120
Featured
See All Featured
The Language of Interfaces
destraynor
162
26k
Automating Front-end Workflow
addyosmani
1370
200k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
270
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
190
Designing for Performance
lara
611
70k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
Mobile First: as difficult as doing things right
swwweet
225
10k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
Technical Leadership for Architectural Decision Making
baasie
3
340
The World Runs on Bad Software
bkeepers
PRO
72
12k
Bash Introduction
62gerente
615
210k
Paper Plane
katiecoart
PRO
1
49k
Transcript
foolab.ca | @foolabca Cyclomatic Complexity Bulgaria PHP, Sofia - October
8, 2016
Execution Paths public function getShipping() { if ($this->subtotal >= 40)
{ return 0; } return $this->standardShipping; } 2
Execution Paths public function getShipping() { if ($this->subtotal >= 40)
{ return 0; } return $this->standardShipping; } 3 Path 1 Path 2
Decision Branches 4 start product loop free shipping? end
Decision Branches 5 start product loop free shipping? end
Cyclomatic complexity = edges − nodes + 2 * connected
components
Decision Branches 7 start product loop free shipping? end ◦
Edges ◦ Nodes ◦ Connected components.
Decision Branches 8 start product loop free shipping? end ◦
Edges ◦ Nodes ◦ Connected components.
Decision Branches 9 start product loop free shipping? end ◦
Edges ◦ Nodes ◦ Connected components.
Cyclomatic complexity = 9 − 8 + 2 * 1
= 3
Zero Times foreach ($products as $product) { $total = $product->price
* $product->quantity; } $tax = $total * ... 11
Multiple Times $total = 0; foreach ($products as $product) {
$total = $product->price * $product->quantity; } $tax = $total * ... 12
Multiple Times $total = 0; foreach ($products as $product) {
$total += $product->price * $product->quantity; } $tax = $total * ... 13
@afilina afilina.com