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
Upgrading Legacy to the Latest PHP Version
afilina
1
130
Better Code Design in PHP
afilina
0
260
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
580
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
Better Code Design in PHP
afilina
1
750
Other Decks in Programming
See All in Programming
業務でAIを使いたい話
hnw
0
260
AsyncSequenceとAsyncStreamのプロポーザルを全部読む!!
s_shimotori
1
270
Designing Repeatable Edits: The Architecture of . in Vim
satorunooshie
0
260
Kotlin + Power-Assert 言語組み込みならではのAssertion Library採用と運用ベストプラクティス by Kazuki Matsuda/Gen-AX
kazukima
0
110
Rails Girls Sapporo 2ndの裏側―準備の日々から見えた、私が得たもの / SAPPORO ENGINEER BASE #11
lemonade_37
2
100
Flutterアプリ運用の現場で役立った監視Tips 5選
ostk0069
1
340
Atomics APIを知る / Understanding Atomics API
ssssota
1
120
予防に勝る防御なし(2025年版) - 堅牢なコードを導く様々な設計のヒント / Growing Reliable Code PHP Conference Fukuoka 2025
twada
PRO
36
11k
高単価案件で働くための心構え
nullnull
0
110
JJUG CCC 2025 Fall: Virtual Thread Deep Dive
ternbusty
3
130
Verilator + Rust + gRPC と Efinix の RISC-V でAIアクセラレータをAIで作ってる話 RTLを語る会(18) 2025/11/08
ryuz88
0
340
イベントストーミングのはじめかた / Getting Started with Event Storming
nrslib
1
300
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.3k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Practical Orchestrator
shlominoach
190
11k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
Thoughts on Productivity
jonyablonski
73
4.9k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.2k
The Language of Interfaces
destraynor
162
25k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Speed Design
sergeychernyshev
32
1.2k
How STYLIGHT went responsive
nonsquared
100
5.9k
Six Lessons from altMBA
skipperchong
29
4.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
2.9k
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