Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Quick introduction to scalafix
Rikito Taniguchi
January 19, 2019
Technology
1
120
Quick introduction to scalafix
Scala fukuoka 2019 LT
Rikito Taniguchi
January 19, 2019
Tweet
Share
More Decks by Rikito Taniguchi
See All by Rikito Taniguchi
Tooling for Scala3
tanishiking
0
150
API-Based Code Search
tanishiking
0
27
Things happening before start coding with Metals ~behind the curtain of daily coding~
tanishiking
0
340
How we replaced a 10-year-old Perl product using Scala
tanishiking
14
31k
Format things with scalafmt
tanishiking
1
1.2k
トランザクション技術入門
tanishiking
0
88
Scala製インタプリタをブラウザで動かす3分クッキング
tanishiking
1
150
R-tree と MySQL と PostGIS
tanishiking
0
180
scalaz.\/ が便利だった話
tanishiking
0
1.1k
Other Decks in Technology
See All in Technology
20220510_簡単にできるコスト異常検出(Cost Anomaly Detection) /jaws-ug-asa-cost-anomaly-detection-20220510
emiki
2
310
読者のことを考えて書いてみよう / Write with your reader in mind
line_developers
PRO
3
320
プロダクション環境の信頼性を損ねず観測する技術
egmc
4
330
ITエンジニアを取り巻く環境とキャリアパス / A career path for Japanese IT engineers
takatama
0
580
LINEスタンプの実例紹介 小さく始める障害検知・対応・振り返りの 改善プラクティス
line_developers
PRO
3
1.3k
次期LTSに備えよ!AOS 6.1 HCI Core 編
smzksts
0
170
jaws-ug-asa-datasync-20220510
hiashisan
0
470
JAWS-UG 朝会 #33 登壇資料
takakuni
0
380
様々な現場のPower Platform ~小さなエンジニアの奮闘記~
hyodol2513
0
1.9k
Deeplearning from almost scratch
hn410
0
580
Microsoft Power Automate で 始めるRPAと自動化
taikiyoshida
0
2k
Power BI ”を” 可視化しよう!
hanaseleb
0
150
Featured
See All Featured
Building Applications with DynamoDB
mza
83
4.6k
The Power of CSS Pseudo Elements
geoffreycrofte
46
3.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
19
1.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
253
11k
Infographics Made Easy
chrislema
233
17k
Visualization
eitanlees
124
11k
Done Done
chrislema
174
14k
A Philosophy of Restraint
colly
192
14k
Git: the NoSQL Database
bkeepers
PRO
415
59k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
100
5.9k
What's in a price? How to price your products and services
michaelherold
229
9.3k
Writing Fast Ruby
sferik
612
57k
Transcript
Quick introduction to scalafix Scala福岡 2019
About me - 谷口 力斗 / @tanishiking - 株式会社はてな -
Scala / TypeScript / Go / Perl - 高校生までは福岡に住んでました
Scalafix - https://scalacenter.github.io/scalafix/ - Refactoring and linting tool for Scala
- scala.meta - Builtin Rules / Suppressing Rules - Linter - 独自ルールを作ろう
Scala.meta
Scala.meta - https://scalameta.org/ - Scala compiler とは独立した Scala プログラム 解析のためのライブラリ
- Syntactic API - Semantic API
Scala.meta - Syntactic API - Scalaプログラムをパースしトークン列や構文木 を返すAPI println("function(argument)".parse[Stat].get.struct ure) //
Term.Apply(Term.Name("function"), List(Term.Name("argument")))
Scala.meta - Semantic API - 型情報やシンボルの情報を提供するAPI - compiler plugin を使って
typer phase の後に SemanticDB を生成 - SemanticDB - protobuf で定められたスキーマに従ってシリ アライズされたバイナリ
Builtin Rules / Supressing Rules
Builtin Rules - https://scalacenter.github.io/scalafix/docs/rul es/overview.html // .scalafix.conf rules = [
DisableSyntax, RemoveUnused ]
Suppressing Rules @SuppressWarnings(Array("all")) def foo = ??? List("", null) //
scalafix: ok // scalafix: off foo(null) // scalafix: on
Linter
Linter - v0.5 から linter としての機能が豊富に - 将来的に metals (scala.meta
ベースの Language Server 実装) から scalafix を使った refactoring や lint の提供も
Lint (vs wartremover) - (+) Lintに加えて自動修正もできる - (+) syntactic rulesの実行にコンパイルは不要
なので高速 - (+) 独自ルールの実装が容易(wart実装も難しくないけど) - (-) Builtin rule が少ない - (-) scala compiler と比べて SemanticDB から取 得できる情報は制限される
独自ルールを 作ろう
独自ルールを作ろう https://scalacenter.git hub.io/scalafix/docs/d evelopers/setup.html
独自ルールを作ろう - 作ってみた https://github.com/tanishiking/scalafix-check-scaladoc - publicなAPIにscaladocが書かれてなかったら 怒ってくれるルール - golintとかにあるやつ
まとめ - scalafix は refactoring ツールとしてだけでなく linter としても使える - scala.metaのAPIを使って簡単に独自ルールが
作れる