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
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
120
Upgrading Legacy to the Latest PHP Version
afilina
1
160
Better Code Design in PHP
afilina
0
280
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
180
Better Code Design in PHP
afilina
1
440
Better Code Design in PHP
afilina
0
600
Adding Tests to Untestable Legacy Code
afilina
0
380
Upgrading Legacy to the Latest PHP Version
afilina
0
400
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
300
Other Decks in Programming
See All in Programming
今こそ知るべき耐量子計算機暗号(PQC)入門 / PQC: What You Need to Know Now
mackey0225
3
370
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
6k
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
1.1k
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
MUSUBIXとは
nahisaho
0
130
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
640
疑似コードによるプロンプト記述、どのくらい正確に実行される?
kokuyouwind
0
380
ぼくの開発環境2026
yuzneri
0
150
高速開発のためのコード整理術
sutetotanuki
1
390
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
970
Oxlintはいいぞ
yug1224
5
1.3k
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
88
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
230
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
130
Building Adaptive Systems
keathley
44
2.9k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Bash Introduction
62gerente
615
210k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3k
Chasing Engaging Ingredients in Design
codingconduct
0
110
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