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
PHPMDのPHPMDによる静的解析結果
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
iwamot
PRO
May 27, 2022
Technology
960
0
Share
PHPMDのPHPMDによる静的解析結果
2022-05-27
PHPerのための「静的解析」を語り合うPHP TechCafe
https://rakus.connpass.com/event/245646/
iwamot
PRO
May 27, 2022
More Decks by iwamot
See All by iwamot
自己紹介
iwamot
PRO
1
56
パワポ作るマンをMCP Apps化してみた
iwamot
PRO
0
470
8万デプロイ
iwamot
PRO
2
360
AIエージェント・マイクロサービス時代。AWSでの手軽な構築法を考えて試してみた
iwamot
PRO
1
99
これがLambdaレス時代のChatOpsだ!実例で学ぶAmazon Q Developerカスタムアクション活用法
iwamot
PRO
10
2.7k
Developer Certificate of Origin、よさそう
iwamot
PRO
0
90
復号できなくなると怖いので、AWS KMSキーの削除を「面倒」にしてみた CODT 2025 クロージングイベント版
iwamot
PRO
1
200
復号できなくなると怖いので、AWS KMSキーの削除を「面倒」にしてみた
iwamot
PRO
3
160
IPA&AWSダブル全冠が明かす、人生を変えた勉強法のすべて
iwamot
PRO
14
12k
Other Decks in Technology
See All in Technology
Sony_KMP_Journey_KotlinConf2026
sony
2
210
形式手法特論:公平性制約の位相的特徴づけ #kernelvm / Kernel VM Study Kansai 12th
ytaka23
1
710
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.9k
Chart.js が簡単に使えるようになっていたので OGP 画像生成に使った話
kamekyame
0
140
「嘘をつくテスト」の失敗例から学ぶ 良いテストコード #frontend_phpcon_do
asumikam
0
170
イベントストーミングとKiroの仕様駆動開発で実現する要件の認識合わせプロセス
syobochim
7
1.1k
AIガバナンス実践 - 生成AIコネクタのデータ漏洩リスクと実務対策
knishioka
0
170
Platform Engineering as a Product: Criteria for Improvement and Multi-Tenant Design
kumorn5s
0
490
製造業のクラウド活用最適解〜AI,DXを加速するデータ基盤の作り方〜
hamadakoji
0
330
電子辞書Brainをネットに繋げてみた(自力編)
raspython3
0
430
【Gen-AX】20260530開催_JJUG CCC 2026 Spring
genax
0
410
Gradle×GitHub_ActionsでCI時間を約50%短縮 ジョブ分割の設計と落とし穴 / Cutting CI Time by ~50% with Gradle and GitHub Actions: Job-Splitting Design and Pitfalls
takatty
0
620
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
350
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
170
Facilitating Awesome Meetings
lara
57
6.9k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
200
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.3k
Ruling the World: When Life Gets Gamed
codingconduct
0
240
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Transcript
PHPMDの PHPMDによる静的解析結果 2022-05-27 PHPerのための「静的解析」を語り合うPHP TechCafe https://rakus.connpass.com/event/245646/ ENECHANGE株式会社 インフラエンジニア 岩本隆史 (@iwamot)
2019年、リファクタリングを任された 当時は旅行業の会社に勤めていた アクティビティ予約サービスをCakePHPで開発していた 20,000行超のファイルがあるなど、コードの品質が気になった リファクタリングしたいと申し出た
静的解析ツールを探し始めた リファクタリングの優先度を決めるのに使いたい
PHPMDを見つけた https://phpmd.org/ PHP Mess Detector(いわゆる「コードの不吉な匂い」を検出) SiderやCodacyでも使われていたので、試す価値があると思った
好奇心から、PHPMD自体を解析した PHPMD自体もPHPで書かれている 当時のコードをいま解析するなら下記のような感じ $ git clone https://github.com/phpmd/phpmd.git $ cd phpmd
$ git checkout 42bf8ad4 $ docker run -it --rm \ -v /path/to/phpmd/src:/src \ iwamot/phpmd-docker:2.12.0 /src html \ cleancode,codesize,controversial,design,naming,unusedcode \ --exclude /src/test > phpmd-result.html
不吉な匂いが35件も検出された
OSS貢献のチャンスだと思った 不吉な匂いの検出ツールなのに、不吉な匂いが多いのは切ない 修正プルリクエストを送ろう!
修正ターゲットを決めた 未使用変数 $list が戻り値に使われている 明らかなバグはこれだけだった
PRを送ったらマージされた https://github.com/phpmd/phpmd/pull/598
めでたしめでたし
しかし
リファクタリングは完遂できなかった 自社サービスのコード解析は済ませた リファクタリングも順調に進めていた そこへ新型コロナが来てしまった いろいろあって退職することに
PHPMDの不吉な匂いも増えている 当時の35件から39件に (fcb0f1f3)
ともあれ
静的解析ツールを解析してみると 発見があるかも