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
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
250
Fragmented Architectures
denyspoltorak
0
150
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
5.9k
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
240
Architectural Extensions
denyspoltorak
0
270
CSC307 Lecture 01
javiergs
PRO
0
690
Package Management Learnings from Homebrew
mikemcquaid
0
200
開発者から情シスまで - 多様なユーザー層に届けるAPI提供戦略 / Postman API Night Okinawa 2026 Winter
tasshi
0
190
AI & Enginnering
codelynx
0
110
Implementation Patterns
denyspoltorak
0
280
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
170
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
52
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Bash Introduction
62gerente
615
210k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
72
YesSQL, Process and Tooling at Scale
rocio
174
15k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
120
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.7k
Balancing Empowerment & Direction
lara
5
880
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