Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
クソコードの測り方
Search
Hiraku NAKANO
March 01, 2016
Technology
12k
36
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
クソコードの測り方
PHPBLT#3 で話した内容です。
Hiraku NAKANO
March 01, 2016
More Decks by Hiraku NAKANO
See All by Hiraku NAKANO
iD決済を支える技術 / #merpay_techtalk
hirak
33
7.3k
github.com/mercari の今と昔 /github-mercari
hirak
8
3.2k
PHPStanで始める継続的静的解析 #phperkaigi /php-static-analysis
hirak
14
55k
極める!メソッドチェーン #phpstudy / fluent-interface
hirak
8
3.1k
evalこそパワー #phpkansai / phpkansai2017
hirak
2
1.8k
PHPのエラーと例外再入門 / php-error-and-exception
hirak
19
20k
メルカリ JP Tech Side / mercari-jp-tech-side
hirak
7
2.1k
グローバル展開を支える量子的なサービス設計 #mercariday / mercariday2017-api
hirak
22
14k
Composerプラグインを作ってみよう /phpcon2016
hirak
5
14k
Other Decks in Technology
See All in Technology
AIエージェント時代、Kaggleにどう取り組むか
takanao
2
410
なぜ東京にいる私が、新潟の技術コミュニティを運営するのか by 八雲慎之助
yakumo
0
130
E2Eってつらくないですか?E2Eの管理コストを下げる手段とその実践
akaboshinit
6
2.8k
これだけは抑えておきたい!後悔しない re:Invent の過ごし方 / AWS re:Invent 2026 prestudy
kinunori
2
590
GitHub、使う?使わない?
happysamurai294
0
120
Adversary Infrastructure Hunting101
disconinja
0
180
増え続けるプロダクトの品質をどう担保するか。ProductSpecとTypeScriptによる取り組み
joere
2
230
AIコーディングエージェント開発_全体像
happysamurai294
0
130
日本AIベンチャーレポート2026
kentarofujii
0
260
Agent 活用環境の構築・運用のための AWS サービスのご紹介/agentcore-for-building-and-operating-agents
ren8k
1
280
Flutter Widget Previewerで始めるUIプレビューとVRTの自動化
sakusaku3939
0
180
外国人エンジニアがVueプロトタイプで仕様を合わせている話 / Vue Fes Japan 2026 LT
eluwing
0
320
Featured
See All Featured
A Tale of Four Properties
chriscoyier
163
24k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
How to Ace a Technical Interview
jacobian
280
24k
Exploring anti-patterns in Rails
aemeredith
4
550
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
470
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
760
Transcript
Ϋιίʔυͷ ଌΓํ PHPBLT #3 @Hiraku
ࣗݾհ • த (@Hiraku) • ޱบʮcomposer͕͍ʯʮޫ͕͍ʯˡNew! • ޫ͍Λࠀͯ͠composerΛ10ഒͨ͘͠ http://tech.mercari.com/entry/2016/02/01/164829
hirak/prestissimo (composerߴԽϓϥάΠϯ) Πϯετʔϧ͢Δ͚ͩͰ10ഒ͙Β͍͘ͳΓ·͢
hirak/prestissimo • ͝ԉ͋Γ͕ͱ͏͍͟͝·͢
prestissimoΛൃද͔ͯ͠Β Ұϲ݄
͜͜Ұϲ݄ͷՌ → 1/24 2/28
Scrutinizer • ίʔυ࣭ʹΛ͚ͭΔαʔϏε (OSSͳΒແྉʂ) • όάͬΆ͍ॴΛݟ͚ͭͯ͘ΕΔ • 10ຬ
ϝιουผͷ
ScrutinizerείΞͷ্͛ํ • ৭(AϥϯΫ)ͷϝιου͔ΓʹͳͬͨΒɺ 10.00ʹͳΔ • ଌఆ݁Ռ৭ʑग़ͯ͘Δ͕ɺͲ͜Λमਖ਼͢Ε ͍͍ͷ͔ʁ
͜͜ʹ
C.R.A.P. =Change Risk Anti-Patterns
༁͢Δͱ Ϋι
CRAPͱ • Ϋιίʔυͷ߹͍Λఆྔతʹදͨ͠ࣈ • 1ʙແݶେ • If CRAP1(m) > 30,
we consider the method to be CRAPpy.
Googleͷϒϩά͕ৄ͍͠ http://googletesting.blogspot.jp/2011/02/this-code-is-crap.html
None
comp(m) = ॥తෳࡶ cov(m) = ςετΧόϨοδ
comp(m)=॥తෳࡶ • ίʔυͷذΛ͑ͨͷ • ifforΛ͏ͱ1ͣͭ૿͑Δ(্ݶͳ͍) • ذ͕ͳ͚Ε1
cov(m)=ςετΧόϨοδ • ϢχοτςετͰ࣮ߦ͞Εͨίʔυͷׂ߹ • ͜͜Ͱݴ͏ΧόϨοδC0ΧόϨοδͷ͜ͱ ҰͰશߦ࣮ߦ͍ͯ͠Ε100% • 0%ʙ100%ͷؒͷࣈ
cov(m)͕100%ͩͬͨΒ ͕͜͜0ʹͳΔΑͶ
comp(m)=1, cov(m)=0% ͕͜͜1ʹͳΔΑͶ ͜͜1ʹͳΔΑͶ
CRAPͱมͷؔ • comp(m) ্͕͕Δͱ 2ͷ͍Ͱ૿͑Δ • cov(m)্͕͕Δͱগ ͠؇͞ΕΔ • ΧόϨοδ͕100%Ͱ
ɺෳࡶ͕30Λ ͍͑ͯͨΒμϝ
৭͕CRAP<30
CRAPείΞͷԼ͛ํ
جຊతͳϧʔϧ • ෳࡶϝιουผͳͷͰɺࡉׂ͔͘͢Δ ͱݮΔ • ϢχοτςετΛॻ͚ݮΔ
ݱ࣮తͳ • ෳࡶͳίʔυϢχοτςετͮ͠Β͍ • ςετ͘͢͠ॻ͖͑ͯΏ͘ • →ࣗવͱίʔυׂ͕͞ΕΔʂ
ιʔεΛ͘͢Δ • ಉ͡ϩδοΫΛ͍ίʔυͰ࠶ݱ͢Δ • ϥΠϒϥϦؔͷ׆༻ • ίϐϖΛݮΒͯؔ͠ڞ௨Խ • ࠶ؼʹॻ͖͑Δ
PHPUnitͰCRAPܭଌ • ΧόϨοδϨϙʔτͰCRAPείΞಡΊ·͢
prestissimoͷي
None
None
None
ࠓͷ·ͱΊ • ΫιίʔυΛఆྔతʹఆ͢Δํ๏͕͋Δ • ଌͬͯΈΔͱ໘ന͍ΑɺPHPUnitͰΘ͔ΔΑ • Ғͦ͏ʹղઆ͚ͨ͠ͲScrutinizerείΞ10.00 ·ͩ౸ୡͯ͠ͳ͍
ิɿ CRAP͕ڭ͑ͯ͘Εͳ͍ͷ • ιϑτΣΞ͕͍͔Ͳ͏͔ • ʹཱ͔ͭʢΧωΛੜΉ͔ʣ • ֦ுੑʹ༏Ε͍ͯΔ͔ (͋͘·ͰෳࡶͷͰ͋Δ͜ͱʹҙ)