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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
hihats
August 28, 2017
Technology
270
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
コードの静的解析ツールを使う目的と効用
最近の解析ツールはソースコードのスコアリングもしてくれますが、それってどういう基準なの?
というお話をしました。
hihats
August 28, 2017
More Decks by hihats
See All by hihats
Which Json Serializer should we use in Ruby on Rails6 era
hihats
1
150
ソフトウェア設計についての基本認識
hihats
1
120
アジャイル開発を始める前におさえておきたいこと
hihats
0
130
AWS Lambdaの今現在
hihats
0
820
DIコンテナを学ぶ
hihats
2
410
Laravel勉強会 2016
hihats
0
1.5k
Other Decks in Technology
See All in Technology
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
5
1.2k
フロントエンドカンファレンス関西2026 - 速すぎるUIに、待ち時間を
teamlab
PRO
0
190
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
130
自作バイナリを動かす「入口」8選
puhitaku
2
1.3k
アウトプット初心者、半年間のふりかえり
4o1sobblue
0
440
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
340
Local CI × GitHub Actions
gogutan
3
230
1つのリクエストを追って理解する - llm-dのP/D分離
akhino
1
170
Browser Spec: Testing Hotwire with Ruby
takahashim
1
130
Code for Security プロジェクト紹介 2026年10月
yu23ki14
0
110
大型犬好きによるPugの紹介
yamanoku
1
160
CTO Night|NotionのAIエージェントとFDE
kzkhykw1991
0
230
Featured
See All Featured
Become a Pro
speakerdeck
PRO
31
6.3k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
940
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
280
My Coaching Mixtape
mlcsv
0
360
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.1k
A designer walks into a library…
pauljervisheath
211
25k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
480
Faster Mobile Websites
deanohume
310
32k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
410
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
460
Amusing Abliteration
ianozsvald
1
350
Transcript
コードの静的解析ツール コードメトリクスについて
コードを静的解析してくれるツール PHP • phpmd • phpcs Ruby • Rubocop Javascript
• ESLint
• 一般的な規約に沿っているか • コーディングスタイルの統一 導入目的
だけではない
コードのスコアリング コードの定量評価(いわゆる点数付け)もしてくれる
どういう基準で?
• Coupling • Cohesion • Size • Complexity
凝集度と結合度 構造化設計
凝集度 Cohesion 各モジュール内の関連性を最大に すること class A { int width; Int
height; function widen(int add){ width = width + add; } function highten(int add){ height = height + add; } } クラスのメンバ変数 は2つ 2つのメソッドで使 われているメンバ 変数はそれぞれ ひとつずつ
凝集度 Cohesion 各モジュール内の関連性を最大に すること class A { int width; Int
height; function widen(int add){ width = width + add; } function highten(int add){ height = height + add; } } クラスのメンバ変数 は2つ 2つのメソッドで使 われているメンバ 変数はそれぞれ ひとつずつ 凝集度はそれほど 高くない
結合度 Coupling モジュール間の関連性を最小にす ること class Square { require Rhombus; function
square(rhombus = new Rhombus){ return rhombus->width * rhombus->width; } } 属性は ・width ・angle があるが、angle がSquareの計算 に必要かというと 必要ない
結合度 Coupling モジュール間の関連性を最小にす ること class Square { function square(rhombus_width){ return
rhombus_width * rhombus_width; } } 属性は ・width ・angle があるが、angle がSquareの計算 に必要かというと 必要ない 結合度が下がった!
循環的複雑度 簡単に言うとコードの分岐数
ifやforを使うと1ずつ増えていく foreach ($array as $key => $value ){ for ($i+0;
$i< $max; $++){ switch($value[$i]){ case 1: If ($value…) …… 分岐がなければ1(Best値) function good_method($array){ return array_map(function($n) { return $n * $n; }, $array); }
ネストが深くなっている = 「責務を負いすぎている」 という考え方
詳しくはGoogleのブログ https://testing.googleblog.com/2011/02/this- code-is-crap.html
まとめ コードの静的解析ツールはルールの統一だけでなく、コードのスコアリングも してくれる 基準となるのは ・ 凝集度 ・ 結合度 ・ 循環的複雑度
注意点 あくまでコードを多角的にみるためのもの 指標に囚われすぎるのはよくない 運用してみて、しっくりこないのであれば緩くするのもあり