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
180
Upgrading Legacy to the Latest PHP Version
afilina
1
190
Better Code Design in PHP
afilina
0
300
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
200
Better Code Design in PHP
afilina
1
460
Better Code Design in PHP
afilina
0
620
Adding Tests to Untestable Legacy Code
afilina
0
400
Upgrading Legacy to the Latest PHP Version
afilina
0
430
Semi-Automated Refactoring and Upgrades with Rector
afilina
0
330
Other Decks in Programming
See All in Programming
ふにゃっとしない名前の付け方 〜哲学で茹で上げる、コシのあるソフトウェア設計〜
shimomura
0
130
自動レビューエンジンの実装と運用 ~レビューのない世界へ~
kurukuru1999
1
170
Modding RubyKaigi for Myself
yui_knk
0
390
cloudnative conference 2026 flyle
azihsoyn
1
200
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
280
AI時代だからこそ「Bloc」を採用する価値があるのかもしれない
takuroabe
0
220
Moments When Things Go Wrong
aurimas
3
100
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
4
420
UaaL×Androidアプリのメモリ計測 — Memory Profilerの先へ
rio432
0
170
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
860
My daily life on Ruby
a_matsuda
3
430
GitHub Copilot CLIのいいところ
htkym
2
550
Featured
See All Featured
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
230
The Mindset for Success: Future Career Progression
greggifford
PRO
0
340
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Raft: Consensus for Rubyists
vanstee
141
7.4k
Chasing Engaging Ingredients in Design
codingconduct
0
190
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Code Reviewing Like a Champion
maltzj
528
40k
Between Models and Reality
mayunak
4
290
Tell your own story through comics
letsgokoyo
1
930
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
190
The SEO Collaboration Effect
kristinabergwall1
1
450
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