$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Cyclomatic Complexity
Search
Anna Filina
October 08, 2016
Programming
0
280
Cyclomatic Complexity
Don’t write unnecessary tests anymore. Use a simple, scientific approach.
Anna Filina
October 08, 2016
Tweet
Share
More Decks by Anna Filina
See All by Anna Filina
Surviving a Symfony Upgrade
afilina
0
78
Upgrading Legacy to the Latest PHP Version
afilina
1
150
Better Code Design in PHP
afilina
0
270
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
170
Better Code Design in PHP
afilina
1
430
Better Code Design in PHP
afilina
0
590
Adding Tests to Untestable Legacy Code
afilina
0
370
Upgrading Legacy to the Latest PHP Version
afilina
0
380
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
290
Other Decks in Programming
See All in Programming
堅牢なフロントエンドテスト基盤を構築するために行った取り組み
shogo4131
8
2.4k
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
7
2.5k
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
410
從冷知識到漏洞,你不懂的 Web,駭客懂 - Huli @ WebConf Taiwan 2025
aszx87410
2
2.6k
AIコーディングエージェント(skywork)
kondai24
0
170
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
330
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
3
720
実は歴史的なアップデートだと思う AWS Interconnect - multicloud
maroon1st
0
140
Developing static sites with Ruby
okuramasafumi
0
290
バックエンドエンジニアによる Amebaブログ K8s 基盤への CronJobの導入・運用経験
sunabig
0
160
FluorTracer / RayTracingCamp11
kugimasa
0
230
非同期処理の迷宮を抜ける: 初学者がつまづく構造的な原因
pd1xx
1
720
Featured
See All Featured
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
It's Worth the Effort
3n
187
29k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
390
KATA
mclloyd
PRO
32
15k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
How to Ace a Technical Interview
jacobian
280
24k
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